Resetting a LDAP user's password in PHP, without the old password, using admin user -
i trying figure out how reset ldap user password when connected user (admin user) in php password reset feature.
$this->con = ldap_connect($this->server); ldap_set_option($this->con, ldap_opt_protocol_version, 3); $user_search = ldap_search($this->con, $this->dn,"(|(uid=$user)(mail=$user))"); $this->user_get = ldap_get_entries($this->con, $user_search); $user_entry = ldap_first_entry($this->con, $user_search); $this->user_dn = ldap_get_dn($this->con, $user_entry); $this->user_id = $this->user_get[0]["uid"][0]; $entry = array(); $entry["userpassword"] = "$encoded_newpassword"; ldap_modify($this->con, $this->user_dn, $entry)
(aggregated class methods) works resetting user's password using old password, how go doing password change user (admin in case)?
i think there ldap authentication/binding not understanding. perhaps can point me in right direction.
can ldap_bind before ldap_modify allow me use user_dn , update user admin user?
not clear on how works.
openldap implementation being used.
you can call ldap_bind dn/password of admin user establish connection (admin) user.
sample php manual
// using ldap bind $ldaprdn = 'uname'; // ldap rdn or dn $ldappass = 'password'; // associated password // connect ldap server $ldapconn = ldap_connect("ldap.example.com") or die("could not connect ldap server."); if ($ldapconn) { // binding ldap server $ldapbind = ldap_bind($ldapconn, $ldaprdn, $ldappass); // verify binding if ($ldapbind) { echo "ldap bind successful..."; } else { echo "ldap bind failed..."; } }
Comments
Post a Comment