I'm trying to retrieve some information back from a Windows 2000 Active
Directory server, my 'ldapsearch' from a Solaris machine works:

The search:

ldapsearch -h gsbad1 -b 'dc=gsb,dc=uchicago,dc=edu' -D
"CN=xxxxxx,CN=Users,DC=gsb,DC=uchicago,DC=edu" 
-w xxxxxx sAMAccountName=dyoung2 displayName

And the results:

CN=Young\, Darren,OU=Users,OU=CS,DC=gsb,DC=uchicago,DC=edu
displayName=Young, Darren


Using the same credentials I have the following script:
==============================
#!/usr/local/bin/perl

use Net::LDAP;

my $host       = "gsbad1";
my $port       = 389;
my $binduser   = "CN=xxxxxx,CN=Users,DC=gsb,DC=uchicago,DC=edu";
my $bindpass   = "xxxxxx";
my $connstring = "$host" . ':' . "$port";
my $basedn     = "dc=gsb,dc=uchicago,dc=edu";
my $login      = "dyoung2";
my $ldap       = Net::LDAP->new($connstring);

if ( $ldap->bind( $binddn, password => "$bindpass" ) ) {
    print "successful bind to $host:$port\n";
} else {
    print "can't bind to ldap server $host:$port ($@)\n";
    exit;
}

$mesg = $ldap->search( base   => "$basedn",
                       filter => "(sAMAccountName=$login)"
                       );

if ( $mesg->code ) {
    print "FAILED: error is: " . $mesg->error . "\n";
    exit;
} else {
    print "found " . $mesg->count . " entries\n";

    foreach $entry ( $mesg->entries ) {
        $entry->dump;
    }
}

if ($ldap) {
    $ldap->unbind;
}
======================


Which yields this:

[EMAIL PROTECTED]:[bin]$ ./ad.pl 
successful bind to gsbad1:389
found 0 entries


Any thoughts or suggestions would be most appreciated.

Thanks,

-------------------------------------------------------------
| Darren Young              | http://www.chicagogsb.edu     |
| Senior UNIX Administrator | [EMAIL PROTECTED]   |
| University of Chicago GSB | [EMAIL PROTECTED] |
-------------------------------------------------------------

Reply via email to