Re: Net::LDAP compare question



lexx21 wrote:
Ok, I added "use strict;" and found some defects. I am still not
getting the expected results though. This is where it should do the
compare:

my $href = $result->as_struct;

my @arrayOfDNs = keys %$href;


my $dn;
my $res;
my @entries;
my $entr;
my $mesg;
my $crap;

foreach ( @arrayOfDNs ) {
$dn = $_;
$res = $ldap->compare ( $dn,
attr => "$attrs",
value => ''
);
@entries = $res->dn;

foreach $entr ( @entries ) {
$crap = $entr->dn;
print $crap, "\n";


I think I am doing something wrong as far as the compare statement.
This should take the attribute list that I defined earlier in the
script, and return a value of true or false based on the value. If
true, print the DN for the entry. If false, go to the next entry. For
some reason this isn't happening and I don't see the reason why.

Good idea about using strict though.

I had luck only when passing a Net::LDAP::Entry object instead of a
string DN although this wasn't clear in the docs. Here's an example:

use Net::LDAP;
use Net::LDAP::Constant /LDAP_COMPARE_TRUE LDAP_COMPARE_FALSE/;

my $result = $ldap->search( base => ...
filter => ...
);
die $result->error if $result->code;

my $compare;
foreach my $entry ($result->entries) {
$compare = $ldap->compare( $entry, attr => ..., value => ... );
if ( $compare->code == LDAP_COMPARE_TRUE ) {
print "compare->code is true"
} elsif ( $compare->code == LDAP_COMPARE_FALSE ) {
print "compare->code is false ";
} else {
print "compare error: ", $compare->code;
}
}


hth,
--
Charles DeRykus



.



Relevant Pages

  • Re: does Exchange provide a unique id for messages?
    ... are you saying I can't use WebDAV to get PR_EntryID and compare them? ... > Because long-term entry identifiers must be unique, ... Service providers assign new entry identifiers to moved/copied ...
    (microsoft.public.exchange2000.development)
  • Re: Ammon Shea, _Reading the OED_
    ... The entry for _unpoetic_ gives ... The reader dutifully looks ... means 'compare' so those who look up 'unpoetic' are invited to compare it ... adjectives to make the negative meaning. ...
    (rec.arts.books)
  • Re: Ammon Shea, _Reading the OED_
    ... The entry for _unpoetic_ gives ... The reader dutifully looks ... to compare it with 'unpoetical' and vice versa. ... to make the negative meaning. ...
    (rec.arts.books)
  • Re: Microsoft Access, Double Data Entry and breaking the Normalization rule
    ... This works very well for validation purposes, ... validation is done after the entry. ... field name to compare, as opposed to lopping off the last character ... form with a subform filtered to shows only the discrepancies. ...
    (comp.databases.ms-access)
  • Re: does Exchange provide a unique id for messages?
    ... but the only way to compare two entry ids is the ... If you are using MAPI, ... Because long-term entry identifiers must be unique, ...
    (microsoft.public.exchange2000.development)