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

Adding New OU

10 views
Skip to first unread message

Lupin Deterd

unread,
Dec 7, 2009, 4:38:41 AM12/7/09
to perl...@perl.org
Hi,

What is the correct syntax of adding an OU using Net::LDAP, I tried
the following:
!/usr/bin/perl -w

use 5.10.1; use strict;

use Net::LDAP; use Data::Dumper;

my $ldap = Net::LDAP->new("192.168.183.2") or die "$@"; my $mesg =
$ldap->bind( "cn=admin,dc=lab,dc=net", password => 'xxx' );

$mesg = $ldap->add( "ou=Users,dc=lab,dc=net", attrs => [

'ou' => 'dc=Users',
'objectClass' => [ 'top', 'organizationalUnit' ]
]

);

say $mesg->error; say $mesg->code;

And got the following error:

value of naming attribute 'ou' is not present in entry 64

However using the ldapmodify command line, and using this following ldif, works:

dn: ou=Users,dc=lab,dc=net changetype: add objectclass: top
objectclass: organizationalUnit ou: Users


Thanks,
Lupin

Chris Ridd

unread,
Dec 7, 2009, 5:58:08 AM12/7/09
to Lupin Deterd, perl...@perl.org

In that case, your add call should say:

'ou' => 'Users',

instead of:

'ou' => 'dc=Users',

Cheers,

Chris

Chris Ridd

unread,
Dec 7, 2009, 6:11:14 AM12/7/09
to Lupin Deterd, perl...@perl.org

On 7 Dec 2009, at 11:06, Lupin Deterd wrote:

> Thanks Chris, it works.

No problem. You should also check that your bind is succeeding. It returns a $mesg object (like add does) and you should use its ->code() method in the same sort of way to see if it worked.

Cheers,

Chris

Lupin Deterd

unread,
Dec 7, 2009, 6:06:19 AM12/7/09
to Chris Ridd, perl...@perl.org
On 12/7/09, Chris Ridd <chri...@mac.com> wrote:
>
Thanks Chris, it works.

-lupin

0 new messages