[Samba] Changing active directory user password via LDAP

Tadas tadas at ring.lt
Fri May 2 03:34:05 MDT 2014


Thanks everyone for a support.

Here's a working shell script:

#!/bin/bash
password=test
password='"'$password'"'
u16pass=`printf $password|iconv -f ascii -t UTF16LE|base64`
echo "dn: CN=John Smith,cn=Users,DC=domain,DC=com" >ldap.ldif
echo "changetype: modify" >>ldap.ldif
echo "replace: unicodePwd" >>ldap.ldif
echo "unicodePwd:: $u16pass" >>ldap.ldif
ldapmodify -v -c -a -f ldap.ldif -H ldaps://server.domain.com -D
administrator at domain.com -W
rm ldap.ldif
-- 



On Fri, 2014-05-02 at 05:53 +1000, Dewayne Geraghty wrote:
> I think its all here, in functions.php:
>       $newPassword = "\"" . $newPassword . "\"";
>       $len = strlen($newPassword);
>       $newPassw = "";
>       for ($i = 0; $i < $len; $i++) {
>         $newPassw .= "{$newPassword{$i}}\000";
>       }
>       $newPassword = $newPassw;
>       $userdata["unicodePwd"] = $newPassword;
>       $result = ldap_mod_replace($ldap_connection, $userDn , $userdata);
> but how to do this in a sh script is a challenge.  Please share if you
> can work it out, as I have the same need.
> 
> Regards, Dewayne.
> Sydney, Australia.



More information about the samba mailing list