code: private void createObjectClass(Set<String> objectClasses, DirContext schemaContext, ObjectSchema schema)
              throws NamingException, ClassNotFoundException {
  
          // Super classes
          Set<String> supList = new HashSet<String>();
  
          // For each of the given object classes
          for (String objectClass : objectClasses) {
              // Add to set of included object classes
              schema.addObjectClass(objectClass);
              
              // Grab the LDAP schema of the object class
              Attributes attributes = schemaContext.getAttributes("ClassDefinition/" + objectClass);
              NamingEnumeration<? extends Attribute> valuesEnumeration = attributes.getAll();
  
              // Loop through each of the attributes
              while (valuesEnumeration.hasMoreElements()) {
                  Attribute currentAttribute = valuesEnumeration.nextElement();
  
                  // Get the attribute name and lower case it (as this is all case indep)
                  String currentId = currentAttribute.getID().toUpperCase();
                  
                  // Is this a MUST, MAY or SUP attribute
                  SchemaAttributeType type = getSchemaAttributeType(currentId);
  
                  // Loop through all the values
                  NamingEnumeration<?> currentValues = currentAttribute.getAll();
                  while (currentValues.hasMoreElements()) {
                      String currentValue = (String)currentValues.nextElement();
                      switch (type) {
                          case SUP:
                              // Its a super class
                              String lowerCased=currentValue.toLowerCase();
                              if (!schema.getObjectClass().contains(lowerCased)) {
                                  supList.add(lowerCased);
                              }
                              break;
                          case MUST:
                              // Add must attribute
                              schema.addMust(createAttributeSchema(currentValue, schemaContext));
                              break;
                          case MAY:
                              // Add may attribute
                              schema.addMay(createAttributeSchema(currentValue, schemaContext));
                              break;
                          default:
                              // Nothing to do
                      }
                  }
              }
  
              // Recurse for super classes
              createObjectClass(supList, schemaContext, schema);
          }
      }
docs: Recursively extract schema from the directory and process it