[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: [ldap] ldif question



Perl would help a lot if the entries are not in order.  there is a
Perl-LDIF module, you could use that.

One way using perl is:

read the all the entries of the first LDIF file into a hash, %orig_entries
then read the entries of the second into %new_entries.
then cycle through the contents of new_entries, searching for each entry
in orig_entries and putting the entry into @diff_entries if the entry
doesn't exist in orig_entries or has changed.
then you add all the entries in @diff_entries and %orig_entries together
and write the new LDIF file.

hope that helps.

Allen Reese
Senior Software Engineer
Driversoft, Inc.
allen@driversoft.com

On Thu, 4 Feb 1999, James M. Moe wrote:

> On Wed, 03 Feb 1999 11:34:49 -0600, Shanthi Raman wrote:
> 
> >	I have a requirement to compare two ldif files , one obtained by exporting
> >data from the directory and the other one containing the latest data. I
> >have to update the directory with these changes. The way I like to go about
> >this is:-  
> >
> > [ ... ]
> >
> >Like to hear your comments on the entry deletion.   But more helpful will
> >be if you can point me to a piece of existing code that does the comparison
> >of attributes in each entry or any other advise on those lines.  
> 
>     There is no standard piece of code or program that will *easily* do the 
> comparisons for you. You gave no indication of the volume of data involved. If it's 
> fairly small, the tedium of manually comparing the entries is quickest.
>     If lots of data, you might be able to get "diff" to help out, if the latest data 
> file has complete entries, not just the new or changed parts. It would require that 
> the entries be in the same order.
>     Otherwise you will have to write your own processing program that can parse LDIF 
> files, identifying an entry in one file, searching for it in the other file, and 
> reporting any differences.
>     Or give the job to someone else...
> 
> 
> Good luck.
> 
> Jim Moe
> 
> 
>