Active Directory

Disclaimer: This blog is not really new, as it’s just the migration of the technical content of our website – see further down for the French version.

NOTE: If you are interested in using AD with Solr, you may want to look at our Datafari software (still in Alpha version), which combines Apache ManifoldCF with Solr, so it eases this kind of integration. The code is available on google code: http://code.google.com/p/datafari/

In enterprise environments, enterprise search often needs a security aspect which is not necessary for standard web search. In order to assist you, we release here a small code in order to allow Constellio 1.2 (and probably 1.3 although we didn’t test it) to connect to an Active Directory in order to do the credentials check at authentication time. Here is how it works:

This modification is composed of 2 projects:

  1. First one is responsible for extraction. More precisely, it extracts users and groups from an AD, and injects it in a Constellio 1.2
  2. Second one contains an authentication class which allows for Constellio to check the credentials of the users with the AD, at authentication time. This user must have been created via the script of step 1, unless he has already been create separately in Constellio.

These are the Eclipse projects. In order to make it work:

  1. In the AD-Extractor project, modify the two property files adconfig.properties and mysqlconfig.properties . In the former, put the host and the domain of the AD, as well as the credentials with enough rights to fetch the info from the AD. In the latter, put the host of the machine hosting the DB of Constellio, as well the admin user/password.
  2. Since it is a standalone project (it’s actually a script that fetches the data), you’ll need to start the main class in order to launch it. Note that obviously, if you want a regular synchronization of the AD content, you’ll need to create a batch for regularly starting the script. The script is rather simple, so everytime you call it, it will overwrite the existing users/groups already existing in mysql.
  3. Since we query the AD for the authentication step, we don’t store the password or a hash of it in the Constellio, but only the users and groups.
  4. In the AD-Authentication project, there is a method that overloads the existing authentication method of Constellio (the original one being authenticate() in com.doculibre.constellio.services.authenticationservicesimpl). This new method queries the AD for checking the user credentials. If the response is negative, shall Constellio have also extra users in parallel to the AD (although it’s off course better to centralize the user management, there may be cases where you have users declared in several places), the new authenticate method will query the users base of Constellio through the normal authentication method of Constellio.
  5. You need to modify the adconfig.properties the same way you have done in step 1.
  6. You need to make a jar of this project package.
  7. You need to put it in the WebContent/WEB-INF/lib of Constellio
  8. You need to modify your constellio.xml (at the root of the Constellio classes, which depend whether you’re dealing here an Eclipse Constellio project or with the compiled Constellio), with the following modifications:

the original line: : <bean id=”authenticationServices” class=”com.doculibre.constellio.services.AuthenticationServicesImpl” scope=”prototype”> </bean>

the new line: : <bean id=”authenticationServices” class=”com.doculibre.constellio.services.AuthenticationServicesADImpl” scope=”prototype”> </bean>

And voilà, this should work, and now you can use AD authentication with a Constellio 1.2, although it should work also with a Constellio 1.3


Download

—————————————–

French version

Au sein des entreprises, les outils de recherché doivent souvent respecter les exigences de sécurité interne, contrairement à la recherche sur le web. Pour vous aider, nous mettons à disposition du code permettant à Constellio 1.2 (et probablement aussi 1.3, bien que nous n’ayons pas effectué les tests) de se connecter à un Active Directory, de façon à verifier les droits d’accès au moment de l’authentification. Voici comment cela fonctionne :

Cette modification est composée de 2 projets :

  1. Le premier est responsable de l’extraction. Plus précisément, il extrait les informations utilisateurs et groupes de l’AD, et l’injecte dans Constellio 1.2
  2. Le second contient la classe d’authentification, qui permet à Constellio de contacter l’AD pour vérifier les droits d’un utilisateur, au moment de l’authentification. L’utilisateur doit avoir été créé au préalable par l’étape 1, à moins qu’il n’ait été créé séparément dans le Constellio.

Ces projets sont des projets Eclipse. De façon à les faire fonctionner :

  1. Dans le projet AD-Extractor, modifiez les fichiers de propriété adconfig.properties et mysqlconfig.properties . Dans le premier, indiquez le host et le domaine du AD, ainsi que les identifiants ayant suffisament de droits pour récupérer les informations du AD. Dans le second, indiquez le host de la machine hébergeant la BDD de Constellio, ainsi que les identifiants de l’admin.
  2. Il s’agit d’un projet autonome (c’est en fait un script dont le but est de récupérer les données de l’AD), donc vous devez démarrer sa classe main afin de le lancer. A l’évidence, si vous souhaitez une synchronisation régulière du contenu de l’AD, vous devez créer un batch pour régulièrement lancer le script. Ce script est relativement simple, et à chaque execution, il écrasera les utilisateurs/groupes déjà présents dans le mysql de Constellio et provenant du AD.
  3. L’authentification des utilisateurs se faisant en interrogeant l’AD, nous ne stockons ni les mots de passe ni leur hash dans le Constellio, uniquement les utilisateurs et les groupes.
  4. Dans le projet AD-Authentication, il y a une méthode qui surcharge la méthode d’authentification existante de Constellio (l’original s’appelle authenticat() dans com.doculibre.constellio.services.authenticationservicesimpl). Cette nouvelle méthode interroge l’AD pour vérifier les identifiants. Si la réponse est négative, et dans le cas où Constellio possède des utilisateurs en parralèle à ceux de l’AD (bien qu’évidemment il soit recommandé de centraliser la gestion des utilisateurs, il y a des cas où les utilisateurs sont déclarés à plusieurs endroits), la nouvelle méthode d’authentification va alors interroger la base d’utilisateurs de Constellio, en utilisant la méthode d’authentification standard de Constellio.
  5. Vous devez modifier adconfig.properties de la même façon qu’à l’étape 1.
  6. Vous devez faire un jar du package du projet
  7. Vous devez mettre ce jar dans WebContent/WEB-INF/lib de Constellio
  8. Vous devez modifier votre constellio.xml (à la racine des classes de Constellio, emplacement qui varie selon que vous utilisez un Constellio en projet Eclipse, ou si vous utilisez un Constellio compilé), avec les modification suivantes :

l’original : <bean id=”authenticationServices” class=”com.doculibre.constellio.services.AuthenticationServicesImpl” scope=”prototype”> </bean>

le modifié : <bean id=”authenticationServices” class=”com.doculibre.constellio.services.AuthenticationServicesADImpl” scope=”prototype”> </bean>

Et voilà, tout devrait fonctionner, et vous pouvez à present utiliser une authentification par AD avec un Constellio 1.2, et cela devrait aussi fonctionner avec un Constellio 1.3


Télécharger