LDAP role/group mappings and Active Directory

Hi,

I am trying to get an EJB module to authenticate against Active Directory using an ldapRealm. I have managed to get the authentication working correctly but am having problems with role/group mappings.

In my Realm configuration I have the following:

group-base-dn: CN=Users,dc=MyADDomain,dc=MyDomain,dc=com

group-search-filter: member=%d

And my ejb-jar.xml and sun-ejb-jar.xml are attached below.

I am authenticating with a user that is a member of the Development group (which is in the Users CN) but a call to

oSessionContext.isCallerInRole("user");

returns false.

What am I missing here?

Stuart

ejb-jar.xml:

<ejb-jar>

<display-name>JAASTest</display-name>

<enterprise-beans>

<session>

<description>Test Session Bean</description>

<ejb-name>jaasejb.JAASEJB</ejb-name>

<home>jaasejb.JAASEJBHome</home>

<remote>jaasejb.JAASEJB</remote>

<ejb-class>jaasejb.JAASEJBBean</ejb-class>

<session-type>Stateless</session-type>

<transaction-type>Container</transaction-type>

<security-role-ref>

<role-name>user</role-name>

</security-role-ref>

</session>

</enterprise-beans>

</ejb-jar>

sun-ejb-jar.xml:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE sun-ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 EJB 2.0//EN' 'http://www.sun.com/software/sunone/appserver/dtds/sun-ejb-jar_2_0-0.dtd'>

<sun-ejb-jar>

<security-role-mapping>

<role-name>user</role-name>

<group-name>Development</group-name>

</security-role-mapping>

<enterprise-beans>

<ejb>

<ejb-name>jaasejb.JAASEJB</ejb-name>

<jndi-name>jaasejb.JAASEJB</jndi-name>

<ior-security-config>

<as-context>

<auth-method>USERNAME_PASSWORD</auth-method>

<realm>ActiveDir</realm>

<required>true</required>

</as-context>

</ior-security-config>

<is-read-only-bean>false</is-read-only-bean>

<gen-classes></gen-classes>

</ejb>

</enterprise-beans>

</sun-ejb-jar>

[2502 byte] By [stuartcat] at [2007-9-30 18:23:31]
# 1
Can you do a getCallerPrincipal in the ejb and see what user you get- Harpreet
harpreet1002 at 2007-7-6 19:33:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Yes, getCallerPrincipal returns a Principal with the name 'ADLogin'Stuart
stuartcat at 2007-7-6 19:33:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
I have asked someone who has worked on this particular sub component to look at this.- Harpreet
harpreet1002 at 2007-7-6 19:33:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4
Can you add the following to sun-application.xml<security-role-mapping><role-name>user</role-name><principal-name>ADLogin</principal-name></security-role-mapping>
Shing-Wai.Chan at 2007-7-6 19:33:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
I am deploying as an EJB module at present, not as an application.I will create an application and add this block to the sun-application.xmlStuart
stuartcat at 2007-7-6 19:33:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6

OK, I have created and application with the attached application.xml and sun-application.xml and I am still getting false returned from a call to SessionContext.isCallerInRole("user")

SessionContext.getCallerPrincipal().getName() is still returning "ADLogin"

Regards,

Stuart

application.xml

<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>

<application>

<display-name>Repository Data Capture</display-name>

<module>

<ejb>JaasEJB.dev.jar</ejb>

</module>

<security-role>

<role-name>user</role-name>

</security-role>

</application>

sun-application.xml

<!DOCTYPE sun-application PUBLIC '-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 J2EE Appliation 1.3//EN' 'http://www.sun.com/software/sunone/appserver/dtds/sun-application_1_3-0.dtd'>

<sun-application>

<unique-id>123123273523263456</unique-id>

<realm>ActiveDir</realm>

<security-role-mapping>

<role-name>user</role-name>

<principal-name>ADLogin</principal-name>

</security-role-mapping>

</sun-application>

stuartcat at 2007-7-6 19:33:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 7
I have constructed a test case with security-role-ref info in ejb-jar.xml. It is working fine. You may like to check if the LDAP name has whitespace or not.
Shing-Wai at 2007-7-6 19:33:51 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...