Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get password of active directory by ldap in php?

I have problem about password in Active Directory. I want to get password from "username" of user I tried function "ldap_search", but I do not find correctly attribute for password I tried as: password, userpassword, userPassword, unicodePwd, unicodepwd, but they are not correct.

I look forward to helping of everyone Thanks for all :D trankinhly

like image 285
trankinhly Avatar asked Feb 09 '11 08:02

trankinhly


1 Answers

Passwords in Active Directory are not retrievable. Nor are they in most directories. (eDirectory has a password policy, that if you bind as the specified user, then you can retrieve passwords via LDAP extensions)

Some directories might let you recover the hashed versions, but that is not that great either.

To be cross platform, it is better to try and bind with the values provided and either succeed or fail. Additionally, LDAP says a bind with a blank password is actually an anonymous bind, which will probably succeed, so you need to filter for that case.

Once bound as the user, you could look at their group memberships (since usually they can see their own) or look at some other attribute, which if they can read it, means they have some level of rights. (I.e. Implement authorization as well as authentication).

like image 84
geoffc Avatar answered Sep 19 '22 12:09

geoffc