6 Replies Latest reply on Apr 5, 2007 7:47 AM by mac81

    Fetch UserId form Portal

    mac81

      Hello,

      could anyone help me?

      I'm trying in vain to fetch the "userid" from the portal for my portlet application.
      I've already tried this code

      String userId = request.getParameters().getParameter("userid");

      from http://docs.jboss.com/jbportal/v2.4/reference-guide/en/html_single/#d0e2586 but it didn't work.

      Has anyone an idea?

      Thanks,
      Mac

        • 1. Re: Fetch UserId form Portal
          theute

          You want the username ?

          String loggedInUsername = request.getRemoteUser();
          


          • 2. Re: Fetch UserId form Portal
            mac81

            No, just the Id.

            • 3. Re: Fetch UserId form Portal
              theute

              Well in JSR 168 the username *is* the ID.

              That said if you use the userModule you could get the JBoss Portal User object and there is a getId() method on it that returns an object.

              In the case of the DB implementation it would return the table id (I guess that's the id you are talking about) in LDAP it would return the username.

              If you want to be safe, i suggest you use the username.
              1) You can do it in a JSR168 compliant way
              2) You are not dependant on the implementation of user module (LDAP or Database or whatever)

              • 4. Re: Fetch UserId form Portal
                mac81

                Hi Thomas,

                thanks for your answer.

                I've already assumed that there's no other option to obtain the user Id (yes, I mean the number and in my specific case I cannot use the name) than to use the "UserModule".

                Unfortunately, the UserModule don't work as I use a java bean in the same application (and java beans and UserModule don't harmonize in a managed transaction).
                -> http://www.dbforums.com/archive/index.php/t-1078951.html

                Greetings,
                Mac

                • 5. Re: Fetch UserId form Portal
                  theute

                  What are you trying to achieve ? Why do you need the database id for ?

                  • 6. Re: Fetch UserId form Portal
                    mac81

                    A colleague of mine has created a table in the database. The elements which belong to an user are only accessible via the id.