xpages - Multiple database application ACL (part 2) -


i posted question access control multi database application tried putting application. here case. have maindb has acl no roles defined. user clicks button , opens control crud datasource has computed filepath different database call appdb. in appdb acl has several roles defined, , have added myself acl , assigned me roles [admin] , [finance]. in control have added after page load event following:

var roles = context.getuser().getroles(); viewscope.put("vsroles", roles); 

upon opening page viewscope vsroles [] has not recognized have additional set of roles in appdb. appear context.getuser().getroles() gets roles @ authentication time when log maindb.nsf, , not picking roles when open appdb. need use roles configure actions person can perform, plus documents user can read and/or edit.

to complicate issue user may switch between multiple target application databases , no doubt have different roles , access each one. response previous question,but might not have explained in enough detail.

so, far understood, need learn specific roles user has appdb.

context.getuser().getroles() provides information current application (maindb.nsf in case). accessing appdb.nsf @ data source level. can use java method learn roles of specific user in target database:

public static list<string> getroles(database targetdb, string username) {     acl acl=null;     list<string> roles=new arraylist<string>();      try {         acl=targetdb.getacl();         roles.addall(targetdb.queryaccessroles(username));     } catch (notesexception e) {         // failed, nothing do...     } {         if(acl!=null) acl.recycle();     }      return roles; } 

as example:

session session=extlibutil.getcurrentsession(); database appdb=session.getdatabase("", "appdb.nsf");  // make sure appdb not null...  list<string> rolelist=getroles(appdb, session.geteffectiveusername()); extlibutil.getviewscope().put("vsroles", rolelist); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -