Use the User object's Groups collection to modify which groups the user belongs to. Recall that you can retrieve the User object by using the PluginInterface property. The following code segment retrieves the Groups collection:
var Result = IStore.Query("SELECT Top 1* FROM CI_SYSTEMOBJECTS WHERE SI_ID="+UserID);
var MemberGroups = User.PluginInterface("").Groups;
Now that you have this collection, use it together with the group ID to add a user to a group. For example,
Group = MemberGroups.Add(Number(GroupID));
When you add a member to the group, if the function was successful, the Group object that the user was added to is returned. You can retrieve a group ID by querying the APS, see Retrieving a list of available groups.
To remove the user do the following:
MemberGroups.Delete("#"+GroupID);
Note: The number sign needs to be appended to the group ID so that it is not treated as an array index. That is, when the group ID is specified with the number symbol, the method will look up the index number for the group and remove the group.
Once you have finished modifying the user's groups, commit the changes to the APS.
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |