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

.



Relevant Pages

  • RE: Problems converting vbscript to perl
    ... CSC Systems Engineer ... I have a vb script example that I am trying to convert to Perl. ... print $strADSQuery. ...
    (perl.beginners)
  • Re: scripting newb
    ... I was able to hobble this together from another script posted by Dan ... Dim strSearch, strAdsPath, strServerName 'from search script ... Dim strDefaultDomainNC, strADSQuery 'from search script ... Set objADOConn = CreateObject ...
    (microsoft.public.scripting.vbscript)
  • Re: XMLHTTP problem
    ... if the script finds what its looking for quickly, ... i simply want to keep refreshing the page until a particular quote ... then my intCount variable pops up with a number in the ... If the server returns unicode you must open the textfile as unicode ...
    (microsoft.public.scripting.vbscript)
  • Re: Count words in textfiles
    ... I have a script but this script count the readline but not the word ... Const FOR_READING = 1 ... intCount = intCount + 1 ... and your search string has an uppercase letter, ...
    (microsoft.public.scripting.vbscript)
  • Re: Test for setup.exe success.
    ... the script continues immediately and never gets a return code. ... check for a registry setting added by the install. ... Do Until intCount = 30 ... ' Pause 1 second. ...
    (microsoft.public.scripting.vbscript)