Utiliser Microsoft Active Directory

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Avant propos.

ori-oai-workflow a la possibilité de se connecter à un annuaire LDAP pour l'authentification et l'identification.

Le développement de cette possibilité s'est initalement naturellement concentré sur la compatibilité avec des annuaires LDAP type SupAnn .

Certains utilisateurs ont eu à installer ori-oai-workflow sur un Microsoft Active Directory, un certain nombre de modifications sont à faire pour y parvenir, on tente ici de rassembler quelques notes autour de cela.

N'hésitez pas à contrbuer à cette page en la modifiant directement ou en y ajoutant des commentaires, cela afin d'obtenir une documentation complète, voire à permettre aux développeurs d'intégrer cette possibilité AD nativement dans ori-oai-workflow.

Notes

Quelques notes pour pouvoir utiliser Active Directory de Microsoft avec ori-oai-workflow.
On privilégiera cependant l'utilisation d'un annuaire ldap type Supann à celui d'un AD.
La particularité constatée de l'AD est que le full Domain Name d'un utilisateur ne comprend pas un uid=jtest mais un cn="Justin Test".
L'identifiant login étant un attribut particulier, le "sAMAccountName".

Objectifs

Avec les modifs données ci-dessous, on est censé pouvoir

  • utiliser AD pour s'authentifier via le couple sAMAccountName / password
  • utiliser AD pour récupérer les attributs d'un utilisateur et ses groupes

main-config.properties :

ldap.managerDn = le sAMAccountName d'un "admin" dans l'AD
ldap.managerPassword = son password

acegi-authentication-ldap.xml

  • On décommente l'usage de ldap.managerDn et ldap.managerPassword
  • On ajoute un bloc extraEnvVars, cf diff ci-dessous
Index: /opt/ori-oai/ori-oai-src/ori-oai-workflow-svn/conf/properties/spring/acegi/acegi-authentication-ldap.xml
===================================================================
--- /opt/ori-oai/ori-oai-src/ori-oai-workflow-svn/conf/properties/spring/acegi/acegi-authentication-ldap.xml	(revision 1694)
+++ /opt/ori-oai/ori-oai-src/ori-oai-workflow-svn/conf/properties/spring/acegi/acegi-authentication-ldap.xml	(working copy)
@@ -9,14 +9,23 @@
 		class="org.acegisecurity.ldap.DefaultInitialDirContextFactory">
 		<constructor-arg
 			value="${ldap.providerUrl}" />
-		<!-- uncomment it if you want to connect vith username/password (see main-cinfig.properties)
+		<!-- uncomment it if you want to connect vith username/password (see main-cinfig.properties) -->
 		<property name="managerDn">
 			<value>${ldap.managerDn}</value>
 		</property>
 		<property name="managerPassword">
 			<value>${ldap.managerPassword}</value>
 		</property>
-		-->
+		  <property name="extraEnvVars">
+		    <map>
+		      <entry>
+			<key>
+			  <value>java.naming.referral</value>
+			</key>
+			<value>follow</value>
+		      </entry>
+		    </map>
+		</property>
 	</bean>

</beans>

acegi-authentication.xml

On surcharge le userSearch donné par défaut avec acegi, cf diff ci-dessous

Index: /opt/ori-oai/ori-oai-src/ori-oai-workflow-svn/conf/properties/spring/acegi/acegi-authentication.xml
===================================================================
--- /opt/ori-oai/ori-oai-src/ori-oai-workflow-svn/conf/properties/spring/acegi/acegi-authentication.xml	(revision 1694)
+++ /opt/ori-oai/ori-oai-src/ori-oai-workflow-svn/conf/properties/spring/acegi/acegi-authentication.xml	(working copy)
@@ -82,8 +82,27 @@
 		<property name="peopleSearchBase" value="${ldap.people.peopleSearchBase}" />
 		<property name="uidAttribute" value="${ldap.people.uidAttribute}" />
 		<property name="mailAttribute" value="${ldap.people.mailAttribute}" />
+		<property name="userSearch"><ref bean="userSearch"/></property>
 	</bean>

+	<bean id="userSearch"
+	      class="org.acegisecurity.ldap.search.FilterBasedLdapUserSearch">
+	  <constructor-arg index="0">
+	    <!--value>dc=ul,dc=edu,dc=lb</value-->
+	    <value></value>
+	  </constructor-arg>
+	  <constructor-arg index="1">
+	    <value>(sAMAccountName={0})</value>
+	  </constructor-arg>
+	  <constructor-arg index="2">
+	    <ref bean="initialDirContextFactory" />
+	  </constructor-arg>
+	  <property name="searchSubtree">
+	    <value>true</value>
+	  </property>
+	</bean>
+
+
 	<bean id="oriLdapAuthoritiesPopulator"
 		class="org.orioai.workflow.services.application.OriLdapAuthoritiesPopulator">
 		<constructor-arg>

OriBindAuthenticator.java

Certaines parties du code doivent à ce jour être commentées.
Cf diff ci-dessous

Index: /opt/ori-oai/ori-oai-src/ori-oai-workflow-svn/src/org/orioai/workflow/services/application/OriBindAuthenticator.java
===================================================================
--- /opt/ori-oai/ori-oai-src/ori-oai-workflow-svn/src/org/orioai/workflow/services/application/OriBindAuthenticator.java	(revision 1694)
+++ /opt/ori-oai/ori-oai-src/ori-oai-workflow-svn/src/org/orioai/workflow/services/application/OriBindAuthenticator.java	(working copy)
@@ -78,12 +78,14 @@
 		// If DN patterns are configured, try authenticating with them directly
 		Iterator dns = getUserDns(username).iterator();

+		/*
 		while (dns.hasNext() && (user == null)) {
 			String dn = (String) dns.next();
 			log.debug("retrieveUser :: dn : " + dn);
 			user = bindWithDn(dn, username);
 			log.debug("retrieveUser :: user : " + user);
 		}
+		*/

 		// Otherwise use the configured locator to find the user
 		// and authenticate with the returned DN.
@@ -136,11 +138,13 @@

             LdapUserDetails user = null;

+	    /*
             while (dns.hasNext() && (user == null)) {
             	String dn = (String) dns.next();
             	 log.debug("retrieveUsers :: dn : " + dn);
             	user = bindWithDn(dn, userUid);
             }
+	    */

             // Otherwise use the configured locator to find the user
             // and authenticate with the returned DN.
  • No labels