AddUserToRole2

Assigns a user to a role.

Syntax

<HsvSecurityAccess>.AddUserToRole2 lRoleID, bstrUserSID

Argument

Description

lRoleID

Long (ByVal). The ID of the role to which the user is being assigned. For a list of valid role IDs, see Role ID Constants.

Tip:

To get a role’s ID from its name, use GetRoleID.

bstrUserSID

String (ByVal). The user’s security identifier.

Example

The following subroutine assigns a user to a given role. The role name is passed to the subroutine, which uses GetRoleID to obtain the role ID.

Sub AssignRole(sId As String, sRole As String)
Dim cSecurity As HsvSecurityAccess, lRoleID As Long
'g_cSession is an HsvSession object reference
Set cSecurity = g_cSession.Security
cSecurity.GetRoleID sRole, lRoleID
cSecurity.AddUserToRole2 lRoleID, sId
End Sub