cancel
Showing results for 
Search instead for 
Did you mean: 

Steps for integrate Activiti with LDAP

jcosano
Champ in-the-making
Champ in-the-making
Hello…

I would explain how I use Activiviti with my corporative LDAP. Maybe this is not the best way, but for me is working and it would be a start point for others…

First of all, I choose a framework for work with LDAP, I consider these:
- jndi
- spring ldap
- UnboundID LDAP SDK
- Novell ldap framework

Finally I get Novell ldap framework (jldapv2.0.1.jar) because I worked with it in old projects.

Then… let's go…

1) Create a own ProcessEngineConfiguration OPTIONAL: ONLY IF YOU NEED A SPECIFIC IDENTITY SERVICE.. NOT MANDATORY

public class LDAPStandaloneProcessEngineConfiguration extends StandaloneProcessEngineConfiguration 
{
   protected IdentityService identityService = new IdentityServiceLDAPImpl();
}

2) Change Activiti.cfg.xml ( note: class should be you ProcessEngineConfiguration class… maybe StandaloneProcessEngineConfiguration )

  <bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.ldap.LDAPStandaloneProcessEngineConfiguration">
    <property name="customSessionFactories">
        <list>
       <bean class="org.activiti.engine.impl.ldap.LDAPUserManagerFactory" />
            <bean class="org.activiti.engine.impl.ldap.LDAPGroupManagerFactory" />
        </list>
    </property>
 

3) Create an own IdentityService OPTIONAL: ONLY IF YOU NEED A SPECIFIC IDENTITY SERVICE.. NOT MANDATORY

public class IdentityServiceLDAPImpl extends ServiceImpl implements IdentityService 

In some methods may be you can do this:

throw new LDAPOperationNotSupportedException("This action is not implemented under LDAP");

4) Create LDAPUserManagerFactory

public class LDAPUserManagerFactory implements SessionFactory 
{
   @Override
   public Class<?> getSessionType()
       {
      return UserManager.class; 
   }

   @Override
   public Session openSession()
   {
      return new LDAPUserManager();
   }
}


5) Create LDAPGroupManagerFactory

public class LDAPGroupManagerFactory implements SessionFactory 
{
   @Override
   public Class<?> getSessionType()
       {
      return GroupManager.class; 
   }

   @Override
   public Session openSession()
   {
      return new LDAPGroupManager();
   }
}

6) Create your LDAPUserManager implementing your queries to LDAP using you LDAP framework

public class LDAPUserManager extends org.activiti.engine.impl.persistence.entity.UserManager


7) Create your LDAPGroupManager implementing your queries to LDAP using you LDAP framework

public class LDAPGroupManager extends org.activiti.engine.impl.persistence.entity.GroupManager


And I think… that's all folks
17 REPLIES 17

mokematt
Champ in-the-making
Champ in-the-making
The database Schema includes all Tabels except the identity.

Why you touch Activiti db schema?

I want to store the identity data(username, password, permission) in the LDAP and store every other data in the Oracle Database.

Edit: I think i found the problem. Activiti only added the GroupManagerFactory and the UserManagerFactory, so the IdentityService got two Factories and used the first one. That was the default factory.
I implemented my own ProcessEngineConfiguration and replaced the User and Group SessionFactories with my LDAP factories. Now it seems to work as it should.
I have to do some further tests, but here is my ProcessEngineConfiguration:
package pucco.activiti;

import java.util.Map;

import org.activiti.engine.IdentityService;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.impl.ProcessEngineImpl;
import org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration;
import org.activiti.engine.impl.interceptor.SessionFactory;
import org.activiti.engine.impl.persistence.entity.GroupManager;
import org.activiti.engine.impl.persistence.entity.UserManager;

public class CustomProcessEngineConfiguration extends StandaloneProcessEngineConfiguration {
protected IdentityService identityService;
private LDAPConnectionParams connectionParams;

public CustomProcessEngineConfiguration(LDAPConnectionParams connectionParams){
  this.connectionParams = connectionParams;
}

public ProcessEngine buildProcessEngine() {
  this.setIdentityService(new IdentityServiceLDAPImpl(connectionParams));
  init();
  Map<Class< ? >, SessionFactory> sessionFactories = this.getSessionFactories();
  sessionFactories.put(GroupManager.class, new LDAPGroupManagerFactory(connectionParams));
  sessionFactories.put(UserManager.class, new LDAPUserManagerFactory(connectionParams));
  this.setSessionFactories(sessionFactories);
     return new ProcessEngineImpl(this);
   }
}

Edit2: Now the processEngine works as it should. All method calls of IdentityService will result in a connection to the LDAP directory. The loss of the ACT_ID_* tables in the database is also no longer relevant.

mokematt
Champ in-the-making
Champ in-the-making
I implemented an custom ProcessEngineConfiguration to solve my Problem.

