To query for the current user's ID and group information from a remote application, use the IUserManager interface in the IDK.
To query for the properties for an existing user, follow the steps below. (To retrieve a user ID, you can also execute a standard object query with type ObjectClass.User.)
Java
public static void printGroupIDs(IUserManager userManager)
throws PortalException, MalformedURLException, RemoteException
{
int[] ids = userManager.getCurrentUserGroups();
for(int i = 0 ; i < ids.length ; i++)
{
System.out.println("Current user belongs to group with ID: " + ids[i]);
}
}
.NET (C#)
public static void PrintGroupIDs(IUserManager userManager)
throws PortalException, MalformedURLException, RemoteException
{
int[] ids = userManager.GetCurrentUserGroups();
for(int i = 0 ; i < ids.length ; i++)
{
Console.WriteLine("Current user belongs to group with ID: " + ids[i]);
}
}
.NET (VB)
Public Shared Sub PrintGroupIDs(ByVal userManager As IUserManager)
Dim ids() As Integer = userManager.GetCurrentUserGroups()
Dim i As Integer
For i = 0 To ids.Length
Console.WriteLine("Current user belongs to group with ID: " & ids[i])
EndSub