Example usage for javax.naming.directory Attribute getAttributeDefinition

List of usage examples for javax.naming.directory Attribute getAttributeDefinition

Introduction

In this page you can find the example usage for javax.naming.directory Attribute getAttributeDefinition.

Prototype

DirContext getAttributeDefinition() throws NamingException;

Source Link

Document

Retrieves the attribute's schema definition.

Usage

From source file:Main.java

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("");
}