Determine all groups for a defined user

2020-06-21 05:52发布

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?

6条回答
倾城 Initia
2楼-- · 2020-06-21 06:41

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.

查看更多
我想做一个坏孩纸
3楼-- · 2020-06-21 06:43

session.evaluate( "@UserNamesList" );

查看更多
【Aperson】
4楼-- · 2020-06-21 06:44

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

查看更多
祖国的老花朵
5楼-- · 2020-06-21 06:46

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

查看更多
爷的心禁止访问
6楼-- · 2020-06-21 06:52

use this snippets:

XSPContext context = XSPContext.getXSPContext(FacesContext.getCurrentInstance());
DirectoryUser currentUser = context.getUser();
Vector<String> groups = new Vector(currentUser.getGroups());
查看更多
孤傲高冷的网名
7楼-- · 2020-06-21 06:54

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.

查看更多
登录 后发表回答