繁体   English   中英

System.DirectoryServices.Protocol移动用户问题

[英]System.DirectoryServices.Protocol move user question

我想将用户从一个OU移动到另一个OU,并使用System.DirectoryServices.Protocol更新一些属性,但我很难找到除搜索之外的任何代码示例。

任何人都可以在S.DS.P中发布一些代码示例和/或链接到代码示例/教程中的这两个操作吗?

谢谢,

校准 -

下面是一个来自Howto的一个非常好的c#Active Directory示例源的示例:(几乎)通过C#在Active Directory中的所有内容

//Move an object from one ou to another
DirectoryEntry eLocation = new DirectoryEntry("LDAP://" + objectLocation);
DirectoryEntry nLocation = new DirectoryEntry("LDAP://" + newLocation);
string newName = eLocation.Name;
eLocation.MoveTo(nLocation, newName);
nLocation.Close();
eLocation.Close();

//Modify an attribute of a user object

DirectoryEntry user = new DirectoryEntry(userDn);
int val = (int)user.Properties["userAccountControl"].Value;
user.Properties["userAccountControl"].Value = val & ~0x2; 
user.CommitChanges();
user.Close();

你可以看一下名为Introduction to System.DirectoryServices.Protocols的文章你会找到一个下载MS_Sample_Pack_For_SDSP.EXE的快捷方式,这是一个有很多例子的解决方案:

MoveRenameObject server_or_domain_name originalDn newParentDn objectName 

可能对你有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM