Configuration for Lotus Domino 6.5.4 and AcegiSecurity 1.0 RC1
Code:
<bean
id="initialDirContextFactory"
class="org.acegisecurity.providers.ldap.DefaultInitialDirContextFactory">
<constructor-arg value="ldap://myserver:389" />
</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="userDnPatterns">
<list>
<value>cn={0}</value>
</list>
</property>
</bean>
</constructor-arg>
<constructor-arg>
<bean class="org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator">
<constructor-arg>
<ref local="initialDirContextFactory" />
</constructor-arg>
<constructor-arg>
<value>o=groups</value>
</constructor-arg>
<property name="convertToUpperCase">
<value>true</value>
</property>
<property name="rolePrefix">
<value></value>
</property>
</bean>
</constructor-arg>
</bean>
The groups have the form
APPNAME_ROLE/Groups
where APPNAME is the name off the application (obviously) and ROLE is something like ADMIN, EDITOR or READER. This makes rolePrefix unneccessary.
Web user names are NOT hierarchical (Flat names unlike Notes names.) but it'd be easy to add something like /USERS in userDnPatterns.
Next will be Oracle Internet Directory (OID).
Configuration for Oracle Internet Directory 10g (OID)
Code:
<bean
id="initialDirContextFactory"
class="org.acegisecurity.providers.ldap.DefaultInitialDirContextFactory">
<constructor-arg value="ldap://myoracle.server:389/dc=company,dc=com" />
</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="userDnPatterns">
<list>
<value>cn={0},cn=Users</value>
</list>
</property>
</bean>
</constructor-arg>
<constructor-arg>
<bean
class="org.acegisecurity.providers.ldap.populator.DefaultLdapAuthoritiesPopulator">
<constructor-arg>
<ref local="initialDirContextFactory" />
</constructor-arg>
<constructor-arg>
<value>cn=groups</value>
</constructor-arg>
<property name="convertToUpperCase">
<value>true</value>
</property>
<property name="groupSearchFilter">
<value>(uniquemember={0})</value>
</property>
<property name="groupRoleAttribute">
<value>cn</value>
</property>
<property name="rolePrefix">
<value></value>
</property>
</bean>
</constructor-arg>
</bean>
The DN of a group is like cn=APPNAME_ROLE,cn=GROUPS,dc=company,dc=com.
Again rolePrefix is unneccessary in this context.
You can refine the groupSearchFilter e.g. (&(objectclass=groupOfUniqueNames)(uniqueMember={0 }))
Again configuration was easy and works flawlessly.
Microsoft Active Directory
@Luke
MS AD is a different beast. I don't think the current implementation is able to use it. (Or did I miss something.)
My problem was that in our domain user and group dns are very deep. Something like cn=Mickey Mouse,ou=FunDepartment,ou=Paderborn,ou=Germany,ou= Europe,dc=Disney,dc=com.
We have about 500+ ous, so listing them all in userDnPatterns is no option, unfortunatelly.
Just an idea:
Extend AbstractLdapAuthenticator (anyone for a good name?)
authenticate should then first bind with managerDn/managerPassword and search for an entry where sAMAccountName matches username. (sAMAccountName should be variable.)
This would give an array of DNs.
Last step is trying to bind all DNs with password. The first that binds without an error is the valid account.
As far as I can see you can also use this to authenticate against Oracle or Domino when anonymous binding is disabled on these plattforms.
Are you working on something like this? Or do you have other ideas/plans? If you need help, I could write some code and test it against our Active Directory domain.
Acegi Securiy and Microsoft Active Directory 2003
Ok, this is it. A working configuration for Acegi Security and Microsoft Active Directory 2003.
Only one issue remains:
I don't know how to configure groupSearchBase for groups in multiple different OUs (e.g. ou=Germany and ou=India).
Code:
<bean
id="initialDirContextFactory"
class="org.acegisecurity.providers.ldap.DefaultInitialDirContextFactory">
<constructor-arg value="ldap://myserver:389/dc=company,dc=com" />
<property name="managerDn">
<value>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">
<constructor-arg>
<ref local="initialDirContextFactory" />
</constructor-arg>
<constructor-arg>
<value>ou=germany</value>
</constructor-arg>
<property name="convertToUpperCase">
<value>true</value>
</property>
<property name="rolePrefix">
<value></value>
</property>
<property name="searchSubtree">
<value>true</value>
</property>
<property name="groupSearchFilter">
<value>member={0}</value>
</property>
<property name="groupRoleAttribute">
<value>cn</value>
</property>
</bean>
</constructor-arg>
</bean>