验证Active Directory用户

时间:2011-08-31 10:54:12

标签: c#-4.0 active-directory

要检查用户在Active Directory中是否存在,哪一个是更好的.Net库?

System.Web.Security.ActiveDirectoryMembershipProvider 

System.DirectoryServices

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

请告知。

1 个答案:

答案 0 :(得分: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中的用户和群组一起玩!

相关问题