re: sAMAccount name... it actually doesn't include the "pre-Win2K" domain name (but that's how it's often used).
Rick -----Original Message----- From: Rick Tatem Sent: Wednesday, June 05, 2002 9:38 AM To: [EMAIL PROTECTED] Subject: RE: Help with LDAP access The "distinguishedName" property (CN=<name>,CN=<container>,DC=<domain>) is what most AD-related things use when talking about an account. There's also the "sAMAccountName", which is the old NT4 way of identifying an account (<pre-Windows2000 domain>\<userid>). It's usually just as valid. Both of these attributes are replicated and indexed, so if you need to look "across" domains, you can use the Global Catalog instead. (use "GC:" instead of "LDAP:"). I usually use LDAP search syntax, although you could also use SQL. Here's a quickie example. (this is older code, knowing my luck it's probably cleaner and easier to do now... and I'm sure someone will let me know ;) ------------- use Win32::OLE; $basename = ""; #usually something like "server or domain/cn=users,dc=domain..." $emailaddress = "": #whatever you're looking for... $queryStr = "<LDAP://" . $basename . ">;"(mail=" . $emailaddress . ");distinguishedName,sAMAccountName;subtree"; $Conn = Win32::OLE->new("ADODB.Connection"); $Conn->{'Provider'} = "ADsDSOObject"; $Conn->Open("Active Directory Provider;UID=;PWD="); my $RS = $Conn->Execute($queryStr); while (!$RS->EOF) { print $RS->Fields('distinguishedName')->value . "\n"; print $RS->Fields('sAMAccountName')->value . "\n"; $RS->MoveNext; } -------------- Rick --- Rick Tatem Messaging and Directory Resources SAS Institute -----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 _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
