WindowsTokenRoleProvider 类

定义

通过 Windows 组成员资格获取 ASP.NET 应用程序的角色信息。

public ref class WindowsTokenRoleProvider : System::Web::Security::RoleProvider
public class WindowsTokenRoleProvider : System.Web.Security.RoleProvider
type WindowsTokenRoleProvider = class
    inherit RoleProvider
Public Class WindowsTokenRoleProvider
Inherits RoleProvider
继承
WindowsTokenRoleProvider

示例

以下示例显示了 ASP.NET 应用程序的Web.config文件。 它指定应用程序同时使用Windows 身份验证和WindowsTokenRoleProvider类检索Windows用户的角色信息。 该 authorization 元素指定仅允许在 BUILTIN\Administrators 组中访问应用程序的用户。

<configuration>
  <system.web>
    <authentication mode="Windows" />

    <authorization>
      <allow roles="BUILTIN\Administrators" />
      <deny users="*" />
    </authorization>

    <roleManager defaultProvider="WindowsProvider"
      enabled="true"
      cacheRolesInCookie="false">
      <providers>
        <add
          name="WindowsProvider"
          type="System.Web.Security.WindowsTokenRoleProvider" />
      </providers>
    </roleManager>

  </system.web>
</configuration>

注解

WindowsTokenRoleProvider类是一个只读角色成员身份提供程序,可基于Windows安全组检索Windows用户的角色信息。 对于 ASP.NET 使用Windows 身份验证模式的应用程序,IIS 身份验证设置禁用匿名身份验证,这最有用。 可以根据特定Windows组中用户的成员身份配置 ASP.NET 应用程序以允许或拒绝访问。

不能使用该WindowsTokenRoleProvider类创建或删除角色,或修改基于Windows组成员身份的角色的成员身份。 此功能由Windows操作系统管理。 该WindowsTokenRoleProvider类仅IsUserInRole支持抽象类的RoleProviderGetRolesForUser方法。

构造函数

WindowsTokenRoleProvider()

创建 WindowsTokenRoleProvider 类的实例。

属性

ApplicationName

获取或设置应用程序的名称。

Description

获取一条简短的易懂描述,它适合在管理工具或其他用户界面 (UI) 中显示。

(继承自 ProviderBase)
Name

获得一个友好名称,用于在配置过程中引用提供程序。

(继承自 ProviderBase)

方法

AddUsersToRoles(String[], String[])

Windows 标记角色提供程序不支持此方法。

CreateRole(String)

Windows 标记角色提供程序不支持此方法。

DeleteRole(String, Boolean)

Windows 标记角色提供程序不支持此方法。

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
FindUsersInRole(String, String)

Windows 标记角色提供程序不支持此方法。

GetAllRoles()

Windows 标记角色提供程序不支持此方法。

GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetRolesForUser(String)

获取用户所属的 Windows 组的列表。

GetType()

获取当前实例的 Type

(继承自 Object)
GetUsersInRole(String)

Windows 标记角色提供程序不支持此方法。

Initialize(String, NameValueCollection)

利用在 ASP.NET 应用程序的配置文件中指定的属性值初始化 Windows 标记角色提供程序。 此方法不能直接在代码中使用。

IsUserInRole(String, String)

获取一个值,它指示指定的用户是否属于指定的 Windows 组。

IsUserInRole(String, WindowsBuiltInRole)

获取一个值,它指示指定的用户是否扮演指定的内置 Windows 角色。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
RemoveUsersFromRoles(String[], String[])

Windows 标记角色提供程序不支持此方法。

RoleExists(String)

Windows 标记角色提供程序不支持此方法。

ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