CSSDK - List the groups a user is a member of

I can't seem to find a way to list the groups which a user is a member of. I see you can list all users, you can list all groups and users within, but I cannot seem to figure out how to iterate through all the users and then get the specific groups that each individual user belongs to.

I'm using both TS 16.4 & TS 20.2.

Thanks,

Tim

Comments

  • TimK
    TimK Member
    edited August 18, 2021 #2

    I believe I get this working by using getParentGroups:

    			CSPrincipalManager principalManager = client.getPrincipalManager();
    			CSIterator usersIterator = client.getPrincipalManager().getAllTSUsers();
    			while (usersIterator.hasNext()) {
    				CSUser someUser = (CSUser) usersIterator.next();
    				System.out.println("*** user: " + someUser.getName());
    				CSIterator groupIterator = someUser.getParentGroups(false);
    				CSGroup group = null;
    				while( groupIterator.hasNext() )
    				{
    					group = (CSGroup) groupIterator.next();
    					if (group.getKind() == 0 && !"iwEveryone".equals(group.getName())) {
    						System.out.println("group: " + group.getName());
    					}
    				}
    			}
    
TeamSite Developer Resources

  • Docker Automation

  • LiveSite Content Services (LSCS) REST API

  • Single Page Application (SPA) Modules

  • TeamSite Add-ons

If you are interested in gaining full access to the content, you can register for a My Support account here.
image
OpenText CE Products
TeamSite
APIs