Format LDIF

Handler for importing and exporting directory entries in from and to LDAP Data Interchange Format (LDIF) files

License

License

Categories

Categories

Maven Build Tools ORM Data
GroupId

GroupId

com.btmatthews.maven.plugins.ldap
ArtifactId

ArtifactId

format-ldif
Last Version

Last Version

1.3.2
Release Date

Release Date

Type

Type

jar
Description

Description

Format LDIF
Handler for importing and exporting directory entries in from and to LDAP Data Interchange Format (LDIF) files
Project URL

Project URL

http://ldap-maven-plugin.btmatthews.com/format-ldif
Project Organization

Project Organization

Brian Matthews

Download format-ldif

How to add to project

<!-- https://jarcasting.com/artifacts/com.btmatthews.maven.plugins.ldap/format-ldif/ -->
<dependency>
    <groupId>com.btmatthews.maven.plugins.ldap</groupId>
    <artifactId>format-ldif</artifactId>
    <version>1.3.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.btmatthews.maven.plugins.ldap/format-ldif/
implementation 'com.btmatthews.maven.plugins.ldap:format-ldif:1.3.2'
// https://jarcasting.com/artifacts/com.btmatthews.maven.plugins.ldap/format-ldif/
implementation ("com.btmatthews.maven.plugins.ldap:format-ldif:1.3.2")
'com.btmatthews.maven.plugins.ldap:format-ldif:jar:1.3.2'
<dependency org="com.btmatthews.maven.plugins.ldap" name="format-ldif" rev="1.3.2">
  <artifact name="format-ldif" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.btmatthews.maven.plugins.ldap', module='format-ldif', version='1.3.2')
)
libraryDependencies += "com.btmatthews.maven.plugins.ldap" % "format-ldif" % "1.3.2"
[com.btmatthews.maven.plugins.ldap/format-ldif "1.3.2"]

Dependencies

compile (1)

Group / Artifact Type Version
com.btmatthews.maven.plugins.ldap : format-api jar 1.3.2

provided (1)

Group / Artifact Type Version
com.unboundid : unboundid-ldapsdk jar 3.1.1

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-core jar 1.10.19
com.btmatthews.maven.plugins.ldap : format-api-test jar 1.3.2

Project Modules

There are no modules declared in this project.

LDAP Maven Plugin

Build Status Maven Central License

The LDAP Maven Plugin is a Maven plugin that can:

  • Import/export data to/from an LDAP directory server. Both the: LDIF and DSML formats are supported.

  • Launch and shutdown a LDAP directory server in the Maven build life-cycle. The plugin supports the following LDAP directory servers:

Importing or exporting data

The plugin provides the following goals to import or export content from a LDAP directory server:

  • load is used to load content from a file into a LDAP directory server.

  • dump is used to dump content to a file from a LDAP directory sever.

The following file formats are supported

  • LDIF - LDAP Directory Interchange Format

  • DSML - Directory Services Markup Language

LDAP Data Interchange Format (LDIF)

Import

The following POM fragment demonstrates how to load content into a LDAP directory server from a LDIF formatted file using the load goal of the LDAP Maven Plugin.

<plugin>
    <groupId>com.btmatthews.maven.plugins</groupId>
    <artifactId>ldap-maven-plugin</artifactId>
    <version>1.3.2</version>
    <executions>
        <execution>
            <id>load</id>
            <goals>
                <goal>load</goal>
            </goals>
            <configuration>
                <host>localhost</host>
                <port>10389</port>
                <authDn>uid=admin,ou=system</authDn>
                <passwd>secret</passwd>
                <sources>
                    <ldif>load.ldif</ldif>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

Export

The following POM fragment demonstrates how to export content from a LDAP directory server to a LDIF formatted file using the dump goal of the LDAP Maven Plugin.

<plugin>
    <groupId>com.btmatthews.maven.plugins</groupId>
    <artifactId>ldap-maven-plugin</artifactId>
    <version>1.3.2</version>
    <executions>
        <execution>
            <id>dump</id>
            <goals>
                <goal>dump</goal>
            </goals>
            <configuration>
                <host>localhost</host>
                <port>10389</port>
                <authDn>uid=admin,ou=system</authDn>
                <passwd>secret</passwd>
                <searchBase>dc=btmatthews,dc=com</searchBase>
                <filename>dump.ldif</filename>
                <format>ldif</format>
            </configuration>
        </execution>
    </executions>
</plugin>

Directory Service Markup Language (DSML)

Import

The following POM fragment demonstrates how to load content into a LDAP directory server from a DSML formatted file using the load goal of the LDAP Maven Plugin.

<plugin>
    <groupId>com.btmatthews.maven.plugins</groupId>
    <artifactId>ldap-maven-plugin</artifactId>
    <version>1.3.2</version>
    <executions>
        <execution>
            <id>load</id>
            <goals>
                <goal>load</goal>
            </goals>
            <configuration>
                <host>localhost</host>
                <port>10389</port>
                <authDn>uid=admin,ou=system</authDn>
                <passwd>secret</passwd>
                <sources>
                    <dsml>${basedir}/load.dsml</dsml>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

Export

The following POM fragment demonstrates how to export content from a LDAP directory server to a DSML formatted file using the dump goal of the LDAP Maven Plugin.

<plugin>
    <groupId>com.btmatthews.maven.plugins</groupId>
    <artifactId>ldap-maven-plugin</artifactId>
    <version>1.3.2</version>
    <executions>
        <execution>
            <id>dump</id>
            <goals>
                <goal>dump</goal>
            </goals>
            <configuration>
                <host>localhost</host>
                <port>10389</port>
                <authDn>uid=admin,ou=system</authDn>
                <passwd>secret</passwd>
                <searchBase>dc=btmatthews,dc=com</searchBase>
                <filename>dump.dsml</filename>
                <format>dsml</format>
            </configuration>
        </execution>
    </executions>
</plugin>

Running an LDAP Server in the build life-cycle

pom.xml

The following POM fragment uses the run goal to launch an embedded LDAP directory server prior to the execution of the integration tests and then uses the stop goal to shutdown the embedded LDAP directory server upon completion of the integration tests.

<?xml version="1.0" encoding="UTF-8"?>
<project
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://maven.apache.org/POM/4.0.0
    http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.btmatthews.maven.plugins</groupId>
          <artifactId>ldap-maven-plugin</artifactId>
          <version>1.3.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.btmatthews.maven.plugins</groupId>
        <artifactId>ldap-maven-plugin</artifactId>
        <configuration>
          <monitorPort>11389</monitorPort>
          <monitorKey>ldap</monitorKey>
          <daemon>true</daemon>
        </configuration>
        <executions>
          <execution>
            <id>start-ldap</id>
            <goals>
              <goal>run</goal>
            </goals>
            <phase>pre-integration-test</phase>
          </execution>
          <execution>
            <id>stop-ldap</id>
            <goals>
              <goal>stop</goal>
            </goals>
            <phase>post-integration-test</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Connecting in Java

The following LDAP client libraries can be used to connect to the embedded LDAP server:

The LDAPUnit library provides an assortment of assertion and verification methods for use in unit and integration test cases.

Maven Central Coordinates

The LDAP Maven Plugin has been published in Maven Central at the following coordinates:

<plugin>
    <groupId>com.btmatthews.maven.plugins</groupId>
    <artifactId>ldap-maven-plugin</artifactId>
    <version>1.3.2</version>
</plugin>

Note: If you want to use OpenDJ you will also need to add the following repository to your pom.xml or settings.xml file since the ForgeRock dependencies are not available from Maven Central.

<repository>
    <id>maven.forgerock.org</id>
    <name>maven.forgerock.org-releases</name>
    <url>http://maven.forgerock.org/repo/releases</url>
</repository>

License & Source Code

The LDAP Maven Plugin is made available under the Apache License and the source code is hosted on GitHub at https://github.com/bmatthews68/ldap-maven-plugin.

Versions

Version
1.3.2
1.3.0
1.2.0