Stored Procedure
Sec_userHasCapability.sp: Checks whether the user or user group has specific permissions.
Inputs
|
Name |
Description |
Required |
|---|---|---|
|
userId |
The user ID for the user. You can retrieve the user ID from the UMUsers table: SELECT id FROM UMUsers WHERE login = 'user_name'. |
Yes |
|
permissionIdList |
The list of permission IDs that you want to check. |
Yes |
|
anyCapability |
The option to define an AND/OR relationship between the permissions in the permissionIdList input. |
No |
Output
Yes or No depending on whether the user or user group has the permissions.
Sample Query
This query lists checks whether user "u1" has the Agent Management permission:
--sec_userHasCapability.sp
--If you want to check if user u1 has agent management
DECLARE @userId INT = (SELECT id FROM UMUsers WHERE login = 'u1')
DECLARE @permissionIdList VARCHAR(10) = '2' --2 stands for agent management.
DECLARE @isAllowed INT = 0
EXEC sec_userHasCapability @userId, 0, @isAllowed OUTPUT, 0/*return cursor when set to 1 returns the output via a select*/, 0/*AnyCapability*/, @permissionIdList
SELECT @isAllowed