Editare

Partajați prin


WindowsTokenRoleProvider Class

Definition

Gets role information for an ASP.NET application from Windows group membership.

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
Inheritance
WindowsTokenRoleProvider

Examples

The following example shows the Web.config file for an ASP.NET application. It specifies that the application uses both Windows authentication and the WindowsTokenRoleProvider class to retrieve role information for Windows users. The authorization element specifies that only users in the BUILTIN\Administrators group are allowed access to the application.

<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>

Remarks

The WindowsTokenRoleProvider class is a read-only role-membership provider that retrieves role information for a Windows user based on Windows security groups. It is most useful with ASP.NET applications that use Windows authentication mode where the IIS authentication settings disable anonymous authentication. You can configure ASP.NET applications to allow or deny access based on a user's membership in a particular Windows group.

You cannot use the WindowsTokenRoleProvider class to create or delete roles or modify the membership of a role that is based on Windows group membership. This functionality is managed by the Windows operating system. The WindowsTokenRoleProvider class supports only the IsUserInRole and GetRolesForUser methods of the RoleProvider abstract class.

Constructors

WindowsTokenRoleProvider()

Creates an instance of the WindowsTokenRoleProvider class.

Properties

ApplicationName

Gets or sets the name of the application.

Description

Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs).

(Inherited from ProviderBase)
Name

Gets the friendly name used to refer to the provider during configuration.

(Inherited from ProviderBase)

Methods

AddUsersToRoles(String[], String[])

This method is not supported by the Windows token role provider.

CreateRole(String)

This method is not supported by the Windows token role provider.

DeleteRole(String, Boolean)

This method is not supported by the Windows token role provider.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FindUsersInRole(String, String)

This method is not supported by the Windows token role provider.

GetAllRoles()

This method is not supported by the Windows token role provider.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetRolesForUser(String)

Gets a list of the Windows groups that a user is in.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetUsersInRole(String)

This method is not supported by the Windows token role provider.

Initialize(String, NameValueCollection)

Initializes the Windows token role provider with the property values specified in the configuration file for the ASP.NET application. This method is not intended to be used directly from your code.

IsUserInRole(String, String)

Gets a value indicating whether the specified user is in the specified Windows group.

IsUserInRole(String, WindowsBuiltInRole)

Gets a value indicating whether the specified user is in the specified built-in Windows role.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
RemoveUsersFromRoles(String[], String[])

This method is not supported by the Windows token role provider.

RoleExists(String)

This method is not supported by the Windows token role provider.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also