WIFまたはADFSには、ユーザーパスワードを変更するための特別なものはありません。System.DirectoryServices
名前空間で提供される標準のAD機能を使用する必要があります。
ADでパスワードを変更するためのサンプルコードは次のとおりです。
internal UserPrincipal GetUser(string userName)
{
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, "YourADController",
"YourADContainer",
"ADAdminUser", "ADAdminPassword");
UserPrincipal user = UserPrincipal.FindByIdentity(principalContext, userName);
return user;
}
internal void ResetPassword(string userName, string newPassword)
{
try
{
//
// Update normal AD attributes
//
UserPrincipal user = GetUser(userName);
user.SetPassword(newPassword);
}
catch (PasswordException)
{
throw new Exception("Password does not meet complexity requirements");
}
}
internal void SetPassword(string userName, string oldPassword, string newPassword)
{
try
{
//
// Update normal AD attributes
//
UserPrincipal user = GetUser(userName);
user.ChangePassword(oldPassword, newPassword);
}
catch (PasswordException)
{
throw new Exception("Password does not meet complexity requirements");
}
}