Compartilhar via


AuthorizationAttribute.Authorize Method

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Determines whether the given principal object is authorized to perform a specific operation described by the given AuthorizationContext.

Namespace:  System.ComponentModel.DataAnnotations
Assembly:  System.ServiceModel.DomainServices.Server (in System.ServiceModel.DomainServices.Server.dll)

Syntax

'Declaration
Public Function Authorize ( _
    principal As IPrincipal, _
    authorizationContext As AuthorizationContext _
) As AuthorizationResult
'Usage
Dim instance As AuthorizationAttribute
Dim principal As IPrincipal
Dim authorizationContext As AuthorizationContext
Dim returnValue As AuthorizationResult

returnValue = instance.Authorize(principal, _
    authorizationContext)
public AuthorizationResult Authorize(
    IPrincipal principal,
    AuthorizationContext authorizationContext
)
public:
AuthorizationResult^ Authorize(
    IPrincipal^ principal, 
    AuthorizationContext^ authorizationContext
)
member Authorize : 
        principal:IPrincipal * 
        authorizationContext:AuthorizationContext -> AuthorizationResult 
public function Authorize(
    principal : IPrincipal, 
    authorizationContext : AuthorizationContext
) : AuthorizationResult

Parameters

Return Value

Type: System.ComponentModel.DataAnnotations.AuthorizationResult
An AuthorizationResult object that indicates whether the operation is allowed or denied. Returns Allowed when the operation is allowed. Returns a non-null AuthorizationResult when the request has been denied. The ErrorMessage property contains the error message that is displayed to users.

Exceptions

Exception Condition
ArgumentNullException

principal or authorizationContext is nulla null reference (Nothing in Visual Basic).

Remarks

This method is the entry point for authorization. It delegates to the derived class's IsAuthorized method for implementation-specific authorization.

See Also

Reference

AuthorizationAttribute Class

System.ComponentModel.DataAnnotations Namespace