MWS Groups info. of a user using the Java API

Hi,

We need to know the group membership of a MWS user using the Java API. We tried IDirectory classes but doesn’t seems to work out and getting the null pointer exception.

Can someone please write the flow of the steps we should follow to get the user’s group details?

Thanks.
GetMWSUserGroup.txt (1.41 KB)

Please have a look at this wiki and the attached pdf for some background information: http://communities.softwareag.com/wiki/Wiki.jsp?page=Managing%20Users%20with%20the%20Common%20Directory%20Service%20API

Try changing the code to this:


// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
	String	user = IDataUtil.getString( pipelineCursor, "User" );
	String tempString = null;
	ArrayList<String> availableValues = new ArrayList<String>();
	String users = "";
	pipelineCursor.destroy();

// pipeline
	
	IDirectorySystem system = DirectorySystemFactory.getDirectorySystem();
	System.out.println("System value is: "+system);
	IDirectorySession session = system.createSession();
	System.out.println("Session value is: "+session);
	IDirectoryPrincipal principalUser = session.lookupPrincipalByName(user, IDirectoryPrincipal.TYPE_USER);
	System.out.println("PrincipalUser value is: "+principalUser .getName());
	List<IDirectoryGroup> principalList=session.getGroupMembership(principalUser.getID());
	System.out.println("List is: "+principalList);
	System.out.println("principalUser .getID()"+principalUser.getID());
	for(int i=0;i<principalList.size();i++) &#123;
		if(principalList.get(i).getName() != null && principalList.get(i).getType() == 1) &#123;
			availableValues.add(principalList.get(i).getName());
			users = users + principalList.get(i).getName();
			users = users + ";";
		}
	}
// added to close the session opend to query Idirectory session
	system.destroySession(session);

IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, "Groups", principalUser.getName() );
pipelineCursor_1.destroy();