ok, Acegi can even use MS Active Directory when you read the javadocs.
First it binds using ldapuser/paderborn/germany/company/com, does the search for the username, re-binds with the found dn and then reads the attribute memberOf. (So it is possible! Forget what I said earlier.)
Code:
<bean
id="initialDirContextFactory"
class="org.acegisecurity.providers.ldap.DefaultInitialDirContextFactory">
<constructor-arg value="ldap://myserver:389/dc=company,dc=com" />
<property name="managerDn">
<value><![CDATA[cn=ldapuser,ou=paderborn,ou=germany,dc=company,dc=com]]></value>
</property>
<property name="managerPassword">
<value>some password</value>
</property>
<property name="extraEnvVars">
<map>
<entry>
<key>
<value>java.naming.referral</value>
</key>
<value>follow</value>
</entry>
</map>
</property>
</bean>
<bean
id="userSearch"
class="org.acegisecurity.providers.ldap.search.FilterBasedLdapUserSearch">
<property name="searchSubtree">
<value>true</value>
</property>
<property name="initialDirContextFactory">
<ref local="initialDirContextFactory" />
</property>
<property name="searchFilter">
<value>(sAMAccountName={0})</value>
</property>
</bean>
<bean
id="ldapAuthenticationProvider"
class="org.acegisecurity.providers.ldap.LdapAuthenticationProvider">
<constructor-arg>
<bean
class="org.acegisecurity.providers.ldap.authenticator.BindAuthenticator">
<constructor-arg>
<ref local="initialDirContextFactory" />
</constructor-arg>
<property name="userSearch">
<ref local="userSearch" />
</property>
</bean>
</constructor-arg>
<constructor-arg>
<bean
class="org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator">
<property name="userRoleAttributes">
<value>memberOf</value>
</property>
<property name="convertToUpperCase">
<value>true</value>
</property>
<property name="rolePrefix">
<value></value>
</property>
</bean>
</constructor-arg>
</bean>
The only problem with this solution is that you get the DN of the group, i.e.
cn=APPNAME_ROLE,ou=groups,ou=paderborn,ou=germany, dc=company,dc=com. This is not very nice in the taglib.
Doing a groupsearch for member={0} and using cn as the result will fix this.
Unfortunatelly in our configuration ou=groups is the second entry in the hierarchy and not the last before dc=company,dc=com.
Maybe creating another initialDirFactory with root DN dc=com and groupSearchBase dc=company will fix this.
Has anyone tried this yet?
btw, setting java.naming.referral to follow got rid of the nasty javax.naming.PartialResultException.