Agent J2EE : how to get uid and DN of user ?

Hi,

Sorry if I dont post on good forum.

I've installed OpenSSO (so am 7.5) on tomcat 5.5. It uses a LDAP to identify users.

On the same Tomcat, I have my application that I want to protect by OpenSSO.

I've installed Agent J2EE, and I think it works. The agent make the good redirection on OpenSSO (I use the filtercom.sun.identity.agents.filter.AmAgentFilter in my application)

The OpenSSO identify well the user with LDAP, and I can debug my application.

So, I want to get the LDAP user (UID, DN, O ...) in my application.

Can I do that ?

I try to use

String ssotoken =

AmFilterManager.getAmSSOCache().getSSOTokenForUser(HTTPRequest);

It return me a ssotoken (not null) but I dont know how to have the User LDAP in this token.

I watch it in debuguer, I have some informations about my agent (name of agent, ou of agent) but I dont find where the user is.

Have you a sample of code to take User ?

Thanks,

Thomas

[1019 byte] By [tcaiatia] at [2007-11-27 11:34:16]
# 1

Hi,

You can try modifying the AMAgent.properties and get the userId.

sample code below

#

# SESSION ATTRIBUTE PROCESSING PROPERTIES

#- session.attribute.fetch.mode: The mode of fetching session attributes.

#This value is one of: NONE, HTTP_HEADER, REQUEST_ATTRIBUTE, HTTP_COOKIE

#- session.attribute.mapping: A MAP that specifies the session attributes to

#be populated under specific names for the currently authenticated user.

#The key is the session attribute name and the value is the name under

#which that attribute will be made available.

# Hot-Swap Enabled: Yes

# Example of session.attribute.mapping:

#com.sun.identity.agents.config.session.attribute.mapping[UserToken]=CUSTOM-user id

#

#com.sun.identity.agents.config.session.attribute.fetch.mode = NONE

com.sun.identity.agents.config.session.attribute.fetch.mode = REQUEST_ATTRIBUTE

com.sun.identity.agents.config.session.attribute.mapping[UserToken] = userId

and then you can get this userId by

<%

String userId="";

HashSet val1=(HashSet)request.getAttribute("userId");

Iterator it = val1.iterator();

while(it.hasNext())

{

userId=(String)it.next();

//out.println(userId);

}

%>

hope it helps!

Deepak.

deepshara at 2007-7-29 16:56:18 > top of Java-index,Web & Directory Servers,Directory Servers...
# 2

Hi,

Thanks for your response, It works prefectly. I have my UserID !

Now, I need more informations from LDAP like :

UID, Organisation, DN, ...

Is it possible ?

In fact, if I can get LDAP User Object, it's better,

Thanks,

tcaiatia at 2007-7-29 16:56:18 > top of Java-index,Web & Directory Servers,Directory Servers...