Export (0) Print
Expand All

ClientRoleProvider Class

Gets role information for Windows-based applications from an Microsoft Ajax roles service.

System.Object
  System.Configuration.Provider.ProviderBase
    System.Web.Security.RoleProvider
      System.Web.ClientServices.Providers.ClientRoleProvider

Namespace:  System.Web.ClientServices.Providers
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

type ClientRoleProvider =  
    class 
        inherit RoleProvider 
    end

The ClientRoleProvider type exposes the following members.

  NameDescription
Public methodClientRoleProviderInitializes a new instance of the ClientRoleProvider class.
Top

  NameDescription
Public propertyApplicationNameThis property is not used by this class. (Overrides RoleProvider.ApplicationName.)
Public propertyDescriptionGets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs). (Inherited from ProviderBase.)
Public propertyNameGets the friendly name used to refer to the provider during configuration. (Inherited from ProviderBase.)
Public propertyServiceUriGets or sets the URI of the role service.
Top

  NameDescription
Public methodAddUsersToRolesThis method is not used by this class. (Overrides RoleProvider.AddUsersToRoles(String[], String[]).)
Public methodCreateRoleThis method is not used by this class. (Overrides RoleProvider.CreateRole(String).)
Public methodDeleteRoleThis method is not used by this class. (Overrides RoleProvider.DeleteRole(String, Boolean).)
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodFindUsersInRoleThis method is not used by this class. (Overrides RoleProvider.FindUsersInRole(String, String).)
Public methodGetAllRolesThis method is not used by this class. (Overrides RoleProvider.GetAllRoles().)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetRolesForUserGets the names of the roles that the specified user belongs to. (Overrides RoleProvider.GetRolesForUser(String).)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetUsersInRoleThis method is not used by this class. (Overrides RoleProvider.GetUsersInRole(String).)
Public methodInitializeInitializes the provider. (Overrides ProviderBase.Initialize(String, NameValueCollection).)
Public methodIsUserInRoleGets a value indicating whether the specified user is in the specified role. (Overrides RoleProvider.IsUserInRole(String, String).)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRemoveUsersFromRolesThis method is not used by this class. (Overrides RoleProvider.RemoveUsersFromRoles(String[], String[]).)
Public methodResetCacheClears the cached role information and resets the cache time-out period.
Public methodRoleExistsThis method is not used by this class. (Overrides RoleProvider.RoleExists(String).)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

You can use client application services to retrieve role information from an existing roles service by configuring your application to use the ClientRoleProvider class. After configuration, you can determine whether an authenticated user is in a particular role by calling the IsInRole method of the IPrincipal returned by the static Thread.CurrentPrincipal property. For applications configured to use client application services, this property returns a ClientRolePrincipal. Because this class implements the IPrincipal interface, you do not need to reference it explicitly. The ClientRolePrincipal.IsInRole method internally calls the ClientRoleProvider.IsUserInRole method.

The ClientRoleProvider class is a read-only role membership provider that retrieves role information for authenticated users from the roles service indicated by the ServiceUri property. The value of the ServiceUri property is typically retrieved from the application configuration file along with other configuration values. For more information, see How to: Configure Client Application Services.

You can retrieve the current ClientRoleProvider instance through the static Roles.Provider property.

The ClientRoleProvider class supports only the GetRolesForUser and IsUserInRole methods of the RoleProvider abstract class. When you call one of these methods for a particular user, the service provider first checks the local data cache for role information. If the cache does not contain any role information or the cache has expired, the service provider retrieves the role information from the roles service and adds it to the cache.

You can specify the time-out period for the roles cache when you configure client application services. To force the GetRolesForUser method to retrieve role data from the service instead of the local cache, call the ResetCache method first.

You cannot use the ClientRoleProvider class to create or delete roles, or to modify the role membership of users. To create or modify role information, you must change the configuration of the role service on the server.

The following example code demonstrates how to use this property to programmatically set the roles service location.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft