2010-05-14 94 views

回答

4

试试下面的代码:

$dn = "uid=".$username.",dc=example,dc=com"; 
$newPassword = ...; 
$newEntry = array('userpassword' => "{MD5}".base64_encode(pack("H*",md5($newPassword)))); 

if(ldap_mod_replace($ldapConnection, $dn, $newEntry)) 
    print "<p>succeded</p>"; 
else 
    print "<p>failed</p>"; 

参见:

http://php.net/manual/en/function.ldap-mod-replace.php

http://logout.sh/computers/ldap/

+0

是否总是以同样的方式来解密密码? – FrediWeber 2010-05-14 17:07:22

+0

我不确定我明白你在问什么。 – 2010-05-14 17:33:12

+0

对不起,我的意思是加密密码。你用md5加密,然后用base64加密。 – FrediWeber 2010-05-14 17:42:07