Giter Club home page Giter Club logo

ldifcompare's Introduction

LDIFCompare

A tool based on the UnboundID LDAP SDK library that can be used to compare two LDIF files and output the differences.

Requirements

  • Java 8u151 or newer
  • UnboundID LDAP SDK
  • SLF4J
  • Apache Commons Lang

Instructions

For help run: java -jar LDIFCompare-1.4-SNAPSHOT.jar --help

Example scenario

Let's say you are about to perform some kind of operation on a couple of thousand accounts in an LDAP directory using an automated provision tool and you want to make sure that you have not caused any unintended consequences by accidently modifying attributes or objects that are not in the scope of your operation.

  • The basic idea is to take a snapshot of the directory before your operation by doing an LDIF export.
  • Then you take another snapshot after the operation has taken place by doing another LDIF export.
  • Use your favorite diff tool to compare the two LDIF files and figure out why they diff and if the diff is important or not.

LDIFCompare allows you to compare LDIF files and specify which attributes you want to ignore when comparing, for example you might not be interested if the logonTime attribute has changed.

Concepts

I have chosen to call the file that contains the original pre-operation snapshot for the "left" file and the post-operation snapshot for the "right" file.

Imagine the two LDIF files side by side on your screen.

  • The pre-operation file is called the left file.
  • The post-operation file is called the right file.

Using a properties file with the property "ignore-attributes" you can specify which attributes to ignore while comparing. During processing all attributes specified in "ignore-attributes" will be removed from both entries before being compared and before the results are written to files. For examples see the doc\ldifcompare.properties file.

Output

After processing you will get a number of result files.

It will output five files: Each file is prefixed with the date and time of the operation in the following format: yyyy-MM-dd HHmmss

  • -change_records.txt, contains the modifications that must be performed on an entry from the "left" file to match the entry from the "right" file.
  • -reverse-change_records.txt, contains the the modifications that must be performed on an entry from the "right" file to match the entry from the "left" file.
  • -unique-<left file name>.ldif, contains the entries that only exist in the "left" file.
  • -unique-<right file name>.ldif, contains the entries that only exist in the "right" file.
  • (Optional) -changetype-delete-right.ldif, contains change records where the operation is 'delete' for entries that only exist in the "right" file

Example usage

Let's say you have two files you want to compare, the original "left" file and the post-operation "right" file.

You would execute the following command to compare them:

java -jar LDIFCompare-1.4.jar --ldifLeft ./left.ldif --ldifRight ./right.ldif --output /path/to/outputdirectory --properties ./ldifcompare.properties

The ldifcompare.properties file must contains one property called ignore-attributes=attr1,attr2. The values of the property are the names of the attributes to ignore when comparing, separated with a comma. For an example see the doc/ldifcompare.properties file. In the example above you would replace attr1,attr2 with the actual attribute names.

During a compare the DN is used to match entries between two LDIF-files, if an entry is moved, deleted or renamed then you won't get a match.

If you want to use an attribute instead of the DN to match two entries then you can do that by specifying the following property in the properties file: match-attribute=nameOfAttribute

Limitations

Handles only LDIF files containing content records or add records. Modify records and other changetypes are not supported.

Changelog

+ Added feature
* Improved/changed feature - Bug fixed/refactoring
! security bug fix
~ partial implementation

v1.4 Beta 1

+ Added support for a new property key ignore-attributes-starts-with which can be used to remove attributes that start with a string.

For example ignore-attributes-starts-with=nrf,cid will remove all attributes whose names start with nrf or cid.

v1.3

+ Added new argument, -d or --delete that creates an LDIF file that contains delete operations for entries that are missing from the "left" file, i.e. for deleting entries that only exist in the "right" file.

* Improved performance when using an attribute as key to match entries between files. Previously matching two files containing 60 000 entries (~18 MB files) and creating the diffs took about ~13 minutes. Now it takes 3 seconds on my machine.

v1.2

* Removed the LDIF file that contained entire entries that differed in some way but without any information on what actually differed.

* Introduced threading and performance optimizations, for example comparing two LDIF files, 463 MB and 314 MB using the DN as key previously took ~20 minutes. Now it takes ~40 seconds. An improvement by a factor of 30.

+ Outputs the time to run each operation to stdout.

License

GPL v3.0

ldifcompare's People

Contributors

idsecurity avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ldifcompare's Issues

unable to use the jar file

Hello idsecurity,

I might be hitting very basic issue, can you please help me use the application. I could not find SNAPSHOT.jar as being mentioned in README.md

java -jar LDIFCompare-1.4.jar --help
Error: Could not find or load main class se.idsecurity.ldifcompare.LdifUtilities

I see the class file present in jar, but some how it is not helping.

Thanks,
-Vikas.

How to skip only certain attribute values (i.e. objectClasses)?

I'm experimenting using LdifCompare to sync LDAP servers from different vendors, so left and right are generated from ldapsearch.

Since in left there are some proprietary objectClass values that I'm not interested into, but others (like "organizationalUnit") must of course be kept, how can I tell this tool to only skip certain attribute values?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.