10 Replies Latest reply on Jul 4, 2007 8:59 AM by m m

    user's group

    m m Newbie

      Hy everybody,

      I'm developing a portlet and i want to recover the groups of the user who is connect. It is possible ? I read the javadoc at the user's methods but i don't see anything to that.


      Any solutions ?

      Thanks.

      PS: Sorry for my bad English.

        • 1. Re: user's group
          Thomas Heute Master

          You can't get the roles of a user, you can only check if the user is in a specific role.

          • 2. Re: user's group
            Burkhard Vogt Newbie

            I've posted a solution, please take a look at:
            http://jira.jboss.org/jira/browse/JBPORTAL-1293

            • 3. Re: user's group
              m m Newbie

               

              You can't get the roles of a user, you can only check if the user is in a specific role.


              What must I do to check the role ?

              Thanks

              PS: Sorry for my bad English

              • 4. Re: user's group
                Thomas Heute Master


                Use:
                isUserInRole(String toto)

                See the portlet spec

                • 5. Re: user's group
                  m m Newbie

                  I'm back !

                  I find the methods to get an user when I'm in a page but they return null any time.
                  I'm use :
                  User user = (User) request.getAttribute("org.jboss.portal.header.USER");
                  in library org.jboss.portal.identity.User

                  What I must do ?


                  After, I don't find the method isUserInRole(String toto) :( what is the class at this method ?

                  Thanks.

                  PS: Sorry for my bad English.

                  • 6. Re: user's group
                    Thomas Heute Master

                    isUserInRole is on renderRequest or actionRequest:

                    See:
                    http://docs.jboss.org/jbportal/spec/docs/javax/portlet/PortletRequest.html

                    You can also use
                    getRemoteUser() on the same object to get the id of the llogged-in user.

                    • 7. Re: user's group
                      m m Newbie

                      Thks I'm go see it.

                      • 8. Re: user's group
                        m m Newbie

                        Thks for the methods I can get the user who is connect.

                        But I've a last little problem :

                        The isUserInRole("role") return me false any time.

                        I check with many role's name (I create an user with all roles), I try with the Users or the Administrators.

                        No error in return just false.

                        I read that it can be provide that not have user authenticated, but I sure it is.
                        The page where the method is, need authentificated and I can get the user name in the same place.


                        Sorry if I'm annoying.

                        Thanks.

                        PS: Sorry for my bad English.

                        • 9. Re: user's group
                          Andrew Brownfield Newbie

                          Two things tripped me up when I was starting on this. First make sure to put the security-role-ref stuff into your portlet.xml. You can find the details about this in the section 20.3 of the portlet spec.

                          Also, make sure to use the actual role names, not the displayed ones. The defaults are Admin and User. If you ever get confused about these again and you have access to the underlying database, spit out the contents of the jbp_roles table.

                          • 10. Re: user's group
                            m m Newbie

                            First of all, thks for the help, I must get the role of user for finalize my portlet for Friday, and it's reassure me to find a community who try to help.

                            But, the problem persist...
                            I check the database and I'm sure now I use the role names.

                            I try with Admin or User for test (with a user that is in all roles)

                            return false.

                            I add

                            <security-role-ref>
                             <role-name>Admin</role-name>
                             </security-role-ref>

                            in my portlet.xml

                            I log in admin and try and return false.

                            I despair :(


                            PS: Sorry for my bad English.