Net::LDAP compare question



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.

.



Relevant Pages

  • Re: Retrieve Users in AD from SQL server Procedure
    ... No. SQL statements cannot be applied against an LDAP database. ... such as vbscript can be used to query AD. ... There are other languages as well ...
    (microsoft.public.windows.server.active_directory)
  • LDAP
    ... I'm trying to setup an application to query out LDAP database for ... Do most people create a seperate account for each one of ... these connections? ... What permissions does it need to query the database? ...
    (microsoft.public.windows.server.active_directory)
  • operation similar SQLs JOIN in LDAP?
    ... I have two base DN's in an LDAP database. ... each of the values for 'members' and do a query with that, ... With SQL, you'd do this by doing a JOIN. ...
    (microsoft.public.win2000.active_directory)
  • Re: MySQLdb - Query/fetch dont return result when it *theorically* should
    ... >> an action, if nothing is found, just keep this query-fetch cycle ... >> else with the same query. ... >> If an entry that the query should return is inserted in the database, ... it starts a little queue server in a separate thread. ...
    (comp.lang.python)
  • Re: MySQLdb - Query/fetch dont return result when it *theorically* should
    ... > an action, if nothing is found, just keep this query-fetch cycle ... > else with the same query. ... > If an entry that the query should return is inserted in the database, ... it starts a little queue server in a separate thread. ...
    (comp.lang.python)