2011-08-31 326 views
2

要在Active Directory中检查用户是否存在,哪个更适合使用.Net库?验证Active Directory用户

System.Web.Security.ActiveDirectoryMembershipProvider 

System.DirectoryServices 

我使用的System.DirectoryServices,我觉得它是用一个确切。我确实看到here中提供了类似的功能。

请指教。

回答

2

由于您使用的是.NET 4.0,因此您应该查看System.DirectoryServices.AccountManagement(S.DS.AM)命名空间。在这里阅读全部内容:

基本上,你可以定义域范围内,并可以轻松地查找用户和/或组AD:

// set up domain context 
PrincipalContext ctx = new PrincipalContext(ContextType.Domain); 

// find a user 
UserPrincipal user = UserPrincipal.FindByIdentity(ctx, "SomeUserName"); 

if(user != null) 
{ 
    // do something here....  
} 

的新的S.DS.AM可以很容易地与AD中的用户和群组玩耍!

+0

是的,它是正确的。我的问题是我可以使用System.Web.Security.ActiveDirectoryMembershipProvider用于类似的目的吗? – Roshe

+1

@Nilaa:这是ASP.NET成员资格提供程序 - 需要单独且正确地配置,不确定是否可以在没有安装所有设置的情况下使用它。我不会使用它 - 除非你已经使用ASP.NET会员资料.... –

相关问题