.NET Framework Class Library
ManagementAuthorization..::.IsAuthorized Method

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)
Syntax

Visual Basic (Declaration)
Public Shared Function IsAuthorized ( _
    principal As IPrincipal, _
    configurationPath As String _
) As Boolean
Visual Basic (Usage)
Dim principal As IPrincipal
Dim configurationPath As String
Dim returnValue As Boolean

returnValue = ManagementAuthorization.IsAuthorized(principal, _
    configurationPath)
C#
public static bool IsAuthorized(
    IPrincipal principal,
    string configurationPath
)
Visual C++
public:
static bool IsAuthorized(
    IPrincipal^ principal, 
    String^ configurationPath
)
JScript
public static function IsAuthorized(
    principal : IPrincipal, 
    configurationPath : String
) : boolean

Parameters

principal
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.
configurationPath
Type: System..::.String
The configuration path.

Return Value

Type: System..::.Boolean
true if the principal is authorized for the specified configuration path; otherwise, false.
Exceptions

ExceptionCondition
System..::.ArgumentNullException

principal or configurationPath is nullNothingnullptra null reference (Nothing in Visual Basic).

Remarks

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

Examples

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

Visual Basic
SiteOwnerDetailsBag.Add(0, principal.Identity.Name)
SiteOwnerDetailsBag.Add(1, ManagementAuthorization.IsAuthorized(principal, path).ToString)
SiteOwnerDetailsBag.Add(2, siteName)
C#
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.

Visual Basic
Thread.GetDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)
Dim principal As WindowsPrincipal = DirectCast(Thread.CurrentPrincipal, WindowsPrincipal)
C#
AppDomain domain = Thread.GetDomain();
domain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
WindowsPrincipal principal = (WindowsPrincipal)Thread.CurrentPrincipal;
Permissions

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .
See Also

Reference

Tags :


Page view tracker