5

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?

ekad
  • 14,436
  • 26
  • 44
  • 46
JMCooper
  • 77
  • 2
  • 6

6 Answers6

13

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.

  • Mentioned on the blog, but just in case no one checks that. "lotus.notes.addins.*" is an undocumented API so there is no guarantee it will work in later releases (or even be available). So please use at your own risk. – Simon O'Doherty Apr 27 '12 at 08:23
4

use this snippets:

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

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

Egor Margineanu
  • 740
  • 5
  • 9
  • $ServerAccess doesn't show if a user is member of a group that is member of a group. So depending on requirements that can become tricky. So starting with $ServerAccess and work from there. Caveat groups that have circular references – stwissel Apr 04 '12 at 14:16
0

session.evaluate( "@UserNamesList" );

Tommy Valand
  • 868
  • 6
  • 10
  • That will only work for the current user; so will not meet my requirements unless my understanding is incorrect. – JMCooper Apr 04 '12 at 13:39
0

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.

Jasper Duizendstra
  • 2,587
  • 1
  • 21
  • 32
0

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

Newbs
  • 1,632
  • 11
  • 16