Java Code Examples for org.apache.directory.api.ldap.model.ldif.LdifReader#close()

The following examples show how to use org.apache.directory.api.ldap.model.ldif.LdifReader#close() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LdapService.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Import all of the entries from the provided LDIF stream.
 *
 * Note: The whole stream is read
 *
 * @param ldif - Stream containing the LDIF.
 * @return This Builder for subsequent changes.
 */
public Builder importLdif(final InputStream ldif) throws Exception {
    assertNotStarted();
    if (directoryService == null) {
        throw new IllegalStateException("The Directory service has not been created.");
    }
    CoreSession adminSession = directoryService.getAdminSession();
    SchemaManager schemaManager = directoryService.getSchemaManager();

    LdifReader ldifReader = new LdifReader(ldif);
    for (LdifEntry ldifEntry : ldifReader) {
        adminSession.add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
    }
    ldifReader.close();
    ldif.close();

    return this;
}
 
Example 2
Source File: InMemorySchemaPartition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Partition initialization - loads schema entries from the files on classpath.
 *
 * @see org.apache.directory.server.core.partition.impl.avl.AvlPartition#doInit()
 */
@Override
protected void doInit() throws Exception {
    if (initialized)
        return;

    LOG.debug("Initializing schema partition " + getId());
    suffixDn.apply(schemaManager);
    super.doInit();

    // load schema
    final Map<String, Boolean> resMap = ResourceMap.getResources(Pattern.compile("schema[/\\Q\\\\E]ou=schema.*"));
    for (String resourcePath : new TreeSet<String>(resMap.keySet())) {
        if (resourcePath.endsWith(".ldif")) {
            URL resource = DefaultSchemaLdifExtractor.getUniqueResource(resourcePath, "Schema LDIF file");
            LdifReader reader = new LdifReader(resource.openStream());
            LdifEntry ldifEntry = reader.next();
            reader.close();

            Entry entry = new DefaultEntry(schemaManager, ldifEntry.getEntry());
            // add mandatory attributes
            if (entry.get(SchemaConstants.ENTRY_CSN_AT) == null) {
                entry.add(SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString());
            }
            if (entry.get(SchemaConstants.ENTRY_UUID_AT) == null) {
                entry.add(SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString());
            }
            AddOperationContext addContext = new AddOperationContext(null, entry);
            super.add(addContext);
        }
    }
}
 
Example 3
Source File: LdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadAttributeTypes( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> attributeTypeList = new ArrayList<>();

    if ( schemas == null )
    {
        return attributeTypeList;
    }

    for ( Schema schema : schemas )
    {
        // check that the attributeTypes directory exists for the schema
        File attributeTypesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.ATTRIBUTE_TYPES_PATH );

        if ( !attributeTypesDirectory.exists() )
        {
            return attributeTypeList;
        }

        // get list of attributeType LDIF schema files in attributeTypes
        File[] attributeTypeFiles = attributeTypesDirectory.listFiles( ldifFilter );

        if ( attributeTypeFiles != null )
        {
            for ( File ldifFile : attributeTypeFiles )
            {
                LdifReader reader = new LdifReader( ldifFile );
                LdifEntry entry = reader.next();
                reader.close();

                attributeTypeList.add( entry.getEntry() );
            }
        }
    }

    return attributeTypeList;
}
 
Example 4
Source File: LdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> objectClassList = new ArrayList<>();

    if ( schemas == null )
    {
        return objectClassList;
    }

    for ( Schema schema : schemas )
    {
        // get objectClasses directory, check if exists, return if not
        File objectClassesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.OBJECT_CLASSES_PATH );

        if ( !objectClassesDirectory.exists() )
        {
            return objectClassList;
        }

        // get list of objectClass LDIF files from directory and load
        File[] objectClassFiles = objectClassesDirectory.listFiles( ldifFilter );

        if ( objectClassFiles != null )
        {
            for ( File ldifFile : objectClassFiles )
            {
                LdifReader reader = new LdifReader( ldifFile );
                LdifEntry entry = reader.next();
                reader.close();

                objectClassList.add( entry.getEntry() );
            }
        }
    }

    return objectClassList;
}
 
Example 5
Source File: LdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadNormalizers( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> normalizerList = new ArrayList<>();

    if ( schemas == null )
    {
        return normalizerList;
    }

    for ( Schema schema : schemas )
    {
        File normalizersDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.NORMALIZERS_PATH );

        if ( !normalizersDirectory.exists() )
        {
            return normalizerList;
        }

        File[] normalizerFiles = normalizersDirectory.listFiles( ldifFilter );

        if ( normalizerFiles != null )
        {
            for ( File ldifFile : normalizerFiles )
            {
                LdifReader reader = new LdifReader( ldifFile );
                LdifEntry entry = reader.next();
                reader.close();

                normalizerList.add( entry.getEntry() );
            }
        }
    }

    return normalizerList;
}
 
Example 6
Source File: LdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadSyntaxCheckers( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> syntaxCheckerList = new ArrayList<>();

    if ( schemas == null )
    {
        return syntaxCheckerList;
    }

    for ( Schema schema : schemas )
    {
        File syntaxCheckersDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.SYNTAX_CHECKERS_PATH );

        if ( !syntaxCheckersDirectory.exists() )
        {
            return syntaxCheckerList;
        }

        File[] syntaxCheckerFiles = syntaxCheckersDirectory.listFiles( ldifFilter );

        if ( syntaxCheckerFiles != null )
        {
            for ( File ldifFile : syntaxCheckerFiles )
            {
                LdifReader reader = new LdifReader( ldifFile );
                LdifEntry entry = reader.next();
                reader.close();

                syntaxCheckerList.add( entry.getEntry() );
            }
        }
    }

    return syntaxCheckerList;
}
 
Example 7
Source File: LdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadComparators( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> comparatorList = new ArrayList<>();

    if ( schemas == null )
    {
        return comparatorList;
    }

    for ( Schema schema : schemas )
    {
        File comparatorsDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.COMPARATORS_PATH );

        if ( !comparatorsDirectory.exists() )
        {
            return comparatorList;
        }

        File[] comparators = comparatorsDirectory.listFiles( ldifFilter );

        if ( comparators != null )
        {
            for ( File ldifFile : comparators )
            {
                LdifReader reader = new LdifReader( ldifFile );
                LdifEntry entry = reader.next();
                reader.close();

                comparatorList.add( entry.getEntry() );
            }
        }
    }

    return comparatorList;
}
 
Example 8
Source File: JarLdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadObjectClasses( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> objectClassList = new ArrayList<>();

    if ( schemas == null )
    {
        return objectClassList;
    }

    for ( Schema schema : schemas )
    {
        // get objectClasses directory, check if exists, return if not
        String start = getSchemaDirectoryString( schema )
            + SchemaConstants.OBJECT_CLASSES_PATH + "/" + "m-oid=";
        String end = "." + LDIF_EXT;

        for ( String resourcePath : RESOURCE_MAP.keySet() )
        {
            if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) )
            {
                URL resource = getResource( resourcePath, "objectClass LDIF file" );
                LdifReader reader = new LdifReader( resource.openStream() );
                LdifEntry entry = reader.next();
                reader.close();

                objectClassList.add( entry.getEntry() );
            }
        }
    }

    return objectClassList;
}
 
Example 9
Source File: JarLdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadDitStructureRules( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> ditStructureRuleList = new ArrayList<>();

    if ( schemas == null )
    {
        return ditStructureRuleList;
    }

    for ( Schema schema : schemas )
    {
        String start = getSchemaDirectoryString( schema )
            + SchemaConstants.DIT_STRUCTURE_RULES_PATH + "/" + "m-oid=";
        String end = "." + LDIF_EXT;

        for ( String resourcePath : RESOURCE_MAP.keySet() )
        {
            if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) )
            {
                URL resource = getResource( resourcePath, "ditStructureRule LDIF file" );
                LdifReader reader = new LdifReader( resource.openStream() );
                LdifEntry entry = reader.next();
                reader.close();

                ditStructureRuleList.add( entry.getEntry() );
            }
        }
    }

    return ditStructureRuleList;
}
 
Example 10
Source File: JarLdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadDitContentRules( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> ditContentRulesList = new ArrayList<>();

    if ( schemas == null )
    {
        return ditContentRulesList;
    }

    for ( Schema schema : schemas )
    {
        String start = getSchemaDirectoryString( schema )
            + SchemaConstants.DIT_CONTENT_RULES_PATH + "/" + "m-oid=";
        String end = "." + LDIF_EXT;

        for ( String resourcePath : RESOURCE_MAP.keySet() )
        {
            if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) )
            {
                URL resource = getResource( resourcePath, "ditContentRule LDIF file" );
                LdifReader reader = new LdifReader( resource.openStream() );
                LdifEntry entry = reader.next();
                reader.close();

                ditContentRulesList.add( entry.getEntry() );
            }
        }
    }

    return ditContentRulesList;
}
 
Example 11
Source File: JarLdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> matchingRuleUseList = new ArrayList<>();

    if ( schemas == null )
    {
        return matchingRuleUseList;
    }

    for ( Schema schema : schemas )
    {
        String start = getSchemaDirectoryString( schema )
            + SchemaConstants.MATCHING_RULE_USE_PATH + "/" + "m-oid=";
        String end = "." + LDIF_EXT;

        for ( String resourcePath : RESOURCE_MAP.keySet() )
        {
            if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) )
            {
                URL resource = getResource( resourcePath, "matchingRuleUse LDIF file" );
                LdifReader reader = new LdifReader( resource.openStream() );
                LdifEntry entry = reader.next();
                reader.close();

                matchingRuleUseList.add( entry.getEntry() );
            }
        }
    }

    return matchingRuleUseList;
}
 
Example 12
Source File: LdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadMatchingRuleUses( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> matchingRuleUseList = new ArrayList<>();

    if ( schemas == null )
    {
        return matchingRuleUseList;
    }

    for ( Schema schema : schemas )
    {
        File matchingRuleUsesDirectory = new File( getSchemaDirectory( schema ),
            SchemaConstants.MATCHING_RULE_USE_PATH );

        if ( !matchingRuleUsesDirectory.exists() )
        {
            return matchingRuleUseList;
        }

        File[] matchingRuleUseFiles = matchingRuleUsesDirectory.listFiles( ldifFilter );

        if ( matchingRuleUseFiles != null )
        {
            for ( File ldifFile : matchingRuleUseFiles )
            {
                LdifReader reader = new LdifReader( ldifFile );
                LdifEntry entry = reader.next();
                reader.close();

                matchingRuleUseList.add( entry.getEntry() );
            }
        }
    }

    return matchingRuleUseList;
}
 
Example 13
Source File: LdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadDitStructureRules( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> ditStructureRuleList = new ArrayList<>();

    if ( schemas == null )
    {
        return ditStructureRuleList;
    }

    for ( Schema schema : schemas )
    {
        File ditStructureRulesDirectory = new File( getSchemaDirectory( schema ),
            SchemaConstants.DIT_STRUCTURE_RULES_PATH );

        if ( !ditStructureRulesDirectory.exists() )
        {
            return ditStructureRuleList;
        }

        File[] ditStructureRuleFiles = ditStructureRulesDirectory.listFiles( ldifFilter );

        if ( ditStructureRuleFiles != null )
        {
            for ( File ldifFile : ditStructureRuleFiles )
            {
                LdifReader reader = new LdifReader( ldifFile );
                LdifEntry entry = reader.next();
                reader.close();

                ditStructureRuleList.add( entry.getEntry() );
            }
        }
    }

    return ditStructureRuleList;
}
 
Example 14
Source File: JarLdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadNormalizers( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> normalizerList = new ArrayList<>();

    if ( schemas == null )
    {
        return normalizerList;
    }

    for ( Schema schema : schemas )
    {
        String start = getSchemaDirectoryString( schema )
            + SchemaConstants.NORMALIZERS_PATH + "/" + "m-oid=";
        String end = "." + LDIF_EXT;

        for ( String resourcePath : RESOURCE_MAP.keySet() )
        {
            if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) )
            {
                URL resource = getResource( resourcePath, "normalizer LDIF file" );
                LdifReader reader = new LdifReader( resource.openStream() );
                LdifEntry entry = reader.next();
                reader.close();

                normalizerList.add( entry.getEntry() );
            }
        }
    }

    return normalizerList;
}
 
