UserPrincipalを使用してActiveDirectoryにChangePassword機能を実装しようとしています。一個の以上の入力パラメータが無効である - 私はのChangePassword、System.Runtime.InteropServices.COMExceptionの例外を取得し、私のWindows 10マシン上でこれをテストしようとするとSystem.DirectoryServices.AccountManagement.UserPrincipal - ChangePasswordメソッドが例外をスローする
using System.DirectoryServices.AccountManagement;
private PrincipalContext Context { get; set; }
...
Context = new PrincipalContext(ContextType.Domain,
AdDomain,
AdRoot,
ContextOptions.SimpleBind,
AdUsername,
AdPassword)
...
public bool ChangePassword(string login, string password, string newPassword, out string message)
{
using (var foundUser = UserPrincipal.FindByIdentity(Context, IdentityType.SamAccountName, login))
{
try
{
foundUser.ChangePassword(password, newPassword);
foundUser.Save();
}
catch (Exception e)
{
message = e.Message;
return false;
}
return true;
}
}
:コードは次のようになります。
しかし、同じプロジェクトで同じコードを実行しているときに、Windows 7マシンで同じADドメインに接続すると、エラーなしで実行され、パスワードが変更されます。環境上でこの異なる動作を引き起こす原因は何か、そのエラーはどうして起こるのでしょうか?
http://stackoverflow.com/questions/33717673/system-directoryservices-accountmanagement-principalcontext-broken-after-windows こちらをご覧ください。 –
Windows 10マシンでRegisteredOwnerとRegisteredOrganizationでレジストリを変更しましたが、このエラーは解決しませんでした。 –