#!/bin/bash

eval "$(ucr shell)"

PSOname=PSO1
PSOdn="CN=$PSOname,CN=Password Settings Container,CN=System,$samba4_ldap_base"

ldbadd -H /var/lib/samba/private/sam.ldb <<%EOF
dn: $PSOdn
objectClass: msDS-PasswordSettings
msDS-PasswordHistoryLength: 1
msDS-PasswordSettingsPrecedence: 1
msDS-PasswordReversibleEncryptionEnabled: FALSE
msDS-LockoutThreshold: 0
msDS-LockoutDuration: 0
msDS-LockoutObservationWindow: -18000000000
msDS-PasswordComplexityEnabled: TRUE
msDS-MinimumPasswordLength: 8
msDS-MinimumPasswordAge: 0
msDS-MaximumPasswordAge: -36288000000000
%EOF

ldbmodify -H /var/lib/samba/private/sam.ldb <<%EOF
dn: $PSOdn
changetype: modify
add: msDS-PSOAppliesTo
msDS-PSOAppliesTo: CN=Guests,CN=Builtin,$samba4_ldap_base
%EOF

ldbsearch -H /var/lib/samba/private/sam.ldb samaccountname=guest msDS-ResultantPSO
