1
我有这个代码工作。这可以通过LDAP功能完成吗?
#!/usr/bin/perl
use warnings;
use strict;
use Net::LDAP;
use Data::Dumper;
my $dn="...";
my $password="...";
my $ldap = Net::LDAP->new('...') or die "[email protected]";
my $mesg = $ldap->bind($dn, password => $password);
if ($mesg->code) { die "uuuu $mesg"; }
$mesg = $ldap->search(
base => "...",
scope => 'one',
filter => '(groupType=-2147483646)',
attrs => ['sAMAccountName'],
);
my @ad = ();
foreach ($mesg->entries) {
push @ad, $_->asn->{attributes}[0]->{vals}[0];
}
foreach (@ad) {
print;
print "\n";
}
并输出安全组的名称。
所以我想,如果LDAP(Active Directory)中有函数提取从树的值,而不是做使用数组和哈希就像我在
push @ad, $_->asn->{attributes}[0]->{vals}[0];
的树看起来做硬编码路径像这样
'entries' => [
bless({
'changes' => [],
'changetype' => 'modify',
'asn' => {
'objectName' => '...',
'attributes' => [
{
'type' => 'sAMAccountName',
'vals' => [
'test-group-1'
]
}
]
}
}, 'Net::LDAP::Entry'),
bless({
'changes' => [],
'changetype' => 'modify',
'asn' => {
'objectName' => '...',
'attributes' => [
{
'type' => 'sAMAccountName',
'vals' => [
'test-group-3'
]
}
]
}
}, 'Net::LDAP::Entry')
],