getOSUserGroupsMembership()
The function getOSUserGroupsMembership queries the operating system group memberships of a user.
Synopsis
dyn_mapping getOSUserGroupsMembership(string userName, dyn_string
filterGroupOSIDs, [string domain]);
Parameters
Parameters | Description |
---|---|
userName |
The user name of the user you are querying. Since a user of a domain could be logged on to another domain, the parameter "userName" must contain the user domain. Use the parameter "domain" (see below), to specify the operating system domain. |
filterGroupOSIDs | OS Id's of the groups you are querying. |
domain |
The parameter "domain" specifies in which domain the query is executed. The default value is the domain of the current computer (where the query is executed). If only one domain exists in the IT infrastructure, the parameter does not bear a meaning. If the IT infrastructure consists of several domains and a user was created in another domain than where the query is executed, the user is not found. In this case, specify the correct domain by using the parameter "domain". Example:
|
Return value
The group memberships of the specified user.
Error
Missing or wrong arguments.
Description
The function getOSUserGroupsMembership queries the operating system group memberships of a user.
Returns the group memberships of the current user.
main()
{
mapping mUser = getOSUser(); //Returns the current user of the domain
string username = mUser["Name"];
DebugN("USername:", username);
dyn_mapping dmGroups = getOSGroups(); //Returns an array with attributes of all groups
DebugN("User groups:", dmGroups);
dyn_string dsOSID;
for(int i = 1; i <= dynlen(dmGroups); i++)
DebugN(dsOSID[i] = dmGroups[i]["OSID"]);
string osDomain = "DomainName"; //User domain
string userDomain = "DomainName2"; //Operating system domain
DebugTN("Domain = ",osDomain);
dmGroups = getOSUserGroupsMembership(userDomain+"\\"+username,dsOSID,osDomain);
/* All groups of the domain the user is member of.
Note that you specify the user domain for the parameter userName -> in this example "userdomain"*/
DebugTN("getOSUserGroupsMembership("+userDomain+"\\"+username+" "+","+osDomain+") = ",dmGroups);
}
Assignment
Availability
UI, CTRL