aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-01-15 13:36:03 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-01-15 13:36:03 +0100
commit4e75fdc85ff2a9e04d1820a3a2f8dc62e431295b (patch)
tree4bd11b5f25d51f173786174e16d1ffafb703ed89 /src/main
parent829097ddaa118c0283c7e2191f9afeb241fa195b (diff)
downloadesper-testing-4e75fdc85ff2a9e04d1820a3a2f8dc62e431295b.tar.gz
esper-testing-4e75fdc85ff2a9e04d1820a3a2f8dc62e431295b.tar.bz2
esper-testing-4e75fdc85ff2a9e04d1820a3a2f8dc62e431295b.tar.xz
esper-testing-4e75fdc85ff2a9e04d1820a3a2f8dc62e431295b.zip
o Renaming PersonGenerator to LdapImporter. Taking arguments from args instead of system properties.
Diffstat (limited to 'src/main')
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/LdapImporter.java (renamed from src/main/java/io/trygvis/esper/testing/PersonGenerator.java)19
1 files changed, 9 insertions, 10 deletions
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();