Domanda

I am currently creating a java method(part of and XPages managed bean) to retrieve a list groups a user(not necessarly current user) is a member of.

Is there any easy method to retieve this information or am i going to have to loop through all the groups to check for the user and also check if those groups are sub groups of other groups?

È stato utile?

Soluzione

Answered this in a blog post here: http://ntf.gbs.com/nathan/escape.nsf/d6plinks/NTFN-8TMHRP

Simple version is that what you're looking for is...

lotus.notes.addins.DominoServer server = new lotus.notes.addins.DominoServer("YourCanonicalServerName");
Collection nameList = server.getNamesList("TheUserNameYou'reLookingFor");

That should be all you need.

Altri suggerimenti

use this snippets:

XSPContext context = XSPContext.getXSPContext(FacesContext.getCurrentInstance());
DirectoryUser currentUser = context.getUser();
Vector<String> groups = new Vector(currentUser.getGroups());

You can retrieve this information from ($ServerAccess) view in names.nsf, which is categorized by user name.

session.evaluate( "@UserNamesList" );

Rather than looping through all the groups in all the directories on the server you might prefer to create a special view in each director organized by group members. That makes the finding of matches quite a lot faster.

The GroupManager tools mentioned by Jasper are also a good example of LotusScript code which accomplishes most of what you want. The objects in Java are the same, the syntax is just a lot more pesky.

/Newbs

Not sure if you can (re)use the LotusScript here, but this article (IBM DeveloperWorks, look at the 4th paragraph) is a great start. It mentions the NotesGroupManager and NotesGroup classes. These classes could be used as a basis for rewriting the code for XPages. There seems to be no other "easy" way to find all the groups a user belongs to. The straight answer to the question seems to be NO.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top