我想要將用戶從一個OU移動到另一個OU,並使用System.DirectoryServices.Protocol更新一些屬性,但我很難找到任何除搜索外的任何其他代碼示例。System.DirectoryServices.Protocol移動用戶問題
任何人都可以發佈一些代碼示例和或鏈接到代碼示例/教程這兩個操作S.DS.P?
感謝,
校準 -
我想要將用戶從一個OU移動到另一個OU,並使用System.DirectoryServices.Protocol更新一些屬性,但我很難找到任何除搜索外的任何其他代碼示例。System.DirectoryServices.Protocol移動用戶問題
任何人都可以發佈一些代碼示例和或鏈接到代碼示例/教程這兩個操作S.DS.P?
感謝,
校準 -
一個例子你可以看看文章叫Introduction to System.DirectoryServices.Protocols內你會發現一個快捷方式下載MS_Sample_Pack_For_SDSP.EXE這是一個很多例子的解決方案:
MoveRenameObject server_or_domain_name originalDn newParentDn objectName
可能對您有用。
下面是一個很好的C#的Active Directory實例源在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();
是的,如果您使用System.DirectoryServices,這是一個很好的參考,但如果您使用的是System.DirectoryServices.Protocol,則不是。 S.DS =更容易,S.DS.P =更快唉我使用S.DS.P ... –