aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpom.xml4
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/LdapImporter.java (renamed from src/main/java/io/trygvis/esper/testing/PersonGenerator.java)19
2 files changed, 13 insertions, 10 deletions
diff --git a/pom.xml b/pom.xml
index 5fe5c03..eba5b45 100755
--- a/pom.xml
+++ b/pom.xml
@@ -204,6 +204,10 @@
<configuration>
<programs>
<program>
+ <name>ldap-importer</name>
+ <mainClass>io.trygvis.esper.testing.LdapImporter</mainClass>
+ </program>
+ <program>
<name>nexus-importer</name>
<mainClass>io.trygvis.esper.testing.nexus.NexusImporter</mainClass>
</program>
diff --git a/src/main/java/io/trygvis/esper/testing/PersonGenerator.java b/src/main/java/io/trygvis/esper/testing/LdapImporter.java
index 28d8438..b29b325 100755
--- a/src/main/java/io/trygvis/esper/testing/PersonGenerator.java
+++ b/src/main/java/io/trygvis/esper/testing/LdapImporter.java
@@ -11,21 +11,21 @@ import java.util.*;
import javax.naming.*;
import javax.naming.directory.*;
-public class PersonGenerator {
+public class LdapImporter {
public static void main(String[] args) throws Exception {
Config config = Config.loadFromDisk("person-generator");
final Logger logger = LoggerFactory.getLogger(config.appName);
- String ldapHost = System.getProperty("ldap.host", "localhost");
- int ldapPort = Integer.parseInt(System.getProperty("ldap.port", "386"));
- String baseDn = System.getProperty("ldap.base");
-
- if(baseDn == null) {
- System.err.println("Missing system property: ldap.base");
- return;
+ if(args.length != 3) {
+ System.err.println("Usage: ldap-importer [ldap host] [ldap port] [base dn]");
+ System.exit(1);
}
+ String ldapHost = args[0];
+ int ldapPort = Integer.parseInt(args[1]);
+ String baseDn = args[2];
+
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
properties.put(Context.PROVIDER_URL, "ldap://" + ldapHost + ":" + ldapPort);
@@ -35,8 +35,7 @@ public class PersonGenerator {
InitialDirContext context = new InitialDirContext(properties);
SearchControls searchCtls = new SearchControls();
searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);
- String returnedAtts[] = {"uid", "mail", "displayName"};
- searchCtls.setReturningAttributes(returnedAtts);
+ searchCtls.setReturningAttributes(new String[]{"uid", "mail", "displayName"});
NamingEnumeration answer = context.search(baseDn, "(&(uid=*)(mail=*)(displayName=*))", searchCtls);
BoneCPDataSource dataSource = config.createBoneCp();