【发布时间】:2020-11-01 01:02:58
【问题描述】:
我在测试中使用 spring-ldap-test(2.3.3)。配置:
@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());
}
}
这是 appication.yml 文件:
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
因此,当我尝试使用“posixAccount”对象类保存实体时,会发生错误,因为“m-disabled”参数在 cn = nis, ou = schema 中设置为 TRUE,这不是为我定义的,并且我无法通过 Spring 更改此设置。
如何动态改变它?(((
实体:
@Entry(objectClasses = {"inetOrgPerson","top","posixAccount"})
public final class Person {
...................................
}
错误,顺便说一句:
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
【问题讨论】:
标签: java spring testing ldap schema