gpt4 book ai didi

c# - 将 AD 用户从一个 OU 移动到另一个 OU

转载 作者:行者123 更新时间:2023-11-30 14:50:47 25 4
gpt4 key购买 nike

我想使用 C# 将 Active Directory 用户从一个组织单位移动到另一个组织单位。

我已经引用了以下链接

  1. http://forums.asp.net/t/932664.aspx?Moving+an+AD+user+from+an+OU+to+another+OU
  2. http://www.nullskull.com/q/10279930/to-move-a-user-from-one-ou-to-another-ou.aspx

尝试了下面的代码,但是它抛出了错误

DirectoryEntry eLocation = new DirectoryEntry("LDAP://CN=Test User,OU=Users,OU=Development,DC=domain,DC=com");
DirectoryEntry nLocation = new DirectoryEntry("LDAP://OU=Users,OU=QC,DC=domain,DC=com");
eLocation.MoveTo(nLocation);

上面的代码抛出以下错误

A referral was returned from the server.
Error code: -2147016661
Extended Error Message 0000202B: RefErr: DSID-0310082F, data 0, 1 access points
ref 1: 'domain.com'

最佳答案

我已经按如下方式传递了用户凭据,效果非常好。

DirectoryEntry eLocation = new DirectoryEntry("LDAP://CN=Test User,OU=Users,OU=Development,DC=domain,DC=com", "domain\admin", "password");
DirectoryEntry nLocation = new DirectoryEntry("LDAP://OU=Users,OU=QC,DC=domain,DC=com", "domain\admin", "password");
eLocation.MoveTo(nLocation);
nLocation.Close();
eLocation.Close();

关于c# - 将 AD 用户从一个 OU 移动到另一个 OU,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35909780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com