Export (0) Print
Expand All

Roles::Provider Property

Gets the default role provider for the application.

Namespace:  System.Web.Security
Assembly:  System.Web (in System.Web.dll)

public:
static property RoleProvider^ Provider {
	RoleProvider^ get ();
}

Property Value

Type: System.Web.Security::RoleProvider
The default role provider for the application, which is exposed as a class that inherits the RoleProvider abstract class.

ExceptionCondition
System.Configuration.Provider::ProviderException

Role management is not enabled.

The Provider property enables you to directly reference the default role provider for an application. This is commonly used to access custom members of the role provider that are not part of the RoleProvider abstract class.

For example, the WindowsTokenRoleProvider class includes an overload of the IsUserInRole method that enables you to determine whether a user is in a common Windows role by using a WindowsBuiltInRole enumeration value. A reference to the WindowsTokenRoleProvider class for an application can be obtained by using the Provider property and can be cast as a WindowsTokenRoleProvider in order to refer to the IsUserInRole overload.

If multiple role providers are configured for an application, you can access different role providers using the Providers collection.

The following code example casts the default role provider as a WindowsTokenRoleProvider and checks whether the currently logged-on user is in the Administrators role before allowing the user to view roles settings for the application. For an example of a Web.config file that enables role management, see WindowsTokenRoleProvider.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft