[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Ldap Schema question
Hi all,
I've got problem retreiving ldap schema via Java. This is the source code of
Java File:
import javax.naming.*;
import javax.naming.directory.*;
import java.util.Hashtable;
class GetSchema {
public static void main(String[] args) {
// Set up environment for creating initial context
Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,
"ldap://*******************:389/o=*****");
env.put(Context.SECURITY_PRINCIPAL,"cn=*********,o=******");
env.put(Context.SECURITY_CREDENTIALS,"*********");
try {
// Create the initial context
DirContext ctx = new InitialDirContext(env);
// Get the schema tree root
DirContext schema = ctx.getSchema("ou=Payroll");
// List contents of root
NamingEnumeration bds = schema.list("");
while (bds.hasMore()) {
System.out.println(((NameClassPair)(bds.next())).getName());
}
// Close the context when we're done
ctx.close();
} catch (NamingException e) {
e.printStackTrace();
}
}
}
Compile and this is the result also if the entry is present in the Directory
Server:
javax.naming.NameNotFoundException : [LDAP : Error Code 32 - No such object]
Thanks for your help.
Davide Colombo
dcolombo@matrix.it