AnsweredAssumed Answered

Java engine and ldap configuration problem

Question asked by rmadaow on Dec 2, 2015
Latest reply on Dec 4, 2015 by rmadaow
Hi,

I have a little problem with ldap configuration under java aplication. After configureing activiti engine and ldap IdentityService do not find existing ldap user. (Given user exists in ldap - i have checked that using DirContext and the same ldap connection properties and queries). Engine need to be created programmatically because some of connection properties are stored in different database.

org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl process = new org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration();
process.setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE);
process.setJdbcDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver");
process.setJdbcUrl("jdbc:sqlserver://"+jdbcHost+";databaseName="+jdbcDatabase);
process.setJdbcUsername(jdbcUser);
process.setJdbcPassword(jdbcPass);
process.setAsyncExecutorEnabled(true);
process.setAsyncExecutorActivate(false);

LDAPConfigurator ldapConfig = new LDAPConfigurator();
//LDAP connection params
ldapConfig.setServer(ldapUrl);
ldapConfig.setPort(lPort);
ldapConfig.setUser(ldapUser);
ldapConfig.setPassword(ldapPass);
ldapConfig.setSecurityAuthentication("simple");
ldapConfig.setInitialContextFactory("com.sun.jndi.ldap.LdapCtxFactory");
ldapConfig.setBaseDn(baseDn);
//Attributes config
ldapConfig.setUserIdAttribute("sAMAccountName");
ldapConfig.setUserFirstNameAttribute("givenName");
ldapConfig.setUserLastNameAttribute("sn");
ldapConfig.setUserEmailAttribute("mail");
ldapConfig.setGroupIdAttribute("cn");
ldapConfig.setGroupNameAttribute("cn");
//Queries
ldapConfig.setQueryUserByUserId("(&(objectClass=user)(sAMAccountName={0}))");
ldapConfig.setQueryGroupsForUser("(&(objectClass=group)(member={0}))");

process.addConfigurator(ldapConfig);
org.activiti.engine.ProcessEngine engine = process.buildProcessEngine();


org.activiti.engine.identity.User user = engine.getIdentityService().createUserQuery().userId(ldapExistingUser).singleResult();
if(user == null){
    System.err.println("User not found");
}else{
    System.out.println(u.getId());
    System.out.println(u.getFirstName());
    System.out.println(u.getLastName());
    System.out.println(u.getEmail());
}



Console output:

[AWT-EventQueue-0] INFO org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl - Found 1 Process Engine Configurators in total:
[AWT-EventQueue-0] INFO org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl - class org.activiti.ldap.LDAPConfigurator (priority:10000)
[AWT-EventQueue-0] INFO org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl - Executing beforeInit() of class org.activiti.ldap.LDAPConfigurator (priority:10000)
[AWT-EventQueue-0] INFO org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl - Executing configure() of class org.activiti.ldap.LDAPConfigurator (priority:10000)
[AWT-EventQueue-0] INFO org.activiti.engine.impl.ProcessEngineImpl - ProcessEngine default created
User not found



I will be grateful for your help and suggestions.

Outcomes