Active Directory ユーザーがパスワードを更新できるようにするための Web アプリケーションの一部として、次のコードがあります (Active Directory と gmail を同時に)。System.DirectoryServices.AccountManagement で C# を使用しています。
このコードは昨日まで機能していました
try
{
State.log.WriteLine("Connecting LDAP.");
string ldapPath = "LDAP://192.168.76.3";
DirectoryEntry directionEntry = new DirectoryEntry(ldapPath, domainName + "\\" + userName, currentPassword);
if (directionEntry != null)
{
DirectorySearcher search = new DirectorySearcher(directionEntry);
State.log.WriteLine("LDAP Connected, searching directory for SAMAccountName");
search.Filter = "(SAMAccountName=" + userName + ")";
SearchResult result = search.FindOne();
if (result != null)
{
State.log.WriteLine("Getting User Entry.");
DirectoryEntry userEntry = result.GetDirectoryEntry();
if (userEntry != null)
{
State.log.WriteLine("Setting Password");
if (force)
{
userEntry.Invoke("SetPassword", new[] { newPassword });
}
else
{
userEntry.Invoke("ChangePassword", new object[] { currentPassword, newPassword });
}
userEntry.CommitChanges();
State.log.WriteLine("Changes Committed to ActiveDirectory.");
}
else
{
State.log.WriteLine("Could not get user Entry...");
}
}
else
{
State.log.WriteLine("Search returned no results.");
}
}
else
{
State.log.WriteLine("Could not connect to LDAP with given username and passwd");
}
}
昨日から、このコードは次の行になります。
userEntry.Invoke("ChangePassword", new object[] { currentPassword, newPassword });
そして、次の例外をスローします。
[8:37:00 AM] : パスワード要件が満たされました。
[8:37:00 AM] : LDAP を接続しています。
[8:37:00 AM] : LDAP 接続、SAMAccountName のディレクトリを検索中
[8:37:01 AM] : ユーザー エントリを取得しています。
[8:37:01 AM] : パスワードの設定
[8:37:01 AM] : jason の Windows パスワードのリセットに失敗しました。
呼び出しのターゲットによって例外がスローされました。
システムは、認証要求を処理するためにドメイン コントローラに接続できません。後でもう一度やり直してください。(HRESULT からの例外: 0x800704F1)
「SetPassword」を使用した「強制」オプションは問題なく機能しますが、管理者以外のユーザーが呼び出すことができる「ChangePassword」メソッドは機能しません。