[jboss-user] [JBoss Portal] - How to get current User's Role ?

jboss.techie do-not-reply at jboss.com
Mon Jul 7 07:33:49 EDT 2008


Hi ,
How can I retreive logged in user's role? I am using MSSQLDS. 
I have attatched my code here:
	
  | UserModule usrMod = (UserModule) new InitialContext().lookup("java:/portal/UserModule");
  | MembershipModule mbr = (MembershipModule)new InitialContext().lookup("java:/portal/MembershipModule");
  | User user = usrMod.findUserByUserName("john"); // username = john
  | Set roles = mbr.getRoles(user);
  | Iterator itr = roles.iterator();
  | while(itr.hasNext()){
  |          Role role = (Role)itr.next();
  |          System.out.println( "ROLE  : "+ role.getDisplayName());
  | }
  | 
It says , Could not find user by name john. (Identity Exception)
But in my database, there is an entry for this username.
Please help me out.
Thanks .


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4162814#4162814

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4162814



More information about the jboss-user mailing list