Wednesday, June 13, 2018

Help with changing AD password through .NET

Hi, I'm working on a small application for my work place to allow users to change their AD account password despite being logged in with a smart card on the client (or smart card login through a Citrix thin client). It work when the user logs in locally with usernam,e and password, but not via smart card. Does anyone have any experience with this?

Here's the meat of my code for reference:

using (PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, "XXXXXXXX")) if (principalContext.ValidateCredentials(Username.Text, Password.Password)) { using (UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext, Username.Text)) { try { userPrincipal.ChangePassword(Password.Password, NewPassword1.Password); } catch (PasswordException pe) { MessageBox.Show(pe.Message); return; } userPrincipal.Save(); MessageBox.Show("Your password has been changed"); this.Close(); } } else MessageBox.Show("You entered the wrong password"); 
Help with changing AD password through .NET Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team