协议移动用户问题
本文关键字:问题 用户 移动 协议 | 更新日期: 2023-09-27 18:07:56
我想将用户从一个OU移动到另一个OU,并使用System.DirectoryServices更新一些属性。协议,但我有一个非常困难的时间找到任何代码样本,除了搜索。
谁能请张贴一些代码样本和或链接到代码样本/教程这两个操作在S.DS.P?
谢谢,
Cal -
下面是一个非常好的c#活动目录示例来源:how(几乎)Everything In Active Directory through c#
//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();
您可以查看一篇名为System.DirectoryServices.Protocols的文章,在其中您将找到下载MS_Sample_Pack_For_SDSP.EXE的快捷方式,这是一个有许多示例的解决方案:
MoveRenameObject server_or_domain_name originalDn newParentDn objectName