簡體   English   中英

將AD用戶從一個OU移到另一個OU

[英]Moving an AD user from an OU to another OU

我想使用C#將活動目錄用戶從一個組織單位移動到另一個組織單位。

我在下面提到了鏈接

  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();

您不需要任何憑據即可通過以下操作

DirectoryEntry oDE= new DirectoryEntry(LDAP://" + "CN="xxx OU=xxxx,DC=xxxxxxx,DC=xxx");
DirectoryEntry de = new DirectoryEntry("LDAP://"+ "OU=xxxx,DC=xxxxxxx,DC=xxx");
oDE.MoveTo(de);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM