When I run that (with values supplied for $strusername and $strMyOU), I receive the following error:
Win32::OLE(0.1601) error 0x8002000e: "Invalid number of parameters"
in METHOD/PROPERTYGET "GetObject"
It's as if I need to specify the type of object I am requesting or something.
Any ideas?
-----Original Message-----
From: Steven Manross [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 01, 2003 3:26 PM
To: Messenger, Mark; AS-Win32-Admin
Subject: RE: Pulling Email Address from ADSI?
You can use Win32::OLE and convert that script to perl...
use Win32::OLE;
$ldapstr = "LDAP://cn=" . $strusername . ",OU=Users,ou=" . $strMyOU
.",ou=Support,dc=DIRECTV,dc=com";
$objUser = Win32::OLE->new("ADsNamespaces");
$objUser->GetObject($ldapstr);
if (Win32::OLE->LastError() != 0) {
print Win32::OLE->LastError();
exit 0;
}
$strmail = $objUser->Get("mail");
print "email: " . $strmail . "\n";
This should work providing I don't have any glaring syntactical errors
(and providing that script worked in VB... But, it looks good..).
Steven
-----Original Message-----
From: Messenger, Mark [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 01, 2003 1:43 PM
To: 'AS-Win32-Admin'
Subject: Pulling Email Address from ADSI?
Does anyone know a way to use Win32::OLE (or any other module, for that
matter) to pull the Active Directory field known as "E-mail" in AD Users
and
Computers? (The SMTP address associated with an account)
Up to this point, I've been shelling out to a VBS (I feel dirty). A
snippet
follows, as it may be of assistance:
On Error Resume Next
set objArgs=WScript.Arguments
strusername=objArgs(0)
strfullname=objArgs(1)
strMyOU=objArgs(2)
ldapstr="LDAP://cn=" & strusername & ",OU=Users,ou=" & strMyOU &
",ou=Support,dc=DIRECTV,dc=com"
Set objUser = GetObject (ldapstr)
objUser.GetInfo
strphnum = objUser.Get("mail")
WScript.echo "email: " & strphnum & " ##$"
Danke :)
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
