Thanks, I will try this and the other posted by Rick a try.

How does one get the information on OLE? By that I mean.. The following
code worked but I have no idea why or how:
use Win32::OLE;
use strict;

my $sysinfo = Win32::OLE->new('ADSystemInfo') 
|| die ("Can't get sysinfo: ".Win32::OLE->LastError()."\n");

my $username=$sysinfo->{UserName}; #distinguishedName #givenName
#name#userPrincipalName
print "Username:$username\n";
my $adsuser = Win32::OLE->GetObject("LDAP://$username";) 
|| die ("Can't find user: ".Win32::OLE->LastError()."\n");
print "CN: $adsuser->{cn}\n";
print "name: $adsuser->{name}\n";




I could muck around with it and get it to give me the address if I knew
the LDAP URL for the given user.
I just don't understand where they got the "ADSystemInfo" and what else
is out there for OLE.

--
Dan



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
> Sent: Wednesday, June 05, 2002 5:36 AM
> To: Dans Lists; [EMAIL PROTECTED]
> Subject: RE: Help with LDAP access
> 
> 
> 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

Reply via email to