用户登录
用户注册

分享至

查询活动目录以获取 .NET 中的用户角色

  • 作者: 水杯仙子
  • 来源: 51数据库
  • 2022-10-21

问题描述

我一直在使用 Linq to Active Directory,但我发现很难获得用户所属的所有角色.我可以检索它们的直接组的列表,但它不是递归的.

I have been using Linq to Active Directory a bit but I am finding it difficult to get a list of all roles of which the user is a member. I can retrieve a list of their immediate groups but it isn't recursive.

我尝试查询 AD 目录的原因是为了解决内置的角色管理器 AspNetWindowsTokenRoleProvider,除非用户名与当前的 Windows 标识匹配,否则它不会让您调用 Roles.GetRolesForUser(username).

The reason I am trying to query AD directory is to work around the built-in Role Manager AspNetWindowsTokenRoleProvider which won't let you call Roles.GetRolesForUser(username) unless the username matches the current Windows Identity.

推荐答案

你看过这个?

软件
前端设计
程序设计
Java相关