Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RoleService Class

Enables access to the ASP.NET role provider as a WCF Web service.

System.Object
  System.Web.ApplicationServices.RoleService

Namespace:  System.Web.ApplicationServices
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)
[ServiceContractAttribute(Namespace = "http://asp.net/ApplicationServices/v200")]
[AspNetCompatibilityRequirementsAttribute(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehaviorAttribute(Namespace = "http://asp.net/ApplicationServices/v200", 
	InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)]
public class RoleService

The RoleService type exposes the following members.

  NameDescription
Public methodRoleServiceInitializes a new instance of the RoleService class.
Top
  NameDescription
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 methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetRolesForCurrentUserReturns all the roles for the logged-in user.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIsCurrentUserInRoleDetermines whether the logged-in user belongs to the specified role.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Public eventStatic memberSelectingProviderOccurs when a RoleService instance determines which role provider to use for checking the user's roles.
Top

The RoleService object enables you to read a user's roles through a Windows Communication Foundation (WCF) service. To use the role service, you must enable the role service on a Web server and then connect a WCF-compatible client application to the Web service. For information about how to configure the role service, see How to: Enable the WCF Role Service.

The user must be authenticated to read the user's roles. The role service works with any kind of ASP.NET authentication. For information about how to log users in through a WCF service, see Windows Communication Foundation Authentication Service Overview.

The RoleService class exposes two methods that should be accessed only through a WCF service: the GetRolesForCurrentUser method and the IsCurrentUserInRole method. The GetRolesForCurrentUser method returns all the roles for the logged-in user. The IsCurrentUserInRole method determines whether the user is in a specified role.

The RoleService object raises the SelectingProvider event. You create an event handler for the SelectingProvider event to select which role provider to use at run time.

For an example of how to use the WCF role service from a console application, see Walkthrough: Using ASP.NET Application Services.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5

Windows Phone 8.1, Windows Phone 8, 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.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.