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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



asandybox
Novice

Jun 30, 2014, 7:37 AM

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

All,

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.


Code
dn: cn=1234,ou=clients,dc=example,dc=com 
clientid: 1234
gn: john
sn: doe
mail: john.doe@example.com
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
mail: jane.hump@example.com
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 ldifdiff.pl 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 ldifdiff.pl 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.

Thanks


BillKSmith
Veteran

Jul 2, 2014, 5:57 AM

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

It is probably easier to modify lidfdiff.pl 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,
Bill


asandybox
Novice

Jul 8, 2014, 8:30 AM

Post #3 of 3 (291 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:

http://search.cpan.org/~gbarr/perl-ldap-0.33/contrib/ldifdiff.pl

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