I have not run this with AD as of yet (it runs against a Netscape LDAP implementation)
but it shouldn't be too different. It should give you an idea to work with and some
tricky (see "$entry"[!]) syntax help:
#################################################################
#################################################################
use Net::LDAP;
$ldap = Net::LDAP->new('ldap.domain.com:389') or warn "$@";
$ldap->bind ( # bind to a directory with dn and password, anonymous connection
dn => '',
password => ''
) or warn "$@";
### perform a search with a filter --> the filter is your key
$mesg = $ldap->search ( base => "ou=Users, dc=domain, dc=com",
filter => "(&(sn=A*) (email=".$email."))"
) or warn "$@";
### code is the return code, 0 for success
$mesg->code && write_log("LDAP Search failure, code is {$mesg->code}, error
{$mesg->error} ") and die;
foreach $entry ($mesg->all_entries)
{
### Let's make this a little simpler for sanity sake...
### We'll throw the entry into a hash
my %ldap_entry = (
Region => ${$entry->{'attrs'}{lc(c)}}[0],
City => ${$entry->{'attrs'}{lc(l)}}[0],
Domain_Name =>
${$entry->{'attrs'}{lc(ntUserDomainID)}}[0],
NTUserID =>
${$entry->{'attrs'}{lc(uid)}}[0]
);
}
#################################################################
#################################################################
-----Original Message-----
From: Dans Lists [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 05, 2002 2:29 AM
To: [EMAIL PROTECTED]
Subject: Help with LDAP access
I have an email address, I need to get the user account out of AD.
How?
--
Daniel Peterson
LBNL - Berkeley Lab
Energy Sciences Network - ESnet
E-Mail: [EMAIL PROTECTED]
Voice: (510) 486-7275
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Visit our website at http://www.ubswarburg.com
This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs