2

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

1 Answer 1

2
'ou'          => 'dc=Users',

This line needs to be change to:

'ou'          => 'Users',
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.