Re: Net::LDAP compare question
- From: Charles DeRykus <ced@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 29 Jun 2006 04:03:32 GMT
lexx21 wrote:
Ok, I added "use strict;" and found some defects. I am still notI had luck only when passing a Net::LDAP::Entry object instead of a
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.
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
.
- References:
- Net::LDAP compare question
- From: max_headroom27606
- Re: Net::LDAP compare question
- From: James E Keenan
- Re: Net::LDAP compare question
- From: lexx21
- Net::LDAP compare question
- Prev by Date: Transition of CPAN to Perl6 ?
- Next by Date: Re: Transition of CPAN to Perl6 ?
- Previous by thread: Re: Net::LDAP compare question
- Next by thread: use bigmnum?
- Index(es):
Relevant Pages
|