Rediger

Del via


RoleService Class

Definition

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

public ref class RoleService
[System.ServiceModel.Activation.AspNetCompatibilityRequirements(RequirementsMode=System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Required)]
[System.ServiceModel.ServiceBehavior(ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Multiple, InstanceContextMode=System.ServiceModel.InstanceContextMode.Single, Namespace="http://asp.net/ApplicationServices/v200")]
[System.ServiceModel.ServiceContract(Namespace="http://asp.net/ApplicationServices/v200")]
public class RoleService
[<System.ServiceModel.Activation.AspNetCompatibilityRequirements(RequirementsMode=System.ServiceModel.Activation.AspNetCompatibilityRequirementsMode.Required)>]
[<System.ServiceModel.ServiceBehavior(ConcurrencyMode=System.ServiceModel.ConcurrencyMode.Multiple, InstanceContextMode=System.ServiceModel.InstanceContextMode.Single, Namespace="http://asp.net/ApplicationServices/v200")>]
[<System.ServiceModel.ServiceContract(Namespace="http://asp.net/ApplicationServices/v200")>]
type RoleService = class
Public Class RoleService
Inheritance
RoleService
Attributes

Remarks

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.

Constructors

RoleService()

Initializes a new instance of the RoleService class.

Methods

Equals(Object)

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

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetRolesForCurrentUser()

Returns all the roles for the logged-in user.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
IsCurrentUserInRole(String)

Determines whether the logged-in user belongs to the specified role.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Events

SelectingProvider

Occurs when a RoleService instance determines which role provider to use for checking the user's roles.

Applies to

See also