List of usage examples for javax.naming.directory DirContext getSchema
public DirContext getSchema(String name) throws NamingException;
From source file:CreateJavaSchema.java
void showSchema(DirContext ctx, String[] attrs, String[] ocs) throws NamingException { DirContext attrRoot = (DirContext) ctx.getSchema("").lookup("AttributeDefinition"); printSchema(attrRoot, attrs);/*from w w w . j a v a 2s .co m*/ DirContext ocRoot = (DirContext) ctx.getSchema("").lookup("ClassDefinition"); printSchema(ocRoot, ocs); }
From source file:CreateJavaSchema.java
/** * Updates the schema://from w w w.jav a 2s . c o m * * Delete obsolete attributes: * javaSerializedObject * javaFactoryLocation * javaReferenceAddress * javaFactory * javaClassName * + all the new ones that we're going to add * Add new and updated attributes: * javaSerializedData * javaCodebase * javaClassName * javaClassNames * javaFactory * javaReferenceAddress * javaDoc * * Delete obsolete object classes: * javaNamingReference * javaObject * + all the new ones that we're going to add * Add new and updated object classes: * javaObject * javaSerializedObject * javaMarshalledObject * javaNamingReference */ private void updateSchema(DirContext ctx, String[] attrIDs, String[] ocIDs) throws NamingException { if (activeDirectorySchemaBug) { updateADSchema(ctx); } else { updateAttributes((DirContext) ctx.getSchema("").lookup("AttributeDefinition"), attrIDs); updateObjectClasses((DirContext) ctx.getSchema("").lookup("ClassDefinition"), ocIDs); } System.out.println("Please use your directory server's administration tool to verify"); System.out.println("the correctness of the schema."); }
From source file:org.springframework.ldap.odm.tools.SchemaToJava.java
private static ObjectSchema readSchema(String url, String user, String pass, SyntaxToJavaClass syntaxToJavaClass, Set<String> binarySet, Set<String> objectClasses) throws NamingException, ClassNotFoundException { // Set up environment Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.PROVIDER_URL, url); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); if (user != null) { env.put(Context.SECURITY_PRINCIPAL, user); }/*from w w w . jav a 2s. com*/ if (pass != null) { env.put(Context.SECURITY_CREDENTIALS, pass); } DirContext context = new InitialDirContext(env); DirContext schemaContext = context.getSchema(""); SchemaReader reader = new SchemaReader(schemaContext, syntaxToJavaClass, binarySet); ObjectSchema schema = reader.getObjectSchema(objectClasses); if (LOG.isDebugEnabled()) { LOG.debug(String.format("Schema - %1$s", schema.toString())); } return schema; }