Peter,
Since you are already using Win32-Exchange (and Win32-Exchange really
uses AD user accounts as its base[for E2K]),
(I know this from offline conversations)
_AdodbExtendedSearch would be useful in finding the user by either
name... But here's a sample using samAccountName.
(not tested, but should work unless there's flaming syntactical issues).
Something like this would probably find your user: (but a better filter
would speed up your query.. i.e. the (objectClass=User) could be &ed
with a (samaccountname=$search_string) to turn down the number of
results you are looking through for a match, from all users to just 1
user.
if (!Win32::Exchange::_AdodbExtendedSearch($search_string,
"LDAP://$dc_name",
"(objectClass=User)",
"samAccountName,distinguishedName",
1,
$dn)) {
print "Error querying distinguished name for user\n";
return 0;
} else {
print "Here's your user's dn: $dn\nNow all you have to do is connect
to it!\n";
return $dn;
}
Steven
-----Original Message-----
From: Peter A. Peterson II [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2003 9:54 AM
To: [EMAIL PROTECTED]
Subject: Getting user object by account name (samAccountName)
I'm working on a little CLI AD/Exchange swiss army knife utility and
I've run into a snag -- when creating accounts, Microsoft by default
makes the conatiner name the displayName (J. Random Hacker) rather
than the account name, jhacker.
However for an administrator, most activities, like mailbox creation,
lockout, enable/disable, deletion, are more easily referred to by
accountname than by displayName... does anyone know how I could get a
user object using the account name instead of the display name?
I'm incorporating code from Steven Manross' Exchange module (his
example script code is utilized), as well as code that Colin Eric
Johnson posted in Feb. for creating users -- please let me know if
either of you object. :)
I'll be sure to post my code when it's ready for the light.
Peter
_______________________________________________
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