Found the problem, it was with the hash. $strAdsPath =
$objQueryResultSet->Fields('AdsPath')->Item; should have been
$strAdsPath = $objQueryResultSet->Fields('AdsPath')->Value;
Timothy F. Gallagher
CSC Systems Engineer
-----Original Message-----
From: Gallagher, Tim (NE) [mailto:[EMAIL PROTECTED]
Sent: Monday, April 10, 2006 12:35 PM
To: Perl Beginners
Subject: Problems converting vbscript to perl
I have a vb script example that I am trying to convert to Perl. Most of
the script is done except for the last part. Can some tell me what I am
missing? Here is the script.
Start Script
use Win32::OLE;
$strSearch = 'tim*;
$objRootDSE = Win32::OLE->GetObject('LDAP://RootDSE');
$strDomain1 = $objRootDSE->Get('DefaultNamingContext');
# Set up the ADO connection required to implement the search.
$objADOConn = Win32::OLE->new('ADODB.Connection');
$objADOConn->{Provider} = 'ADsDSOObject';
# Connect using current user credentials
$objADOConn->Open('Active Directory Provider');
$objADOCommand = Win32::OLE->new('ADODB.Command');
$objADOCommand->{ActiveConnection} = $objADOConn;
# Format search criteria using SQL syntax
$strADSQuery = 'SELECT samAccountName, givenName, sn, AdsPath FROM
\'LDAP://' . $strDomain1 . '\' WHERE samAccountName = \'' . $strSearch .
'\'';
print $strADSQuery . "\n";
$objADOCommand->{CommandText} = $strADSQuery;
# Execute the search
$objQueryResultSet = $objADOCommand->Execute;
$intCount = 0;
while(<>)
{
$strAdsPath = $objQueryResultSet->Fields('AdsPath')->Item;
print 'The AdsPath is: ' . $strAdsPath, "\n";
print "\n";
$intCount = $intCount + 1;
$objQueryResultSet->MoveNext();
}
$objADOConn->Close();
End Script
The last part, while is not working and I cannot find out why. Here is
the VB script
Start script
strSearch = "tim.g*"
Set objRootDSE = GetObject("LDAP://RootDSE")
strDomain1 = objRootDSE.Get("DefaultNamingContext")
'Set up the ADO connection required to implement the search.
Set objADOConn = CreateObject("ADODB.Connection")
objADOConn.Provider = "ADsDSOObject"
'Connect using current user credentials
objADOConn.Open "Active Directory Provider"
Set objADOCommand = CreateObject("ADODB.Command")
Set objADOCommand.ActiveConnection = objADOConn
'Format search criteria using SQL syntax
strADSQuery = "SELECT samAccountName, givenName, sn, AdsPath FROM
'LDAP://" & _
strDomain1 & "' WHERE samAccountName = '" & strSearch & "'"
objADOCommand.CommandText = strADSQuery
'Execute the search
Set objQueryResultSet = objADOCommand.Execute
intCount = 0
While Not objQueryResultSet.EOF
strAdsPath = objQueryResultSet.Fields("AdsPath")
WScript.Echo("The AdsPath is: " & strAdsPath)
WScript.Echo("")
intCount = intCount + 1
objQueryResultSet.MoveNext
Wend
objADOConn.Close
end script
Timothy F. Gallagher
CSC Systems Engineer
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>