0 Replies Latest reply on Jul 7, 2008 7:33 AM by J K

    How to get current User's Role ?

    J K Newbie

      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 .