public class CustomProcessEngineConfiguration extends StandaloneProcessEngineConfiguration {
protected IdentityService identityService;
private LDAPConnectionParams connectionParams;

public CustomProcessEngineConfiguration(LDAPConnectionParams connectionParams){
  this.connectionParams = connectionParams;
}

public ProcessEngine buildProcessEngine() {
  init();
  Map<Class< ? >, SessionFactory> sessionFactories = this.getSessionFactories();
  sessionFactories.put(GroupManager.class, new LDAPGroupManagerFactory(connectionParams));
  sessionFactories.put(UserManager.class, new LDAPUserManagerFactory(connectionParams));
  this.setSessionFactories(sessionFactories);
  return new ProcessEngineImpl(this);
   }
}

greets
mokematt

sdwilly22
Champ in-the-making
Champ in-the-making
This example is from an older version of Activiti. UserManager has been changed to UserEntityManager. GroupManager has been changed to GroupEntityManager. Does anyone have an example of this working with version 5.12 or 5.13?

frederikherema1
Star Contributor
Star Contributor
5.13 comes with LDAP-support OOTB, you can use this or use the implementation as a base…

This post helped me to solve my problem of integration with 5.13. I will put it here in case anyone else is looking for the same information. http://forums.activiti.org/content/customsessionfactories-activiti-513#comment-18496

rajannavagare
Champ in-the-making
Champ in-the-making
i'm trying to integrate ldap with activiti.



my activiti-custom-context.xml file is as folllows:




<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:jee="http://www.springframework.org/schema/jee" xmlns:aop="http://www.springframework.org/schema/aop"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
       http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
      
  <!– <bean id="dbProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="location" value="classpath:db.properties" />
      <property name="ignoreUnresolvablePlaceholders" value="true" />
   </bean>
   
   <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
      <property name="driverClassName" value="${jdbc.driver}" />
      <property name="url" value="${jdbc.url}" />
      <property name="username" value="${jdbc.username}" />
      <property name="password" value="${jdbc.password}" />
      <property name="defaultAutoCommit" value="false" />
   </bean> –>

   <!–<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
   </bean>–><!– <!–
 
   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="true" />
         <property name="enableDatabaseEventLogging" value="true" />
    <property name="jobExecutorActivate" value="false" />
    <property name="asyncExecutorEnabled" value="true" />
    <property name="asyncExecutorActivate" value="true" />

         <property name="customFormTypes">
           <list>
              <bean class="org.activiti.explorer.form.UserFormType" />
              <bean class="org.activiti.explorer.form.ProcessDefinitionFormType" />
              <bean class="org.activiti.explorer.form.MonthFormType" />
           </list>
         </property>

 
<property name="mailServerHost" value="mail.lodhagroup.com" />
<property name="mailServerPort" value="25" />
<property name="mailServerUseSSL" value="false" />
<property name="mailServerUseTLS" value="true" />
<property name="mailServerDefaultFrom" value="processmaster@lodhagroup.com" />
<property name="mailServerUsername" value="lodha_email@lodhagroup.com" />
<property name="mailServerPassword" value="welcome@123" />
   </bean> –> –>
 
   <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean" destroy-method="destroy">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
   </bean>
 
   <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
   <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
   <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
   <bean id="formService" factory-bean="processEngine" factory-method="getFormService" />
   <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
   <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
   <bean id="identityService" factory-bean="processEngine" factory-method="getIdentityService" />


<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.ldap.LDAPStandaloneProcessEngineConfiguration">
     <!– <property name="customSessionFactories">
        <list>
   <bean class="org.activiti.engine.impl.ldap.LDAPUserManagerFactory" />
            <bean class="org.activiti.engine.impl.ldap.LDAPGroupManagerFactory" />
        </list>
    </property>  –>

  <property name="configurators">
          <list>
              <bean class="org.activiti.ldap.LDAPConfigurator">

                <!– Server connection params –>
                <property name="server" value="ldap://192.168.12.25" />
                <property name="port" value="389" />
                <property name="user" value="cn=Manager,dc=lodhagroup,dc=com" />
                <property name="password" value="*******" />

                <!– Query params –>
                <property name="baseDn" value="o=People" />
                <property name="queryUserByUserId" value="(&(objectClass=inetOrgPerson)(uid={0}))" />
                <property name="queryUserByFullNameLike" value="(&(objectClass=inetOrgPerson)(|({0}=*{1}*)({2}=*{3}*)))" />
                <property name="queryGroupsForUser" value="(&(objectClass=groupOfUniqueNames)(uniqueMember={0}))" />

                <!– Attribute config –>
                 <property name="userIdAttribute" value="uid" />
                <property name="userFirstNameAttribute" value="cn" />
                <property name="userLastNameAttribute" value="sn" />S
                <property name="userEmailAttribute" value="mail" />


                <property name="groupIdAttribute" value="cn" />
                <property name="groupNameAttribute" value="cn" />

              </bean>
          </list>
        </property> 

</bean>
 
</beans>


when i made changes in XML file i'm unable to start Activiti.
error says could not start Activiti explorer.



rajannavagare
Champ in-the-making
Champ in-the-making
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
</bean>
including this in activiti-custom-context.xml
stopping my activiti from running.
it says activiti could not start.

jbarrez
Star Contributor
Star Contributor
We would need more info … stacktraces, errors …to be able to answer your question.