Getting an Object's Schema from the Directory
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
public class Main {
public static void main(String[] argv) throws Exception {
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "yourURL");
DirContext ctx = new InitialDirContext(env);
DirContext tedClasses = ctx.getSchemaClassDefinition("cn=YourName, ou=People");
NamingEnumeration e = tedClasses.search("", null);
while (e.hasMore()) {
DirContext entry = (DirContext) e.next();
System.out.println(entry);
}
}
}
Related examples in the same category