samedi 24 octobre 2020

'Spring Tests. I cannot use posixAccount objectClass in ldap as its use is disabled in the schema

I use spring-ldap-test(2.3.3) in tests. Configurations:

@TestConfiguration
@TestPropertySource("classpath:application.yml")
@EnableAutoConfiguration(exclude = {ConsulAutoConfiguration.class,
        AutoServiceRegistrationAutoConfiguration.class,
        ConsulServiceRegistryAutoConfiguration.class,
        ConsulCatalogWatchAutoConfiguration.class,
        ConsulAutoServiceRegistrationAutoConfiguration.class,
})
public class TestConfigurations {

@Autowired
private Environment env;
@Autowired
private ResourceLoader resourceLoader;



@Primary
@Bean
public TestContextSourceFactoryBean testContextSource() {
    TestContextSourceFactoryBean contextSource = new TestContextSourceFactoryBean();
    contextSource.setDefaultPartitionName(env.getRequiredProperty("ldap.partition"));
    contextSource.setDefaultPartitionSuffix(env.getRequiredProperty("ldap.partitionSuffix"));
    contextSource.setPrincipal(env.getRequiredProperty("ldap.principal"));
    contextSource.setPassword(env.getRequiredProperty("ldap.password"));
    contextSource.setLdifFile(resourceLoader.getResource(env.getRequiredProperty("ldap.ldiffile")));
    contextSource.setPort(Integer.parseInt(env.getRequiredProperty("ldap.port")));
    return contextSource;
}


@Bean
public LdapTemplate ldapTemplate() throws Exception {
    return new LdapTemplate((ContextSource) testContextSource().getObject());
}




}

this is appication.yml file:

ldap:
  partitionSuffix: dc=example,dc=com
  partition: example
  principal: uid=admin,ou=system
  password: secret
  ldiffile: classpath:/test.ldif
  port: 18888
  url: ldap://localhost:18888

So when I try to save the entity using the "posixAccount" object class, an error occurs because the "m-disabled" parameter is set to TRUE in cn = nis, ou = schema, which is not defined for me and I cannot access to changing this setting via Spring.

How can I dynamically change it?(((

entity:

@Entry(objectClasses = {"inetOrgPerson","top","posixAccount"})
public final class Person {
...................................
}

error, by the way:

 objectClass posixaccount w/ OID 1.3.6.1.1.1.2.0 not registered!
Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: [LDAP: error code 54 - LOOP_DETECT

Aucun commentaire:

Enregistrer un commentaire