Sai*_*han 5 .net helper active-directory
是否有某个Active Directory帮助程序类可用?在重新发明轮子之前检查一下.
我需要
在AD中验证用户.
获得hhis /她的成员角色.
谢谢
tva*_*son 10
在.NET 3.5中,您希望查看System.DirectoryServices.AccountManagement.对于早期版本,System.DirectoryServices版本具有您所需要的功能,但它需要更多工作.
using (var context = new PrincipalContext( ContextType.Domain ))
{
var valid = context.ValidateCredentials( username, password );
using (var user = UserPrincipal.FindByIdentity( context,
IdentityType.SamAccountName,
username ))
{
var groups = user.GetAuthorizationGroups();
}
}
Run Code Online (Sandbox Code Playgroud)