Improving Efficiency for LDAP Search


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Improving Efficiency for LDAP Search

  1. #1
    Join Date
    Jun 2004
    Posts
    1

    Improving Efficiency for LDAP Search

    I am working to improve the response time to search a record (User Name ) from LDAP. There is a JSP(web application) page which automatically populates the user name when users logs in with the ID and password.

    The record (name) picked is coming right but as there are some 120 thousand records so its taking around 30 seconds to load the page which is very slow.

    Is there some way through which we can filter and index the search that it reaches very close to the required result in short time.

    Currently the function we are using is as below.

    the record is serched based on the "oracleid" which is 8 digit number.



    public String getUserFullName(String s) {
    String s1 = "";

    try {
    SearchControls searchcontrols = new SearchControls();
    searchcontrols.setSearchScope(2);
    searchcontrols.setReturningAttributes(new String[] {
    "givenname", "initials", "sn", "oracleid"
    });
    String s2 = "georaclehrid=".concat(String.valueOf(String.valueOf(s)));

    // NamingEnumeration namingenumeration = ctx.search("o=worker", s2, searchcontrols);

    NamingEnumeration namingenumeration = ctx.search("ou=worker,o=xx.com", s2, searchcontrols);
    do {
    if(!namingenumeration.hasMore())
    break;
    SearchResult searchresult = (SearchResult)namingenumeration.next();
    Attributes attributes = searchresult.getAttributes();

    Attribute attribute = attributes.get("sn");

    if(attribute != null && attribute.get() != null)
    s1 = String.valueOf(s1) + String.valueOf(String.valueOf(String.valueOf((String)attribute.get())).concat(", "));
    attribute = attributes.get("givenname");
    if(attribute != null && attribute.get() != null)
    s1 = String.valueOf(s1) + String.valueOf(String.valueOf(String.valueOf((String)attribute.get())).concat(" "));
    } while(true);

    }
    catch(NamingException namingexception) {
    System.out.println(namingexception);
    }
    if(s1.length() > 0)
    return s1.trim();
    else
    return " ";
    }

  2. #2
    Join Date
    Jun 2004
    Posts
    199
    have you put logging in to determine which line of code (or lines) is the source of the problem.

    LDAP datasources are slow. You might need to

    1. Get your code closer to the datasource.
    2. Get a faster server.
    3. Get a faster client.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center