System.DirectoryServices.Protocol移动用户问题

发布于 2024-12-04 04:50:37 字数 170 浏览 1 评论 0原文

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

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

谢谢,

卡尔-

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.

Can anyone please post some code samples and or links to code samples/tutorials for these two operation in S.DS.P?

Thanks,

Cal-

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼睛会笑 2024-12-11 04:50:37

下面是来自一个非常好的 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();

Below is an example from a very good source of c# Active Directory examples at Howto: (Almost) Everything In Active Directory via 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();
左岸枫 2024-12-11 04:50:37

您可以查看System.DirectoryServices.Protocols简介 在里面你会找到下载的快捷方式MS_Sample_Pack_For_SDSP.EXE 这是一个包含许多示例的解决方案:

MoveRenameObject server_or_domain_name originalDn newParentDn objectName 

可能对您有用。

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 :

MoveRenameObject server_or_domain_name originalDn newParentDn objectName 

may be useful for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文