samba PDC sambaLogonTime update

Samba doesnt update sambaLogonTime in LDAP when a user login
in order to have it set , one can run a script that will do it
set up a script /root/update_sambaLogonTime.sh

#!/bin/bash
TIMESTAMP=$(date +%s)
ldapmodify -x -h localhost -D "cn=Manager,dc=example,dc=com" -y /root/pass-test <<EOF
dn: uid=$1,ou=People,dc=example,dc=com
changetype: modify
replace: sambaLogonTime
sambaLogonTime: $TIMESTAMP
EOF

now create a pass-test file by running echo with “-n” in order to remove the newline “n”
because ldapmodify doesnt not chop it

echo -n "mypassword" > /root/pass-test 

now just add a line under [netlogon] in smb.conf

root preexec = /root/update_sambaLogonTime.sh "%u"