Hello guys,

I am now trying to add functionality for searching multiple users to our
project. We already have code which returns data for single user. From the
begining it looked quite easy. I will just send request like
(|(uid=user1)(uid=user2)) to LDAP. This actually works and I can see in
karaf.log, that I received data for these two users. 

I am using this converter to pass data to POJO class

    @Converter
    public static LdapPerson toLdapPerson(Collection ldapResult) {

        Iterator<?> resultIterator = ldapResult.iterator();
        SearchResult searchResult = (SearchResult) resultIterator.next();

        Attributes attributes = searchResult.getAttributes();
        Attribute uidAttribute = attributes.get("uid");
        Attribute givenNameAttribute = attributes.get("givenname");
        Attribute snAttribute = attributes.get("sn");
        Attribute cnAttribute = attributes.get("cn");
        Attribute mailAttribute = attributes.get("mail");

        String uid = getAttributeValue(uidAttribute);
        String givenName = getAttributeValue(givenNameAttribute);
        String sn = getAttributeValue(snAttribute);
        String cn = getAttributeValue(cnAttribute);
        String email = getAttributeValue(mailAttribute);

        LdapPerson ldapPerson = new LdapPerson();
        ldapPerson.setUid(uid);
        ldapPerson.setGivenName(givenName);
        ldapPerson.setSurname(sn);
        ldapPerson.setCommonName(cn);
        ldapPerson.setEmail(email);

        return ldapPerson;
    }

For single user it works perfectly, but when I have more then one user, then
it shows data only for the first one. 
When I modified the converter to loop through ldapResult, it was the same,
because I receive only one big message which contains two results. I tried
splitter, but I was getting errors.

This is the message I get:

BodyType:java.util.ArrayList, Body:[uid=user1: null:null:{mail=mail:
us...@company.com, uid=uid: user1, objectclass=objectClass: top, person,
organizationalPerson, inetorgperson, givenname=givenName: user1, sn=sn:
user1,cn=cn: user1 user1}, uid=user2: null:null:{mail=mail:
us...@company.com, uid=uid: user2, objectclass=objectClass: top, person,
organizationalPerson, inetorgperson, givenname=givenName: user2, sn=sn:
user2,cn=cn: user2 user2}]

Thanks for help

-Roman



--
View this message in context: 
http://camel.465427.n5.nabble.com/LDAP-component-search-for-multiple-users-tp5734130.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to