Plugin

Parse and load LDIF records to an LDAP directory server. Dump records from an LDAP directory server to LDIF or DSML formats. Start or stop an embedded LDAP server.

License

License

Categories

Categories

Maven Build Tools
GroupId

GroupId

com.btmatthews.maven.plugins
ArtifactId

ArtifactId

ldap-maven-plugin
Last Version

Last Version

1.3.2
Release Date

Release Date

Type

Type

maven-plugin
Description

Description

Plugin
Parse and load LDIF records to an LDAP directory server. Dump records from an LDAP directory server to LDIF or DSML formats. Start or stop an embedded LDAP server.
Project URL

Project URL

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

Project Organization

Brian Matthews

Download ldap-maven-plugin

How to add to project

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

Dependencies

compile (8)

Group / Artifact Type Version
dom4j : dom4j jar 1.6.1
jaxen : jaxen jar 1.1.6
com.unboundid : unboundid-ldapsdk jar 3.1.1
com.btmatthews.utils : monitor jar 2.1.3
com.btmatthews.maven.plugins.ldap : format-api jar 1.3.2
com.btmatthews.maven.plugins.ldap : format-ldif jar 1.3.2
com.btmatthews.maven.plugins.ldap : format-dsml jar 1.3.2
com.btmatthews.maven.plugins.ldap : server-api jar 1.3.2

provided (3)

Group / Artifact Type Version
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.2
org.apache.maven : maven-plugin-api jar 3.0.5
org.apache.maven : maven-core jar 3.0.5

runtime (1)

Group / Artifact Type Version
org.slf4j : log4j-over-slf4j jar 1.7.21

test (6)

Group / Artifact Type Version
org.powermock : powermock-api-mockito jar 1.6.5
com.btmatthews.maven.plugins.ldap : server-apacheds jar 1.3.2
com.btmatthews.maven.plugins.ldap : server-opendj jar 1.3.2
com.btmatthews.maven.plugins.ldap : server-unboundid jar 1.3.2
com.btmatthews.maven.plugins.ldap : server-api-test jar 1.3.2
com.btmatthews.ldapunit : ldapunit jar 1.1.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
1.1.0