Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 使用Net::LDAP添加LDAP OU_Perl - Fatal编程技术网

Perl 使用Net::LDAP添加LDAP OU

Perl 使用Net::LDAP添加LDAP OU,perl,Perl,使用Net::LDAP添加OU的正确语法是什么,我尝试了以下方法: #!/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' );

使用Net::LDAP添加OU的正确语法是什么,我尝试了以下方法:

#!/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;
并得到以下错误:

value of naming attribute 'ou' is not present in entry 64
但是,使用ldapmodify命令行并使用以下ldif可以工作:

dn: ou=Users,dc=lab,dc=net
changetype: add
objectclass: top
objectclass: organizationalUnit
ou: Users
该行需要更改为:

'ou'          => 'Users',
'ou'          => 'Users',