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 ) ; } 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 ; }
Bind to the directory read and process the schema