How can I change an Active Directory user password using Directory Services without knowing old password?
+2
A:
You are probably searching the SetPassword
method, which you should invoke on a DirectoryEntry
object.
Check the "Reset a User's Password" example here: Howto: (Almost) Everything In Active Directory via C#.
EDIT:
If you are having problems with the directory entry being null, you are probably passing a wrong path. The path should be something like this:
DirectoryEntry entry = new DirectoryEntry("LDAP://CN=johndoe,CN=Users,DC=acme,DC=com");
Paolo Tedesco
2010-09-29 05:39:48
@Paolo, i used that method but its not working.When i got the search result,it shows null while debugging.But the user is there in AD
Abhimanyu
2010-09-29 05:47:08
@Abhimanyu: The solution by Paolo should be correct. Can you explain what did you mean by "it shows null", what is null when you were debugging? Some code on what you are doing now would help.
Amry
2010-09-29 06:09:00
@Amry: After executing this line of code(DirectoryEntry uEntry = new DirectoryEntry(userDn);), i am getting errors in uEntry properties and UserName is shown as null.
Abhimanyu
2010-09-29 06:30:58