Adding LDAP OU using Net::LDAP
- by lupindeterd
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