SFU.getValueForRightCode()
- Last UpdatedJun 25, 2024
- 1 minute read
Use SFU.getValueForRightCode() method to get the values for security rights of a user.
Syntax
SFU.getValueForRightCode(rights, userIdWithProvider)
Parameters
|
Parameter |
Description |
|---|---|
|
rights |
Array of Right codes |
|
userIdWithProvider |
User Id of the user for whom the roles are fetched. This parameter is optional. If the parameter is not passed, it fetches the roles for the current logged-in user. |
Return Value
Values for security right codes.
Example 1
// Gets the values for Security Rights for the logged-in user
var rightsValue = SFU.getValueForRightCode(["CanView", "CanEdit"]);
// rightsValue variable would get values of the rights as a key-value pair
var valueForCanViewRight = rightsValue["CanView"];
var valueForCanEditRight = rightsValue["CanEdit"];
Example 2
// Gets the values for Security Rights for the User with Id "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX".
var rightsValue = SFU.getValueForRightCode(["CanView", "CanEdit"], "skeltalist::XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
// rightsValue variable would get values of the rights as a key-value pair
var valueForCanViewRight = rightsValue["CanView"];
var valueForCanEditRight = rightsValue["CanEdit"];
The userIdWithProvider value varies based on the authentication provider configured. This value should have the Entity instance mapped for the repository to be prefixed along with real id of the user.
-
If the repository is mapped to Repository User Provider, the userIdWithProvider will be skeltalist::[GUID]. Here the GUID is of the user john, taken from SKEUsers table present in the Repository DB.
For example: skeltalist:: C99B4110-C8CC-410B-BF70-93F3A7E34EDF
-
If the repository is mapped to the Active Directory user provider, the userIdWithProvider will be activedirectory::[samAccountName]. Here, samAccountName is an active directory property value.
For example: activedirectory::john
Note: The API SFU.getValueForRightCode() is applicable only for “Repository” or “Global” types of “Scope of Right” values.