Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

LDAP Query

Posted on 2002-06-03
6
Medium Priority
?
1,898 Views
Last Modified: 2010-05-18
Hello

i am new to LDAP. And we are using openLDAP. I have never written any code to access data from LDAP.
Neither am i sure whether i must use JNDI or JLDAP(from Novell) to pick data from openLDAP.

I have to write a LDAP Query Engine. The functionality is simple. Display onw a web page a set of attributes (available in LDAP) for the user to choose from. Based on attributes the user selected i generate a Query to fetch data for those attributes from LDAP and display them to the user in the form of a report.

I am not sure how to do this. Can anyone give me example code or suggest how to go about doing this.

I only know what entries(objects) and their attributes are present in LDAP.

I am sure in many cases the user choice of attributes too would be invalid i.e it would not make sense to generate query for attributes from two totally unrelated objects etc...

Help !!!
0
Comment
Question by:Jitu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 7

Expert Comment

by:HalldorG
ID: 7065623
There are some modules in perl that I have been using
They work well.
0
 
LVL 1

Expert Comment

by:raid999
ID: 7077720
Lookup.java provides access to LDAP

import java.util.*;
import javax.naming.*;
import javax.naming.directory.*;

public class Lookup {
 public static void main(String args[]) {
   String name = "";
   if ( args.length > 0 ) name = args[0];
   try {
     Hashtable env = new Hashtable();
     env.put("java.naming.factory.initial",
             "com.sun.jndi.ldap.LdapCtxFactory");
     env.put("java.naming.provider.url",
             "ldap://ldap.nameflow.net:1389/");

     DirContext ictx = new InitialDirContext(env);
     Attributes a = ictx.getAttributes(name);
     NamingEnumeration all = a.getAll();
     while ( all.hasMore() ) {
       Attribute attr = (Attribute)all.next();
       System.out.println("Attribute: " + attr.getID());
       NamingEnumeration values = attr.getAll();
       while ( values.hasMore() )
         System.out.println("Value: " + values.next());
     }
   } catch ( Exception e ) {
     System.out.println("Exception: " + e);
   }
 }
}

Compiling and running this Java requires the following libraries

1-jndi.jar
2-ldap.jar
3-providerutil.jar

How to use the lookup.java

unix% java Lookup "ldap://ldap.nameflow.net:1389/cn=Dai Davies,o=DANTE,c=GB"
Attribute: collectiveTelephoneNumber
Value: +44 1223 302992
Attribute: organizationalStatus
Value: General Manager
Attribute: sn
Value: Davies
Attribute: collectivePostalAddress
Value: DANTE $ Francis House $ 112 Hills Road $ Cambridge $ CB2 1PQ $ United Kingdom
Attribute: collectiveStreetAddress
Value: 112 Hills Road
Attribute: mail
Value: Dai.Davies@dante.org.uk
...
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7265841

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
 - PAQ'd and pts removed
Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

Nic;o)
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 1

Author Comment

by:Jitu
ID: 7266587
No suitable answer received. Request the administrator to remove this question if that is alright.
0
 
LVL 54

Expert Comment

by:nico5038
ID: 7266758
Hi Jitu,

Glad you returned, I just missed a comment on the comments given by the two experts. Normally solving a Q is a "co-production" between questionner and expert(s)...

Nic;o)
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7296599
Per recommendation, points NOT refunded and question closed.

Netminder
CS Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question