AddOrRemoveUsersFromRole2

Assigns users to or removes them from a given role.

Syntax

<HsvSecurityAccess>.AddOrRemoveUsersFromRole2 lRoleID, varabstrUserSIDs, varabAdd

Argument

Description

lRoleID

Long (ByVal). The ID of the role. For a list of valid role IDs, see Role ID Constants.

Tip:

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

varabstrUserSIDs

String array (ByVal). The security identifiers of the users being assigned to or removed from the role.

This array has a one-to-one correspondence with the varabAdd argument’s array. For example, the third element of the varabAdd array indicates whether the user identified by the third element of this array is assigned or removed.

varabAdd

Boolean array (ByVal). Indicates whether users should be assigned to or removed from the role. For each array element, specify TRUE to assign, FALSE to remove.

Example

The following subroutine adds the specified users to a given role. The subroutine takes an array of security identifiers and the name of the role.

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