Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using LDIF file with Net::LDAP

74 views
Skip to first unread message

Parag Kalra

unread,
Oct 4, 2009, 8:51:51 AM10/4/09
to perl...@perl.org
Hi Friends,

I guess we all know that using ldif files we can add or modify the directory
contents using OpenLDAP command line applications as shown below:
E.G: ldapadd -v -x -D "cn=admin,dc=nodomain" -H ldap://192.168.1.31:389 *-f
add_org.ldif* -W

Now "Net::LDAP' provides "add" method which takes the attributes to be
added. It also provides "modify" method along with many other useful
methods.

I was refering the documentation (
http://search.cpan.org/~gbarr/perl-ldap/lib/Net/LDAP.pod) and I couldn't
find a way to provide a ldif file as an input parameter to the methods like
"add" or "modify".

I just wanted to know if it is possible provide "ldif" files as an input
parameter to various functions of Net::LDAP (just as we can do with the
command "ldapadd")

If no then I guess we have to use Net::LDAP::LDIF.

Cheers,
Parag

Parag Kalra

unread,
Oct 5, 2009, 7:34:30 AM10/5/09
to Ernest Peterhans, perl...@perl.org
If there are few lines then your approached can be used. But what if the
ldif file is 100MB + and containing million of lines and containing complex
distinguished names and multiple object classes.

In that scenario the above method is not possible. That also means that
first I have to import the data from LDIF file to a text file.

The best option would be to use a ldif file as it is.

Anybody else who knows if it is possible?

Cheers,
Parag


On Mon, Oct 5, 2009 at 12:59 PM, Ernest Peterhans <epete...@pixelio.ch>wrote:

> Hi Parag,
>
> you don't need a LDIF file with Net::LDAP. You can use a simple text file
> providing it has a predefined "structure".
>
> For example, "the structure" is uid:givenName:sn:telephoneNumber. Then you
> can have a file phonelist.txt:
> 1000:Parag:Kalra:009988776655
> 1001:FirstA:LastA:01234567
>
> Your perl script can read the file, split each line in variables, delete
> the ldap entry, add the ldap entry as per above...
>
> Good luck,
> Ernest
> ----- Message d'origine -----
> De: Parag Kalra <parag...@gmail.com>
> Date: Sun, 4 Oct 2009 18:21:51 +0530
> Sujet: Using LDIF file with Net::LDAP
> À: perl...@perl.org


>
> >Hi Friends,
> >
> >I guess we all know that using ldif files we can add or modify the
> directory
> >contents using OpenLDAP command line applications as shown below:
> >E.G: ldapadd -v -x -D "cn=admin,dc=nodomain" -H ldap://192.168.1.31:389*-f
> >add_org.ldif* -W
> >
> >Now "Net::LDAP' provides "add" method which takes the attributes to be
> >added. It also provides "modify" method along with many other useful
> >methods.
> >
> >I was refering the documentation (

> >http://search.cpan.org/~gbarr/perl-ldap/lib/Net/LDAP.pod<http://search.cpan.org/%7Egbarr/perl-ldap/lib/Net/LDAP.pod>)

Parag Kalra

unread,
Oct 11, 2009, 12:46:19 PM10/11/09
to Graham Barr, perl...@perl.org
Was away from scene for a while...

BTW thanks Graham...I have been able to successfully import entire data from
LDIF file using Net::LDAP::LDIF module...

Thanks once again...

Cheers,
Parag


On Mon, Oct 5, 2009 at 6:01 PM, Graham Barr <gb...@pobox.com> wrote:

>
> On Oct 4, 2009, at 7:51 AM, Parag Kalra wrote:
>
> Hi Friends,
>>
>> I guess we all know that using ldif files we can add or modify the
>> directory
>> contents using OpenLDAP command line applications as shown below:
>> E.G: ldapadd -v -x -D "cn=admin,dc=nodomain" -H ldap://192.168.1.31:389
>> *-f
>> add_org.ldif* -W
>>
>> Now "Net::LDAP' provides "add" method which takes the attributes to be
>> added. It also provides "modify" method along with many other useful
>> methods.
>>
>> I was refering the documentation (

>> http://search.cpan.org/~gbarr/perl-ldap/lib/Net/LDAP.pod<http://search.cpan.org/%7Egbarr/perl-ldap/lib/Net/LDAP.pod>)


>> and I couldn't
>> find a way to provide a ldif file as an input parameter to the methods
>> like
>> "add" or "modify".
>>
>> I just wanted to know if it is possible provide "ldif" files as an input
>> parameter to various functions of Net::LDAP (just as we can do with the
>> command "ldapadd")
>>
>> If no then I guess we have to use Net::LDAP::LDIF.
>>
>

> well thats what Net::LDAP::LDIF is for.
>
> If you are familiar with the ldifadd command then you probably know there
> is also a
> command ldifmodify.
>
> Net::LDAP::LDIF can read these change descriptions and apply thenGraham.
>
>

0 new messages