Justin
Thu Jun 22 17:13:30 CDT 2006
On Thu, 22 Jun 2006 11:35:35 -0500, Leslie Houk <lhouk@ghg.net> wrote:
> This is exactly the situation I'm facing. I'd rather not have a
> password hard-coded into my script, but that's the only way I can
> automate my access to a specific web page. What would VBScript code
> that uses Integrated Windows Authentication to pass the user's name and
> password to the remote web page look like? I'm relatively new to
> VBScript, and can't seem to find any examples.
It's a feature of IIS, rather than something specific to VBScript. You
need to enable it in IIS Manager, disable anonymous access, and I believe
you also need to be on the same domain as the web server. You can find
more information about enabling it on Microsoft's site.
Configuring Integrated Windows Authentication in IIS 6.0
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5f8fe119-4095-4094-bba5-7dec361c7afe.mspx
Below I have included a short example that demonstrates automating
Internet Explorer below. If anonymous access has been disabled and
Integrated Windows Authentication is enabled on the web server, it will
attempt to automatically log in. If that fails, it will display a prompt
for the username and password. If that fails, it will give up and exit.
Option Explicit
Const Url = "
http://localhost/auth/test.asp"
Const ProgId = "InternetExplorer.Application"
Const Prefix = "IE_"
Const Status_Unauthorized = 401
Dim finished : finished = False
Dim navcomplete : navcomplete = False
' Open Internet Explorer and navigate to the web page
Dim ie: Set ie = WScript.CreateObject(ProgId, Prefix)
ie.Navigate2 Url
' Wait for the signal to quit
Do Until finished : WScript.Sleep 100 : Loop
' Internet Explorer will call this subroutine when the web page has
' been found and the server has replied
Sub IE_NavigateComplete2(pdisp, url)
navcomplete = True
End Sub
' Internet Explorer will call this subroutine when the page has
' finished loading, and sometimes just for kicks
Sub IE_DownloadComplete()
If navcomplete = True Then
WScript.Echo ie.Document.Body.InnerText
finished = True
End If
End Sub
' Internet Explorer will call this subroutine if it was not able to
' find the web page
Sub IE_NavigateError(pdisp, url, target, status, cancel)
Select Case status
' This status code is used when IIS was not able to
' authenticate the user
Case Status_Unauthorized: WScript.Echo "Unable to log in."
finished = True
End Select
End Sub
There are a number of other such examples on the web. Searching for
"InternetExplorer.Application" should turn up more information.
--
Justin Piper
Bizco Technologies
http://www.bizco.com/