简体   繁体   English

System.DirectoryServices.Protocol移动用户问题

[英]System.DirectoryServices.Protocol move user question

I want to move a user from one OU to a Different OU, and also to update a few attributes using System.DirectoryServices.Protocol, but I'm having a very hard time finding any code samples for anything except searching. 我想将用户从一个OU移动到另一个OU,并使用System.DirectoryServices.Protocol更新一些属性,但我很难找到除搜索之外的任何代码示例。

Can anyone please post some code samples and or links to code samples/tutorials for these two operation in S.DS.P? 任何人都可以在S.DS.P中发布一些代码示例和/或链接到代码示例/教程中的这两个操作吗?

Thanks, 谢谢,

Cal- 校准 -

Below is an example from a very good source of c# Active Directory examples at Howto: (Almost) Everything In Active Directory via C# 下面是一个来自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();

You can have a look to the article called Introduction to System.DirectoryServices.Protocols inside you'll find a shortcut to download MS_Sample_Pack_For_SDSP.EXE which is a solution with many examples : 你可以看一下名为Introduction to System.DirectoryServices.Protocols的文章你会找到一个下载MS_Sample_Pack_For_SDSP.EXE的快捷方式,这是一个有很多例子的解决方案:

MoveRenameObject server_or_domain_name originalDn newParentDn objectName 

may be useful for you. 可能对你有用。

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

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