String domain = configurationProvider.Configuration.DomainName; ContextType contextType = ContextType.Machine; public int newPassword(string username, string oldPassword, string newPassword) using (PrincipalContext pc = new PrincipalContext(contextType, domain)) { using (UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(pc, username)) { if (userPrincipal != null) { try { userPrincipal.ChangePassword(oldPassword, newPassword); } catch (PasswordException pe) { return null; } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)