LoadLdap { public static Map<String, Object> getConnectionMap(Object conn) { if (conn instanceof String) { String value = apocConfig().getString("apoc.loadldap" + conn.toString() + ".config"); if (value == null) throw new RuntimeException("No apoc.loadldap."+conn+".config ldap access configuration specified"); Map<String, Object> config = new HashMap<>(); String[] sConf = value.split(" "); config.put("ldapHost", sConf[0]); config.put("loginDN", sConf[1]); config.put("loginPW", sConf[2]); return config; } else { return (Map<String,Object> ) conn; } }  @Procedure(name = "apoc.load.ldap", mode = Mode.READ) @Description("apoc.load.ldap(\"key\" or {connectionMap},{searchMap}) Load entries from an ldap source (yield entry)") Stream<LDAPResult> ldapQuery(@Name("connection") final Object conn, @Name("search") final Map<String,Object> search); static Map<String, Object> getConnectionMap(Object conn);  }
@Test public void testLoadLDAP() throws Exception { Map<String, Object> connParms = new HashMap<>(); connParms.put("ldapHost", "ldap.forumsys.com"); connParms.put("ldapPort", 389l); connParms.put("loginDN", "cn=read-only-admin,dc=example,dc=com"); connParms.put("loginPW", "password"); LoadLdap.LDAPManager mgr = new LoadLdap.LDAPManager(LoadLdap.getConnectionMap(connParms)); Map<String, Object> searchParms = new HashMap<>(); searchParms.put("searchBase", "dc=example,dc=com"); searchParms.put("searchScope", "SCOPE_ONE"); searchParms.put("searchFilter", "(&(objectClass=*)(uid=training))"); ArrayList<String> ats = new ArrayList<>(); ats.add("uid"); searchParms.put("attributes", ats); LDAPSearchResults results = mgr.doSearch(searchParms); LDAPEntry le = results.next(); assertEquals("uid=training,dc=example,dc=com", le.getDN()); assertEquals("training", le.getAttribute("uid").getStringValue()); }