ManagementAuthorization.IsAuthorized Method (IPrincipal, String)

IIS 7.0

Retrieves a value indicating whether the specified principal is authorized for the specified configuration path.

Namespace:   Microsoft.Web.Management.Server
Assembly:  Microsoft.Web.Management (in Microsoft.Web.Management.dll)

static member IsAuthorized : 
        principal:IPrincipal *
        configurationPath:string -> bool


Type: System.Security.Principal.IPrincipal

A System.Security.Principal.IPrincipal interface that represents the security context of the user on whose behalf the code is running.

Type: System.String

The configuration path.

Return Value

Type: System.Boolean

true if the principal is authorized for the specified configuration path; otherwise, false.

Exception Condition

principal or configurationPath is null.

This method checks the Administration.config file to determine whether the principal is an authorized user for the specified configuration path.

The following example demonstrates the IsAuthorized method. This code example is part of a larger example provided for the ManagementAuthorization class.

    ManagementAuthorization.IsAuthorized(principal, path).ToString());
SiteOwnerDetailsBag.Add(2, siteName as string);

The following example sets the principal parameter to an object that enables you to check the Windows group membership of the current user.

AppDomain domain = Thread.GetDomain();
WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
Return to top