我想将一个计算机对象移动到另一个 OU 我连接到另一个域并且我总是得到一个 ComException 类型的异常"A referral was returned from the server"
并且对象永远不会移动!
try
{
//I get the exception here
computerObject.MoveTo(new DirectoryEntry("LDAP://OU=someOU,OU=parentOU,DC=test,DC=com"));
computerObject.CommitChanges();
}
catch (InvalidOperationException inOp)
{
//log
}
catch (COMException comEx)
{
//log
}
//joinPath.Close();
finally
{
computerObject.Close();
}
为了进行故障排除,我稍微更改了代码,但它再次不起作用。
computerObject.MoveTo(new DirectoryEntry("LDAP://OU=someOU,OU=parentOU,DC=test,DC=com"),
"admin@test.com","somepassowrd",AuthenticationTypes.Secure));
新异常的类型为 ComException"Logon failure: unknown user name or bad password."
我检查了活动目录中是否存在 OU 并且我有足够的权限。
我在这里关注了 Microsoft 文档https://msdn.microsoft.com/en-us/library/ms180856(v=vs.90).aspx 和许多 stackoverflow 问题。
更新:我在一个域中运行我的应用程序并在另一个域中进行更改,这可能是问题的原因