Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从Active Directory获取用户角色/组-mvc3_C#_Asp.net Mvc 3_Active Directory - Fatal编程技术网

C# 从Active Directory获取用户角色/组-mvc3

C# 从Active Directory获取用户角色/组-mvc3,c#,asp.net-mvc-3,active-directory,C#,Asp.net Mvc 3,Active Directory,我需要能够将用户active directory组与可接受组列表进行比较。这不是用于身份验证的 我知道我可以使用System.DirectoryServices,但我看到很多帖子都说使用AccountManagement,但我看到的只是.Active Directory 有人能帮我找到正确的方向吗?试试这样的方法:查看System.DirectoryServices.AccountManagement(S.DS.AM)命名空间。请在此处阅读所有相关内容: 基本上,您可以定义域上下文并在A

我需要能够将用户active directory组与可接受组列表进行比较。这不是用于身份验证的

我知道我可以使用System.DirectoryServices,但我看到很多帖子都说使用AccountManagement,但我看到的只是.Active Directory


有人能帮我找到正确的方向吗?

试试这样的方法:查看
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)
{
   PrincipalSearchResult<Principal> authgroups = user.GetAuthorizationGroups();

   // do your checking with the auth groups that the user has - against your list 
}
//设置域上下文
PrincipalContext ctx=新PrincipalContext(ContextType.Domain);
//查找用户
UserPrincipal user=UserPrincipal.FindByIdentity(ctx,“SomeUserName”);
如果(用户!=null)
{
PrincipalSearchResult authgroups=user.GetAuthorizationGroups();
//根据列表检查用户拥有的身份验证组
}
新的S.DS.AM使得在广告中与用户和群组进行互动变得非常容易