Example 15
Source File: InMemorySchemaPartition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Partition initialization - loads schema entries from the files on classpath.
 *
 * @see org.apache.directory.server.core.partition.impl.avl.AvlPartition#doInit()
 */
@Override
protected void doInit() throws Exception {
    if (initialized)
        return;

    LOG.debug("Initializing schema partition " + getId());
    suffixDn.apply(schemaManager);
    super.doInit();

    // load schema
    final Map<String, Boolean> resMap = ResourceMap.getResources(Pattern.compile("schema[/\\Q\\\\E]ou=schema.*"));
    for (String resourcePath : new TreeSet<String>(resMap.keySet())) {
        if (resourcePath.endsWith(".ldif")) {
            URL resource = DefaultSchemaLdifExtractor.getUniqueResource(resourcePath, "Schema LDIF file");
            LdifReader reader = new LdifReader(resource.openStream());
            LdifEntry ldifEntry = reader.next();
            reader.close();

            Entry entry = new DefaultEntry(schemaManager, ldifEntry.getEntry());
            // add mandatory attributes
            if (entry.get(SchemaConstants.ENTRY_CSN_AT) == null) {
                entry.add(SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString());
            }
            if (entry.get(SchemaConstants.ENTRY_UUID_AT) == null) {
                entry.add(SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString());
            }
            AddOperationContext addContext = new AddOperationContext(null, entry);
            super.add(addContext);
        }
    }
}
 
Example 16
Source File: JarLdifSchemaLoader.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Entry> loadComparators( Schema... schemas ) throws LdapException, IOException
{
    List<Entry> comparatorList = new ArrayList<>();

    if ( schemas == null )
    {
        return comparatorList;
    }

    for ( Schema schema : schemas )
    {
        String start = getSchemaDirectoryString( schema )
            + SchemaConstants.COMPARATORS_PATH + "/" + "m-oid=";
        String end = "." + LDIF_EXT;

        for ( String resourcePath : RESOURCE_MAP.keySet() )
        {
            if ( resourcePath.startsWith( start ) && resourcePath.endsWith( end ) )
            {
                URL resource = getResource( resourcePath, "comparator LDIF file" );
                LdifReader reader = new LdifReader( resource.openStream() );
                LdifEntry entry = reader.next();
                reader.close();

                comparatorList.add( entry.getEntry() );
            }
        }
    }

    return comparatorList;
}
 
Example 17
Source File: LdifUtilsTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testConvertEntryOneControl() throws Exception
{
    LdifReader reader = new LdifReader();

    String expected =
        "dn: ou=test\n" +
            "control: 2.16.840.1.113730.3.4.2 false\n" +
            "changetype: add\n" +
            "ObjectClass: top\n" +
            "ObjectClass: metaTop\n" +
            "ObjectClass: metaSyntax\n" +
            "m-oid: 1.2.3.4\n" +
            "m-description: description\n\n";

    List<LdifEntry> entries = reader.parseLdif( expected );
    LdifEntry expectedEntry = entries.get( 0 );

    LdifEntry entry = new LdifEntry();

    entry.setDn( "ou=test" );
    entry.addAttribute( "ObjectClass", "top", "metaTop", "metaSyntax" );
    entry.addAttribute( "m-oid", "1.2.3.4" );
    entry.addAttribute( "m-description", "description" );

    ManageDsaITImpl control = new ManageDsaITImpl();

    entry.addControl( control );

    String converted = LdifUtils.convertToLdif( entry );

    assertNotNull( converted );

    entries = reader.parseLdif( converted );
    LdifEntry convertedEntry = entries.get( 0 );

    assertEquals( expectedEntry, convertedEntry );
    reader.close();
}
 
