ClientRolePrincipal::IsInRole Method
Gets a value indicating whether the user represented by the ClientRolePrincipal is in the specified role.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
Parameters
- role
- Type: System::String
The role to check.
Return Value
Type: System::Booleantrue if the user is in the specified role; false if the user is not in the specified role or is not authenticated.
Implements
IPrincipal::IsInRole(String)Normally, you will call the IsInRole method of the IPrincipal returned by the static Thread::CurrentPrincipal property. However, you can cast the CurrentPrincipal property value to a ClientRolePrincipal reference to call this method explicitly, as demonstrated in the Example section.
The IsInRole method will always return false if the user login has expired. This will not occur if your application calls the IsInRole method one time shortly after authentication. If your application must retrieve user roles at other times, you might want to add code to revalidate users whose login has expired. If all valid users are assigned to roles, you can determine whether the login has expired by calling the ClientRoleProvider::GetRolesForUser method. If no roles are returned, the login has expired. For an example of this functionality, see the GetRolesForUser method. This functionality is only necessary if you have selected Require users to log on again whenever the server cookie expires in your application configuration. For more information, see How to: Configure Client Application Services.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.