Java tutorial
import java.util.Hashtable; import javax.naming.Context; import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; 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); // Get an attribute of that type Attributes attrs = ctx.getAttributes("cn=YourName, ou=People", new String[] { "cn" }); Attribute cnAttr = attrs.get("cn"); // Get its attribute definition DirContext cnSchema = cnAttr.getAttributeDefinition(); // Get cnSchema's attributes Attributes cnAttrs = cnSchema.getAttributes(""); } }