Perl で単純な LDAP クエリを実装しようとしています。ドメインのすべての「dnsZone」オブジェクトから「dc」属性を取得したいと考えています。最初に dsquery を使用して記述しましたが、完全に機能します。
dsquery * "DC=iii,DC=hogent,DC=be" -attr dc -scope subtree -filter "(objectClass=dnsZone)"
これを Perl で実装しようとすると、'dc' 属性を照会しただけで次のエラーが表示されます。「dc」属性と「name」属性 (どちらも同じように見えます) を照会すると、問題はありません。
「ADODB.Fields」からの OLE 例外:
要求された名前または序数に対応するコレクション内に項目が見つかりません。
プロパティキャッシュの方向で考えていましたが、プロパティがまだ利用できない可能性があります。しかし、LDAP クエリを使用してプロパティ キャッシュを更新する方法がわかりません。多分 getInfoEx([...], 0) バリアントがありますか?
my $rootDSE = bind_object('RootDSE');
my $base = bind_object($rootDSE->Get('defaultNamingContext'))->{ADsPath};
my $filter = "(objectClass=dnsZone)";
my $attrs = 'dc'; #No error when i change this into 'dc,name'
my $scope = 'subTree';
my $connection = Win32::OLE->CreateObject('ADODB.Connection');
$connection->{Provider} = 'ADsDSOObject';
$connection->Open();
my $command = Win32::OLE->CreateObject('ADODB.Command');
$command->{ActiveConnection} = $connection;
$command->{CommandText} = "<$base>;$filter;$attrs;$scope;";
my $resultSet = $command->Execute();
until($resultSet->{EOF}) {
my $fields = $resultSet->{Fields};
print $fields->{dc}->{Value}."\n";
$resultSet->MoveNext();
}
誰かが私が間違っていることを見ていますか?