EnumUsersWithFilter2

Performs a filtered search that returns the security identifiers and usernames of matching users and groups. Filtering options include wildcard searching on usernames and filtering by user category. If delegated user management is enabled in Shared Services, you can filter users who have access rights not granted to the connected user.

Syntax

<HsvSecurityAccess>.EnumUsersWithFilter2 bstrFilter, lBitFieldPrincipalsToReturn, AccessType, pvarabstrUserSIDs, pvarabstrNames
ArgumentDescription
bstrFilterString (ByVal). The string by which to search user and group names. For wildcard searches, use asterisks ( * ).
lBitFieldPrincipalsToReturnLong (ByVal). A bitmask that represents the user categories by which to filter. Valid values for the bits are listed in Table 72, HFM_USER_GROUP_ENUM_FLAGS Enumeration.
AccessTypeLong (ByVal). If delegated user management is enabled, this argument lets you to filter users who have access rights not granted to the connected user. Pass 1 to filter by access rights, 0 otherwise.
pvarabstrUserSIDsVariant array. Returns the security identifiers for the users and groups that match the search criteria. The array's subtype is String.
pvarabstrNamesVariant array. Returns the names of the users and groups that match the search criteria. The array's subtype is String.

Example

The following function returns an array of the user and group names that begin with the string passed.

Function GetUsersByPrefix(sPrefix As String) As Variant
Dim cSecurity As HsvSecurityAccess, vaIds, vaNames
'g_cSession represents an HsvSession instance
Set cSecurity = g_cSession.Security
cSecurity.EnumUsersWithFilter2 sPrefix & "*", HFM_USER_GROUP_ENUM_GROUPS _
    & HFM_USER_GROUP_ENUM_USERS, 0, vaIds, vaNames
GetUsersByPrefix = vaNames
End Function