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

标签 c# active-directory

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

相关文章:

c# - 如何隐藏单个 PivotItem 的可见性

c# - 如何为调用基对象中的基方法的方法编写单元测试

java - 尝试通过LSC(Ldap同步连接器)使Active Directory与openLDAP同步

c# - 小 cucumber 功能无法将任何方法与步骤匹配

c# - 使用 C# 将 XML 转换为 BSON

testing - 如何使用 ADAM 运行单元测试?

c# - 在运行时替换 web.config appsettings 中的值(用于 Active Directory 身份验证)

php - 创建用户,但使用 PHP 检查 Active Directory 中是否存在

node.js - 使用 Active Directory 进行身份验证/SSO 的外部 Rails/Node 应用程序

c# - MVC 中的 ViewModel 是如何工作的