To create new groups and manage group membership from a remote application, use the IUserGroupManager interface in the IDK.
Java
public static int createEmptyGroup(IUserGroupManager userGroupManager, int adminFolderID)
throws PortalException, RemoteException
{
int newGroupID = userGroupManager.createGroup(
"IDK Group",
"Created in IDK example",
adminFolderID,
new int[0], //no member users
new int[0]); //no member groups
return newGroupID;
}
public static void addUserToGroup(IUserGroupManager userGroupManager, int userIDToAdd,
int newGroupID)
throws PortalException, RemoteException
{
userGroupManager.addMemberUsers(newGroupID, new int[]{userIDToAdd});
}
.NET (C#)
public static int CreateEmptyGroup(IUserGroupManager userGroupManager, int adminFolderID)
{
int newGroupID = userGroupManager.CreateGroup(
"IDK Group",
"Created in IDK example",
adminFolderID,
new int[0], //no member users
new int[0]); //no member groups
return newGroupID;
}
public static void AddUserToGroup(IUserGroupManager userGroupManager, int userIDToAdd,
int newGroupID)
{
userGroupManager.AddMemberUsers(newGroupID, new int[]{userIDToAdd});
}
.NET (VB)
Public Shared Function CreateEmptyGroup(ByVal userGroupManager As IUserGroupManager,
ByVal adminFolderID As Integer)
Dim emptyIntegerArray(0) As Integer
Dim newGroupID As Integer = userGroupManager.CreateGroup( _
"IDK Group", _
"Created in IDK example", _
adminFolderID, _
emptyIntegerArray, _
emptyIntegerArray) 'no member users or groups
Return newGroupID
EndFunction
Public Shared Sub AddUserToGroup( _
(ByVal userGroupManager As IUserGroupManager, ByVal userIDToAdd As Integer, ByVal newGroupID As Integer)
Dim singleUserArray() As Integer= {userIDToAdd}
userGroupManager.AddMemberUsers(newGroupID, singleUserArray)
EndSub