Example 18
Source File: LdifUtilsTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
@Test
public void testConvertEntryNoControls() throws Exception
{
    LdifReader reader = new LdifReader();

    String expected =
        "dn: ou=test\n" +
            "ObjectClass: top\n" +
            "ObjectClass: metaTop\n" +
            "ObjectClass: metaSyntax\n" +
            "m-oid: 1.2.3.4\n" +
            "m-description: description\n\n";

    List<LdifEntry> entries = reader.parseLdif( expected );
    LdifEntry expectedEntry = entries.get( 0 );

    LdifEntry entry = new LdifEntry();

    entry.setDn( "ou=test" );
    entry.addAttribute( "ObjectClass", "top", "metaTop", "metaSyntax" );
    entry.addAttribute( "m-oid", "1.2.3.4" );
    entry.addAttribute( "m-description", "description" );

    String converted = LdifUtils.convertToLdif( entry );

    assertNotNull( converted );

    entries = reader.parseLdif( converted );
    LdifEntry convertedEntry = entries.get( 0 );

    assertEquals( expectedEntry, convertedEntry );
    
    reader.close();
}
 
Example 19
Source File: ApacheDirectoryServer.java    From light-oauth2 with Apache License 2.0 4 votes vote down vote up
private static void processLdif(final SchemaManager schemaManager, final CoreSession adminSession, final String ldifName,
                                final Map<String, String> mappings) throws Exception {
    InputStream resourceInput = KerberosKDCUtil.class.getResourceAsStream("/ldif/" + ldifName);
    ByteArrayOutputStream baos = new ByteArrayOutputStream(resourceInput.available());
    int current;
    while ((current = resourceInput.read()) != -1) {
        if (current == '$') {
            // Enter String replacement mode.
            int second = resourceInput.read();
            if (second == '{') {
                ByteArrayOutputStream substitute = new ByteArrayOutputStream();
                while ((current = resourceInput.read()) != -1 && current != '}') {
                    substitute.write(current);
                }
                if (current == -1) {
                    baos.write(current);
                    baos.write(second);
                    baos.write(substitute.toByteArray()); // Terminator never found.
                }
                String toReplace = new String(substitute.toByteArray(), StandardCharsets.UTF_8);
                if (mappings.containsKey(toReplace)) {
                    baos.write(mappings.get(toReplace).getBytes());
                } else {
                    throw new IllegalArgumentException(String.format("No mapping found for '%s'", toReplace));
                }
            } else {
                baos.write(current);
                baos.write(second);
            }
        } else {
            baos.write(current);
        }
    }

    ByteArrayInputStream ldifInput = new ByteArrayInputStream(baos.toByteArray());
    LdifReader ldifReader = new LdifReader(ldifInput);
    for (LdifEntry ldifEntry : ldifReader) {
        adminSession.add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
    }
    ldifReader.close();
    ldifInput.close();
}
 
Example 20
Source File: ApacheDirectoryServer.java    From light-oauth2 with Apache License 2.0 4 votes vote down vote up
private static void processLdif(final SchemaManager schemaManager, final CoreSession adminSession, final String ldifName,
                                final Map<String, String> mappings) throws Exception {
    InputStream resourceInput = KerberosKDCUtil.class.getResourceAsStream("/ldif/" + ldifName);
    ByteArrayOutputStream baos = new ByteArrayOutputStream(resourceInput.available());
    int current;
    while ((current = resourceInput.read()) != -1) {
        if (current == '$') {
            // Enter String replacement mode.
            int second = resourceInput.read();
            if (second == '{') {
                ByteArrayOutputStream substitute = new ByteArrayOutputStream();
                while ((current = resourceInput.read()) != -1 && current != '}') {
                    substitute.write(current);
                }
                if (current == -1) {
                    baos.write(current);
                    baos.write(second);
                    baos.write(substitute.toByteArray()); // Terminator never found.
                }
                String toReplace = new String(substitute.toByteArray(), UTF_8);
                if (mappings.containsKey(toReplace)) {
                    baos.write(mappings.get(toReplace).getBytes(UTF_8));
                } else {
                    throw new IllegalArgumentException(String.format("No mapping found for '%s'", toReplace));
                }
            } else {
                baos.write(current);
                baos.write(second);
            }
        } else {
            baos.write(current);
        }
    }

    ByteArrayInputStream ldifInput = new ByteArrayInputStream(baos.toByteArray());
    LdifReader ldifReader = new LdifReader(ldifInput);
    for (LdifEntry ldifEntry : ldifReader) {
        adminSession.add(new DefaultEntry(schemaManager, ldifEntry.getEntry()));
    }
    ldifReader.close();
    ldifInput.close();
}