Net::LDAP compare question
- From: max_headroom27606@xxxxxxxxx
- Date: 16 Jun 2006 07:08:00 -0700
I am writing a perl script to query an ldap database and find users who
do not belong to any mail distribution list. I can run the query just
fine, but my problem is getting only results back for users who do have
an attribute entry for the field "memberOf". Here is my code
listing....
$ldap = Net::LDAP->new( '**************' );
$mesg = $ldap->bind ( "$user",
password => "$password",
version => 3 );
if (!$base) { $base = "ou=****,ou=*****,dc=******,dc=******"; }
if (!$attrs) { $attrs = [ 'memberOf' ]; }
$search = 'mail=*@**********.com';
$result = $ldap->search ( base => "$base",
scope => "sub",
filter => "$search",
attrs => $attrs
);
$href = $result->as_struct;
@arrayOfDNs = keys %$href;
foreach ( @arrayOfDNs ) {
$dn = $_;
$res = $ldap->compare ( $dn,
attr => "$attrs",
value => ''
);
@entries = $res->dn;
foreach $entr ( @enties ) {
$butes = $entr->dn;
print $butes, "\n";
}
print "#-------------------------------\n";
}
$mesg = $ldap->unbind;
This is pretty much a cut/paste of the example given in CPAN, and I
have replaced the actual values of the query with '*' for obvious
reasons. In the lines
foreach ( @arrayOfDNs ) {
$dn = $_;
$res = $ldap->compare ( $dn,
attr => "$attrs",
value => ''
);
is where I am doing my compare statement, but get nothing back. It
should find any ldap entry where the attribute "memberOf" has no entry.
Any help would be appreciated in this.
.
- Follow-Ups:
- Re: Net::LDAP compare question
- From: James E Keenan
- Re: Net::LDAP compare question
- Prev by Date: env Config option and LockDetect option not working with Berkeley DB RPC
- Next by Date: use bigmnum?
- Previous by thread: env Config option and LockDetect option not working with Berkeley DB RPC
- Next by thread: Re: Net::LDAP compare question
- Index(es):
Relevant Pages
|