System.DirectoryServices.AccountManagement: Change existing password

  • Thread starter Thread starter MarkusJ_NZ
  • Start date Start date
M

MarkusJ_NZ

Hi, I am using the new System.DirectoryServices.AccountManagement
class of .NET 3.5 to do some user maintenance work via an ASP.NET
webform.

My question is how to I reset a users password if they have forgotten
their password?

The only method I have found is the ChangePassword() method which
needs the old password.

I was hoping that I could authenticate as a domain admin, create a new
instance of the user who's password I want to reset.

e.g.

PrincipalContext domainContext = new PrincipalContext
(ContextType.Domain);
UserPrincipal user = UserPrincipal.FindByIdentity(domainContext,
"joeBloggs");
user.ChangePassword("newPassword");
user.Save();

Unfortunately, the the ChangePassword() methods accepts two parameters
the old and new passwords..

So, how can I programatically reset a users password if I do not know
the old password?

Thanks
Markus
 
Back
Top