Is it possible to test what User Rights the current user has?

Hi, I have a BeforeCheckInChanges Event Handler which blocks certain actions by raising an error
I want it to only apply to normal users, and not users who have 'Full control of vault' rights - MFUserAccountVaultRoleFullControl

I can set or remove certain roles from a user account in an AfterCreateUserAccount Event Handler:


And according to this the BeforeCheckInChanges event has access to 'CurrentUserID' and 'CurrentUserSessionInfo'

But then looking at it appears SessionInfo has some roles like CanManageCommonViews, but nothing for Full control of vault.

How do I test if the current user has Full control of vault?
Or failing that, test for CanManageCommonViews, as our admins will have that

I feel like I've found most of what I'd need to figure this out, but am struggling to put the pieces together
Many thanks

  • Not sure if there is a better way to do this but if you have the user ID then there is a way to check if they have full control of the vault by checking their Vault role. 

    Dim SumOfVaultRoles : SumOfVaultRoles = Vault.UserOperations.GetUserAccount(UserID).VaultRoles

    The number that returns is the sum of the user's vault roles. It looks like the roles are all represented by a different bit being set as a 1 or 0 . So the roles all have a value corresponding of a bit being set to 1 (ie 1,2,4,8,16,32....) and the number returning is a summation of the bits that are set to 1. 

    For the sake of not making things confusing I will just point out that the role for "Full Control of vault" is =1 and it is the only one that is an Odd number so if you divide the sum of roles by 2 and get a a remainder of 1 then that user has full control of the vault. 

     ' This is untested code so I am not sure if vault roles is an integer so you might have to convert it with CInt like below 

    If ( (CInt(SumOfVaultRoles ) MOD 2 ) =1 ) Then 
        ' the user has full control of the vault 
        'user does not have full control of the vault
    End if

    Here is a link to the vault roles : 

  • Great, thanks again Smiley

    Here's what I used (CurrentUserID rather than UserID)

    Dim SumOfVaultRoles : SumOfVaultRoles = Vault.UserOperations.GetUserAccount(CurrentUserID).VaultRoles
    If SumOfVaultRoles MOD 2 <> 1 Then
    End If