This time with attachments :) On Mon, Feb 10, 2020 at 03:32:36PM -0600, Lucas Raab wrote: > Hello, > > I'm getting NPE's while attempting to read from a fresh AD install with > a 2012R2 level domain. If I don't load the schema (relaxed or strict), > the search runs normally. if I do load the schema, then the search > throws the NPE. No error is thrown when I attempted similar searches > against an OpenDJ 6.5 server. > > It appears to come from attempting to determine if an LdapSyntax from > an AttributeType is human readable or not. The LdapSyntax object looks > to be null, but is visible when dumping the AttributeType. I'm not > entirely sure where the schema-aware attribute loading is happening to > try and fix it myself so here I am :) > > Attached is a log and sample source file. I can provide credentials in > a private mail for any debugging. > > Thanks, > Lucas
package com.example;
import org.apache.directory.api.ldap.model.cursor.CursorException; import org.apache.directory.api.ldap.model.cursor.SearchCursor; import org.apache.directory.api.ldap.model.entry.Entry; import org.apache.directory.api.ldap.model.exception.LdapException; import org.apache.directory.api.ldap.model.exception.LdapURLEncodingException; import org.apache.directory.api.ldap.model.message.*; import org.apache.directory.api.ldap.model.name.Dn; import org.apache.directory.api.ldap.model.schema.*; import org.apache.directory.api.ldap.model.schema.registries.AttributeTypeRegistry; import org.apache.directory.api.ldap.model.schema.registries.ObjectClassRegistry; import org.apache.directory.api.ldap.model.schema.registries.Schema; import org.apache.directory.api.ldap.model.url.LdapUrl; import org.apache.directory.ldap.client.api.LdapConnection; import org.apache.directory.ldap.client.api.LdapNetworkConnection; import java.io.IOException; import java.util.Collection; public class Main { public static void main(String[] args) throws LdapException, IOException { LdapUrl test = new LdapUrl("ldaps://dc1.example.com/DC=example,DC=com?cn?sub?(objectClass=person)"); LdapConnection connection = new LdapNetworkConnection( "dc1.example.com", 636, true ); System.out.println("Built connection"); int i = 0; System.out.println("Attempting to bind"); try { //connection.anonymousBind(); connection.bind("user_dn", "testtest"); System.out.println("Connection bound"); connection.loadSchemaRelaxed(); System.out.println("Loaded schema"); SearchRequest req = new SearchRequestImpl(); req.setScope(test.getScope()); for (String a : test.getAttributes()) { req.addAttributes(a); } req.setTimeLimit(0); req.setBase(test.getDn()); req.setFilter(test.getFilter()); try (SearchCursor searchCursor = connection.search(req)) { while (searchCursor.next()) { i++; Response response = searchCursor.get(); if (response instanceof SearchResultEntry) { Entry resultEntry = ((SearchResultEntry) response).getEntry(); System.out.println(resultEntry.get("cn")); } } } } catch (LdapException | NullPointerException | CursorException e) { e.printStackTrace(); } finally { System.out.println(String.format("Got %d entries", i)); connection.unBind(); //connection.close(); } } }
--------------------------------------------------------------------- To unsubscribe, e-mail: api-unsubscr...@directory.apache.org For additional commands, e-mail: api-h...@directory.apache.org