CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Suggestions on how to solve diffing two ldap files



Jun 30, 2014, 7:37 AM

Post #1 of 3 (1413 views)
Suggestions on how to solve diffing two ldap files Can't Post


This is a bit of a long post so bear with me as I try my best to explain my problem.

I was given a task a while back to extract client records from a legacy database and migrate them into a ldap database.

I have data that that we are pulling from a database and have been putting into ldif format for insertion into a ldap db.

dn: cn=1234,ou=clients,dc=example,dc=com 
clientid: 1234
gn: john
sn: doe
userpassword: {ssha}muigloxhsr8b41elklgxtj2tsbbsv1z3sdhecw==
uid: jdoe
customerid: 0001
customername: example company
lastupdate: 201404300020z
objectclass: inetorgperson

dn: cn=1235,ou=clients,dc=example,dc=com
clientid: 1235
gn: Jane
sn: Hump
userPassword: {SSHA}MUiGLOxHSR8B41elKlGXTJ2TSBBsV1Z3SDhEcw==
uid: jhump
customerID: 0002
customerName: Example Company
lastUpdate: 201404300020Z
objectclass: inetOrgPerson

This file can sometimes span up to 45k in entries for client records. My first issue was that I needed to figure out how to diff these files generated let's say hourly and only pick up the differences since it would take a long time to clear out the ldap database and re-add everything to keep the database fresh.

Aka: Generate 1.full then 2.incremental, diff the two files and create 1.diff. Then apply the diffs via ldapupdate. I was using for the task. I believe it's a perl module.

So that was working for a period of time until we introduced hashed passwords. That screwed up everything since now each time the sync occurred a new SHA password would be computed for the incremental file.

Back to the drawing board...

To solve that issue, I added a field called "lastUpdate", this would print the time that a record that we were pulling from the database was updated.

My logic was now I can somehow just parse the two files and only print out the differences if this "lastUpdate" field was modified.

Well, since then I've been spinning my wheels on how to accomplish this. Some ideas I've been throwing around in my head are to:

1. Load everything into a hash and diff the values there?
2. Load the two files and extract the lastUpdate field between the two files and print out the blocks of records that have had their update times modified?
3. I also thought about modifying and seeing if I could just add a conditional to check if lastupdate has been modified between the two files.

Still unsure so throwing it out here to see if anyone could offer some advice.



Jul 2, 2014, 5:57 AM

Post #2 of 3 (1176 views)
Re: [asandybox] Suggestions on how to solve diffing two ldap files [In reply to] Can't Post

It is probably easier to modify to ignore passwords than to start from scratch. I cannot find it on CPAN. Can you attach the code or supply a link?
Good Luck,


Jul 8, 2014, 8:30 AM

Post #3 of 3 (959 views)
Re: [BillKSmith] Suggestions on how to solve diffing two ldap files [In reply to] Can't Post

It's part of the ldif-perl package:

I'm currently looking into how to modify this.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives