Active Directory の使用と OU の移動/名前変更で問題が発生しています。これは、2 つのドメイン コントローラー間でレプリケートする場合にのみ発生します。例外は次のとおりです。
System.ServiceModel.FaultException: サーバーにそのようなオブジェクトはありません。(HRESULT からの例外: 0x80072030)
Active Directory で OU を移動して名前を変更しようとすると、このエラー メッセージのバリエーションが表示されます。問題のコードは次のとおりです。
PrincipalContext context = GetPrincipalContext();
using (UserPrincipal principal = UserPrincipal.FindByIdentity(context, IdentityType.Guid, id.ToString()))
{
if (principal == null)
{
throw new InvalidOperationException();
}
string oldEmail = principal.EmailAddress;
principal.EmailAddress = newEmail;
principal.Save();
DirectoryEntry entry = principal.GetUnderlyingObject() as DirectoryEntry;
DirectoryEntry targetDirectoryEntry = null;
string target = null;
// Access the underlying DirectoryEntry to rename it:
try
{
if (entry == null)
{
throw new InvalidOperationException();
}
entry.RefreshCache();
entry.Rename(string.Format("CN={0}", newEmail));
// Move the DirectoryEntry to the correct location.
target = BuildOrganizationalUnitName(newEmail);
targetDirectoryEntry = FindDirectoryEntry(target);
if (targetDirectoryEntry == null)
{
throw new InvalidOperationException();
}
entry.MoveTo(targetDirectoryEntry);
entry.CommitChanges();
}
catch (Exception e)
{
// do some logging
}
finally
{
if (entry != null)
{
entry.Dispose();
}
if (targetDirectoryEntry != null)
{
targetDirectoryEntry.Dispose();
}
}
}
だから私は2つの質問があります:
- OU を移動して名前を変更しようとしている上記のコードに何か問題がありますか?
- そうでない場合、移動/名前変更後に 2 つの DC の同期を維持する方法はありますか?