Hi.
I was wondering if this problem sounded familiar, or if
I've done something wrong in my code...
I have an activedirectory LDAP server to connect to, bind
with username and password to, then retrieve all the details
associated with.
I can do this with the unix command line tool
'ldapsearch', in the format:
ldapsearch -h <servername> -b "DC=Alpha,DC=Bravo,DC=Charlie,DC=Delta" -D
"CN=<username>,OU=Echo,DC=Alpha,DC=Bravo,DC=Charlie,DC=Delta" -W -x "cn=<username>"
(It then prompts for the password, then retrieves the user's record.
- about 56 fields worth of data.
This indicates to me that the server is up, contactable, and working
as it's supposed to.)
On the other hand, when I use Net::LDAP to do the same connect, bind and search
it does connect, it seems to bind, and it returns data...
BUT only retrieves 28 records, omitting the ones I want (among others)
This is confusing to me. I can't seem to get a look at the user's record
binding anonymously (using netscape's ldap ability), which indicates
to me that the server's been set up to hide this sort of record from
people who aren't authenticating.
The code I'm using is as follows:
####binding#####
use Net::LDAP;
use Net::LDAP::Util;
my $ldap = Net::LDAP->new('<servername>') or die "$@";
my $basedn="OU=Echo,DC=Alpha,DC=Bravo,DC=Charlie";
my $binddn = "CN=$username,$basedn";
my $ldap_bind = $ldap->bind ("$binddn", password => "$password");
####searching#####
my $filter = "cn=$username";
my $ldap_search = $ldap->search (base => $basedn,
filter => $filter,
scope => "sub");
my $entry = $ldap_search->entry(0);
foreach my $field ($entry->attributes) {
my $ldap_field_value = $entry->get_value($field);
print $field . "=" . $ldap_field_value . "\n";
}
Am I missing something relatively simple?
It's using perl 5.6.1
Net::LDAP version 0.29
Convert::ASN1 version 0.16
Thanks in advance,
Benji Wakely
------
Benji Wakely
http://arsimagica.net/~benji
personal: +614 0958 8566