UsrMgr_AddUserToLocalGroup
Description
Section titled “Description”Adds a user to a local group.
- If the user is already a member of the group, the function returns True without making changes.
- If the local group doesn’t exist, the function fails.
Syntax
Section titled “Syntax”UsrMgr_AddUserToLocalGroup(sDomainName, sUserName, sGroupName) As Boolean
Parameters
Section titled “Parameters”sDomainName (String)
Section titled “sDomainName (String)”Where the user account is located: a domain name for a domain user, or the local computer name (gsWorkstationName) for a local user. Ignored when sUserName is INTERACTIVE or S-1-5-4.
sUserName (String)
Section titled “sUserName (String)”Name of the user. To add the built-in INTERACTIVE group, specify INTERACTIVE or its SID S-1-5-4.
sGroupName (String)
Section titled “sGroupName (String)”Name or SID of the local group, for example Administrators or S-1-5-32-544. The name isn’t case sensitive.
Example
Section titled “Example”'Add a domain user to a local groupIf bStatus Then bStatus = UsrMgr_AddUserToLocalGroup("Domain", "Username", "Group")
'Add a local user to the local Administrators group, specified by its SIDIf bStatus Then bStatus = UsrMgr_AddUserToLocalGroup(gsWorkstationName, "Username", "S-1-5-32-544")Related functions
Section titled “Related functions”UsrMgr_CreateLocalUser UsrMgr_CreateLocalGroup UsrMgr_RemoveUserFromLocalGroup UsrMgr_IsUserMemberOfLocalGroup Constants Package Property Variables