FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Sep 12, 2011, 8:27 AM
66 Posts
topic has been resolvedResolved

How can I get user roles from the other database in xPages app?

  • Category: Other
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags:
  • Replies: 5
 I have a xPages app, that is separate aplication and takes data (views and documents) from different existing application. We just dont want to mix design of both together. Its easy to do, because view and document datasources can be connected to different app so its very transparent. But we found conceptual problem when using roles permissions. On xPages we need to check, whether use has some role in this 'other/second" database. In java using getContext().getUser().getRoles().contains(name) just checks role in our xPages(current) application. Is there an easy way how to determine, whether the user has certain role in other databases?
Sep 12, 2011, 12:49 PM
39 Posts
Re: How can I get user roles from the other database in xPages app?
Not sure if this is easy or not but you could
 
get the database you want the roles from
create a new acl object from that db
loop through the aclentries looking for the one you want
when you find it get the roles and look for the one you want.
 
using the ACL and ACLEntry classes
 
Thanks
-Toby
Sep 12, 2011, 3:04 PM
66 Posts
Re: How can I get user roles from the other database in xPages app?
 I thought about this aproach but users are members of groups or 'goups inside groups', and such groups have a roles .... so its not such straightforward ... I definitely hoped for some easier solution based on existing API I missed so far.
Sep 13, 2011, 9:01 AM
31 Posts
Will queryAccessRoles do the trick ?
var title:string = database.getTitle();database
title = "For database \"" + title + "\" you have the following access roles: ";
var roles = database.queryAccessRoles(session.getUserName());
if (roles.isEmpty()) {
return title + " none";
} else {
for (var i=0; i<roles.length; i++) {
title = title + " " + roles[i];
}
return title;
}
Sep 14, 2011, 3:20 AM
66 Posts
Re: How can I get user roles from the other database in xPages app?
 GREAT!! I havent noticed this under Database class, my shame :-(
Sep 14, 2011, 6:02 AM
53 Posts
Re: How can I get user roles from the other database in xPages app?
Make sure you read the help for queryaccessroles though - if a person is listed in the acl it won't check their group membership as well, so doesn't necessarily return all their roles. This may not be an issue for you, dependant on your ACL structure
 
To be honest, if you're creating your design in an app all the relevant access should be contained within that app. Of course document level security can be dealt with in the original database using reader fields, but if you're essentially trying to duplicate hide-whens on view links then you should think about re-creating that in the app with the design

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.