gpt4 book ai didi

c# - 使用 C# 在 Active Directory 中移动对象

转载 作者:太空狗 更新时间:2023-10-30 00:05:28 27 4
gpt4 key购买 nike

所以下面的代码应该在事件目录中移动一个对象。我看到这里发生了什么,但我不太明白。我所看到的只是旧位置和新位置。我不明白我实际上是如何捕获物体的。我在两个位置都有几个对象,这段代码在哪里说明要移动哪个特定对象?我看不到 LDAP + objectLocation 字符串中有对象的位置。

DirectoryEntry eLocation = new DirectoryEntry("LDAP://" + objectLocation);
DirectoryEntry nLocation = new DirectoryEntry("LDAP://" + newLocation);
string newName = eLocation.Name;
eLocation.MoveTo(nLocation, newName);
nLocation.Close();
eLocation.Close();

最佳答案

也许这个例子会更清楚:

DirectoryEntry theObjectToMove = new DirectoryEntry("LDAP://CN=jdoe,CN=Users,DC=acme,DC=com");
DirectoryEntry theNewParent = new DirectoryEntry("LDAP://OU=Something,DC=acme,DC=com");
theObjectToMove.MoveTo(theNewParent);

带有两个参数的 MoveTo 重载还为对象指定了一个新名称,我认为在您的示例中这是多余的。

关于c# - 使用 C# 在 Active Directory 中移动对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11633642/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com