[Samba] ldap_modify change password [SOLVED]

Shem Pasamba shemgp at aiias.edu
Tue Feb 18 22:54:58 MST 2014


On 2/17/2014 4:15 PM, Shem Pasamba wrote:
>>> But when I try to login to test1 using winbind in another machine it 
>>> says Wrong password.  Is there anything wrong that I'm doing? Thanks 
>>> for your help.
>>>
>> When I change the password in Windows, the log outputs something 
>> slightly different:
>>
>> [2014/02/17 16:01:36.934743, 10, pid=30000, effective(0, 0), real(0, 
>> 0), class=ldb] ../lib/ldb-samba/ldb_wrap.c:71(ldb_wrap_debug)
>>   ldb: start ldb transaction (nesting: 1)
>> [2014/02/17 16:01:36.934899, 10, pid=30000, effective(0, 0), real(0, 
>> 0), class=ldb] ../lib/ldb-samba/ldb_wrap.c:71(ldb_wrap_debug)
>>   ldb: ldb_trace_request: MODIFY
>>   dn: CN=test1,OU=aiiasusers,DC=aiias,DC=edu
>>   changetype: modify
>>   replace: clearTextPassword
>>   clearTextPassword:: SABhAHAAcAB5ADIAMAAxADQA
>>   -
>>
>>
>>    control: 1.3.6.1.4.1.7165.4.3.8  crit:1  data:no
> Did I mention? When I change the password using the Windows tool, the 
> login works (winbind).
>
Found the solution: I used a different function to change the password. 
Also I used unicodePwd instead of clearTextPassword. Hope this helps 
someone. Here's my function.

function UpdateLdapPassword($username, $newpassword)

{

// Change password

// Can be called only after LdapConnect

// Use globals $rdn and $ds (connection to ldap)

         global $ds;

         global $rdn;

         ldap_bind ($ds, 'cn=administrator,cn=Users,dc=aiias,dc=edu', 'secret');

         $newPassword = $newpassword;

         $newPassword = "\"" . $newPassword . "\"";

         $len = strlen($newPassword);

         $newPassw='';

         for ($i = 0; $i < $len; $i++)

                 $newPassw .= "{$newPassword{$i}}\000";

         $newPassword = $newPassw;

         $userdata["unicodePwd"] = $newPassword;

         $bReturn = ldap_mod_replace($ds, $rdn, $userdata);

         Debug ("msg:'".ldap_error($ds)."'<br><br>");

         return $bReturn;

}

> Thanks again!
>
> Shem Pasamba



More information about the samba mailing list