directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Harris, Christopher P" <>
Subject RE: Proper use of LdapConnectionPool
Date Mon, 02 Feb 2015 22:32:32 GMT
O.K.  I can try that.

However, this issue is reproducible in Apache Directory Studio for me.

 - Chris

-----Original Message-----
From: Emmanuel Lécharny [] 
Sent: Monday, February 02, 2015 4:22 PM
Subject: Re: Proper use of LdapConnectionPool

Le 02/02/15 21:28, Harris, Christopher P a écrit :
> Hi, Emmanuel.
> Do you have any updates on this issue?

Sorry, was busy the last few days...

Here are my findings :

Basically, it works. I have used a slightly different version of the code :

    public void searchLdapUsingHybridApproach()
        SearchCursor cursor = new SearchCursorImpl( null, 30000, TimeUnit.SECONDS );
        Entry entry = null;

            SearchRequest sr = new SearchRequestImpl();
            sr.setBase( new Dn( "ou=system" ) );
            sr.setFilter( "(ObjectClass=*)" );
            sr.setScope( SearchScope.SUBTREE );
            cursor = sr );
            Response response;

            while ( && cursor.isEntry() )
                response = cursor.get();
                System.out.println( ( ( SearchResultEntry ) response
).getEntry() );
                entry = cursor.getEntry();
        catch ( LdapException ex )
        catch ( CursorException ex )
            catch ( IOException ex )

just to check that ther API returns the correct entries in the various cases (OBJECT, ONELEVEL
and SUBTREE). It does.

So now, here is my hypothesys : there is a bug in the EntryMapper.

When I run the code using the EntryMapper, I get a NPE because the EntryMapper tries to do
that :

                public Person map( Entry entry ) throws LdapException
                        return new Person.Builder()
                            .setDistinguishedName( entry.getDn().getName() )
                            .setFirstName( entry.get( "givenName"
).getString() )   <---- NPE here because I have no givenName in the
entry I'm reading
                            .setLastName( entry.get( "sn" ).getString() )
                            .setTitle( entry.get( "title" ).getString() )
                            .setDepartment( entry.get( "department"
).getString() )
                            .setDivision( entry.get( "extensionAttribute14" ).getString()
                            .setCity( entry.get( "l" ).getString() )
                            .setCountry( entry.get( "co" ).getString() )
                            .setEmail( ( entry.get( "mail" ) != null ) ?
entry.get( "mail" ).getString() : "" )
                            .setDeskLocation( entry.get( "postOfficeBox"
).getString() )
                                ( entry.get( "telephoneNumber" ) != null
) ? entry.get( "telephoneNumber" ).getString()
                                    : "" )
                            .setDirectReports( entry.get( "directreports" ) )

So my guess is that in your case your entry is missing some of the expected attribute, and
this is why you get no result.

Can you chack that by printing the entry just hafter having pulled it from the LDAP server

Thanks !

The information transmitted is intended only for the person(s) or entity to which it is addressed
and may contain confidential and/or legally privileged material. Delivery of this message
to any person other than the intended recipient(s) is not intended in any way to waive privilege
or confidentiality. Any review, retransmission, dissemination or other use of, or taking of
any action in reliance upon, this information by entities other than the intended recipient
is prohibited. If you receive this in error, please contact the sender and delete the material
from any computer.

For Translation:
View raw message