Share via


ManagementAuthorization.IsAuthorized(IPrincipal, String) Method

Definition

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

public:
 static bool IsAuthorized(System::Security::Principal::IPrincipal ^ principal, System::String ^ configurationPath);
public static bool IsAuthorized (System.Security.Principal.IPrincipal principal, string configurationPath);
static member IsAuthorized : System.Security.Principal.IPrincipal * string -> bool
Public Shared Function IsAuthorized (principal As IPrincipal, configurationPath As String) As Boolean

Parameters

principal
IPrincipal

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

configurationPath
String

The configuration path.

Returns

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

Exceptions

principal or configurationPath is null.

Examples

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

SiteOwnerDetailsBag.Add(1, 
    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();
domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;

Remarks

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

Applies to