File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes LDAP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "LDAP" Watch "LDAP" New topic
Author

LDAP

Alan Jackson
Greenhorn

Joined: Oct 26, 2004
Posts: 26
Just a quick question about accessing an ldap server.

Im trying to list all the attributes from a server. The address of the one Ive been using is "ldap://ldap.utexas.edu/o=The University of Texas at Austin,c=US"

My code access te server but only lists the first element (which is an ou). How do you either count the attributes in the server or keep going until all have been listed? My code is below. Id really appreciate a response.

while (answer.hasMoreElements()) {

SearchResult sr = (SearchResult)answer.next();
System.out.println("\n>>>" + sr.getName());
this.displayJTextArea.setText(displayJTextArea.getText() + "\n" + sr.getName());
//printAttrs(sr.getAttributes());

if (sr.getAttributes() == null) {
System.out.println("No attributes");
this.displayJTextArea.setText(displayJTextArea.getText() + "\n" + "No attributes");
} else {
try {
NamingEnumeration ae = sr.getAttributes().getAll();
while (ae.hasMore()) {
Attribute attr = (Attribute)ae.next();
System.out.println("ATTRIBUTE: " + attr.getID());
this.displayJTextArea.setText(displayJTextArea.getText() + "\n" + "ATTRIBUTE: " + attr.getID());

NamingEnumeration e = attr.getAll();
while (e.hasMore()) {
System.out.println("value: " + e.next());
this.displayJTextArea.setText(displayJTextArea.getText() + "\n" + "value: " + e.next());
}
}
} catch (NamingException e) {
e.printStackTrace();
}
}


}
Anurag Mishra
Ranch Hand

Joined: Sep 27, 2001
Posts: 133
Store all the elements in HashMap as a key value pair, and then retrieve it 1 by 1.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"anumishra1",
Please see the thread here to prevent your account being deleted.

David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LDAP