Results 1 to 6 of 6

Thread: search problem: search by c = sth.

  1. #1
    Join Date
    Jun 2007
    Location
    Beijing, China
    Posts
    8

    Wink search problem: search by c = sth.

    Hi All,

    there is a problem about searching items.

    if I have these two persons in my ldap DB
    "cn=Some Person2,ou=company1,c=Sweden,dc=example,dc=com"
    "cn=Some Person,ou=company2,c=Sweden,dc=example,dc=com"

    how could i find them all by c=Sweden? it means how could i find person and person2 by their country name Sweden? And how to implement in coding?

    thanks in advance!

  2. #2
    Join Date
    Mar 2005
    Location
    Landskrona, Sweden
    Posts
    505

    Default

    In this case you'd need to use the search base to specify where in the tree to start the search, i.e.:
    Code:
    DistinguishedName dn = new DistinguishedName();
    dn.add("c", "Sweden");
    
    return ldapTemplate.search(dn, "(objectclass=person)", new AttributesMapper(){...});
    Note that the above depends on that the ContextSource base is set to
    Code:
    dc=example,dc=com
    Also note that if you'd want to find persons based on company, i.e. ou=company1 regardless of which country the solution would be much more complicated. In that case you'd need to first find all the matching companies and then loop over these and find the corresponding persons based on each respective company's DN, as in the example above.
    Mattias Arthursson
    Jayway AB (www.jayway.se)
    Spring-LDAP project member

  3. #3
    Join Date
    Jun 2007
    Location
    Beijing, China
    Posts
    8

    Thumbs up use the search base to specify where in the tree to start the search

    Thanks a lot, rasky!
    I got ur idea about use the search base to specify where in the tree to start the search, and i tried. It works now!
    Also thanks about the company based search idea!~

  4. #4
    Join Date
    Sep 2007
    Posts
    2

    Default Spring- LDAP ldaptemplate

    Hi,
    When I am using new AttributeMapper while doing ldaptemplate.search it is throwing an error message saying 'cannot instaniate AttributesMapper'. Can anyone help me . Below is the code, I am wirting.

    return ldapTemplate.search("", filter.encode(),new AttributesMapper()).

    I appreciate if anyone can help me soon

    Thanks
    Prasad

  5. #5
    Join Date
    Mar 2005
    Location
    Landskrona, Sweden
    Posts
    505

    Default

    AttributesMapper is an interface. You'll need to supply an implementation of that.
    Mattias Arthursson
    Jayway AB (www.jayway.se)
    Spring-LDAP project member

  6. #6
    Join Date
    Sep 2007
    Posts
    2

    Default Using Spring LDAPTemplate for searching on multiple users ids simultaneously

    Can anyone help me in reading LDAP using spring LDAPTemplate to search using multiple user ids simultaneously. I am trying to sync data in a database table from LDAP for all the user ids on a timely fashion.


    Any help is really appreciated


    Thanks
    Prasad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •