I need to insert bulk data into the LDAP server for this I used LdapTestUtils class but got some error
Gradle dependencies
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-ldap'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testCompile group: 'org.springframework.ldap', name: 'spring-ldap-test', version: '2.3.2.RELEASE'
}
Java code
public static void loadData() throws Exception
{
// Bind to the directory
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://127.0.0.1:10389");
contextSource.setUserDn("uid=admin,ou=system");
contextSource.setPassword("secret");
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
// Create the Sprint LDAP template
LdapTemplate template = new LdapTemplate(contextSource);
// Clear out any old data - and load the test data
LdapTestUtils.clearSubContexts(contextSource, LdapUtils.newLdapName("dc=example,dc=com"));
LdapTestUtils.loadLdif(contextSource, new ClassPathResource("schema.ldif"));
}
Link - https://www.programcreek.com/java-api-examples/index.php?api=org.springframework.ldap.test.LdapTestUtils first example
Error - org.apcahe.directory.server.core can not be resolve it is indirectly referred from require.class file
What dependency am i missing? Is there any other way to do so?
public static void loadData() throws Exception
{
// Bind to the directory
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://127.0.0.1:10389");
contextSource.setUserDn("uid=admin,ou=system");
contextSource.setPassword("secret");
contextSource.setPooled(false);
contextSource.afterPropertiesSet();
// Create the Sprint LDAP template
LdapTemplate template = new LdapTemplate(contextSource);
// Clear out any old data - and load the test data
LdapTestUtils.cleanAndSetup(
contextSource,
LdapUtils.newLdapName("dn to remove"),
new ClassPathResource("schema.ldif"));
}
cleanAndSetup method works for me but it will restart server as well