You want the username ?
String loggedInUsername = request.getRemoteUser();
No, just the Id.
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)
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).
What are you trying to achieve ? Why do you need the database id for ?
A colleague of mine has created a table in the database. The elements which belong to an user are only accessible via the id.