[Date Prev][Date Next]
Re: Problem with LDIFReader always requiring version number in LDIF file
On Wednesday 11 May 2005 05:25, Safdar Kureishy wrote:
> I couldn't find anything about this on the newsgroup, so am posting
> this message.
> I am running into a problem where the LDIFReader (from JLDAP) requires
> a "version" field to exist in the LDIF file that it is made to read.
> When it doesn't find the version field, the LDIFReader throws the
> following exception:
> LDAPLocalException: com.novell.ldap.ldif_dsml.LDIFReader: Version line
> must be the first meaningful line(on line 1 of the file) (82) Local
If I understand the RFC2849, that defines the LDIF format, correctly
the version specification is required by the LDIFv1 format.
> I will always be getting LDIF files from the customer that don't have
> a version number as the first line. Instead of adding this line on the
> top of each file (which could be an expensive operation for large
> LDIFs) before parsing them, is there any way that I can make the
> LDIFReader not complain about the version and just default to version
> 1? If I add "version: 1" to the file, it works fine, so I know that
> defaulting to version 1 should be fine.
> I've looked around but couldn't find any way of working around this
> error in a simple way. Any help would be greatly appreciated.
You may use the dirty hack below to convert your files to LDIFv1 files.
grep ^version: LDIF-FILE || \
perl -i -p -e 'print "version: 1\n\n" if ($. eq 1)' LDIF-FILE
Hope it helps