Udostępnij za pośrednictwem


Sys.Services RoleService IsUserinRole Property

Checks whether the currently authenticated user is in the specified role.

Note

To get or set property values for client API properties, you must call property accessor methods that are named with the get_ and set_ prefixes. For example, to get or set a value for a property such as cancel, you call the get_cancel or set_cancel methods.

Sys.Services.RoleService.get_isUserInRole(role);

Parameters

Parameter

Description

role

The name of the role to check for.

Return Value

true if the current user is in the specified role; otherwise, false.

Remarks

Before you use the IsUserInRole property, you must load the roles by using the load method. If no roles are loaded, this property returns false.

Example

The following example shows how to use the IsUserInRole property to check whether the authenticated user is in the specified role. This code is part of a complete example found in the RoleService class overview.

// This function gets the role service path.
function GetRoleServicePath()
{
    // Get the role service path.
    var roleServicePath = 
        Sys.Services.RoleService.get_path();
    if (roleServicePath == "")
    {
        DisplayInformation(
            "The role service path is the default value.");
    }
}

See Also

Concepts

Sys.Services.AuthenticationService Class

Sys.Services.ProfileService Class