我已经写了一些code,但没有工作,首先抛出异常发生操作错误。 code --->
I've written some code but not works it throws Exception "An operations error occurred." code --->
DirectoryEntry dirEntry = new DirectoryEntry("LDAP path", "admin-username", "admin-password");
dirEntry.Properties["member"].Remove("username-delete");
dirEntry.CommitChanges();
dirEntry.Close();
给我一些想法,以摆脱这种东西..
give me some ideas to get out of this things..
如果你在.NET 3.5及以上,你应该看看 System.DirectoryServices.AccountManagement
(S.DS.AM)命名空间。阅读所有关于它的:
If you're on .NET 3.5 and up, you should check out the System.DirectoryServices.AccountManagement
(S.DS.AM) namespace. Read all about it here:
基本上,你可以定义域范围内,并很容易地找到在AD用户和/或组:
Basically, you can define a domain context and easily find users and/or groups in AD:
// set up domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find the user you want to delete
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName");
if(user != null)
{
user.Delete();
}
新S.DS.AM使得它可以很容易地玩弄用户和组AD!
The new S.DS.AM makes it really easy to play around with users and groups in AD!
上一篇:ActionScript中的Event.ENTER_FRAME事件的JavaScript的版本?版本、事件、Event、ActionScript
下一篇:PrincipalContext.ValidateCredentials与使用NetBIOS名称受信任域慢名称、PrincipalContext、ValidateCredentials、NetBIOS