RoleProvider Property

ServiceAuthorizationBehavior.RoleProvider Property


Gets or sets a custom role provider.

Namespace:   System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public RoleProvider RoleProvider { get; set; }

Property Value

Type: System.Web.Security.RoleProvider

A custom role provider.

Exception Condition

Behavior is read-only.

The returned RoleProvider object is an implementation of a custom role provider.

The following code shows how to get this property.

public class MyServiceAuthorizationManager : ServiceAuthorizationManager
    protected override bool CheckAccessCore(OperationContext operationContext)
        // Extract the action URI from the OperationContext. Match this against the claims
        // in the AuthorizationContext.
        string action = operationContext.RequestContext.RequestMessage.Headers.Action;
        Console.WriteLine("action: {0}", action);

        // Iterate through the various claim sets in the AuthorizationContext.
        foreach (ClaimSet cs in operationContext.ServiceSecurityContext.AuthorizationContext.ClaimSets)
            // Examine only those claim sets issued by System.
            if (cs.Issuer == ClaimSet.System)
                // Iterate through claims of type "".
                foreach (Claim c in cs.FindClaims("", Rights.PossessProperty))
                    // Write the claim resource to the console.
                    Console.WriteLine("resource: {0}", c.Resource.ToString());

                    // If the claim resource matches the action URI, then return true to allow access.
                    if (action == c.Resource.ToString())
                        return true;

        // If this point is reached, return false to deny access.
        return false;

.NET Framework
Available since 3.0
Return to top
© 2016 Microsoft