Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3/4 Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(VBScript) HTTP Authentication (Basic, NTLM, Digest, Negotiate/Kerberos)
Demonstrates how to use HTTP authentication. Authentication can be added to any method that sends an HTTP request to the server, such as SynchronousRequest, QuickGetStr, PostXml, etc. To add authentication, simply set the Login and Password properties.
By default, Chilkat will use basic HTTP authentication, which sends the login/password clear-text over the connection. This is bad if SSL/TLS (i.e. HTTPS) is not used. However, if the connection is secure, there should be nothing wrong with using basic authentication.
Chilkat supports more secure authentication types as well, including Digest, NTLM, and Negotiate (which dynamically chooses between NTLM and Kerberos). To use Digest authentication, simply set the DigestAuth property = 1. To use NTLM authentication, set the NtlmAuth property = 1. Likewise, to use Negotiate authentication, set the NegotiateAuth property = 1.
Important: Negotiate authentication is only supported for the Chilkat implementations that run on the Windows platform. This is because it is implemented internally using Microsoft's SSPI API. NTLM authentication however, is available for all supported operating systems because Chilkat implements NTLM directlly (i.e. does not use Microsoft SSPI for the underlying implementation.)
Dim fso, outFile Set fso = CreateObject("Scripting.FileSystemObject") Set outFile = fso.CreateTextFile("output.txt", True) ' This example assumes the Chilkat API to have been previously unlocked. ' See Global Unlock Sample for sample code. set http = CreateObject("Chilkat_9_5_0.Http") ' Set the Login and Password properties for authentication. http.Login = "chilkat" http.Password = "myPassword" html = http.QuickGetStr("http://localhost/xyz.html") If (http.LastMethodSuccess <> 1) Then outFile.WriteLine(http.LastErrorText) WScript.Quit End If ' Examine the HTTP status code returned. ' A status code of 401 is typically returned for "access denied" ' if no login/password is provided, or if the credentials (login/password) ' are incorrect. outFile.WriteLine("HTTP status code for Basic authentication: " & http.LastStatus) ' Examine the HTML returned for the URL: outFile.WriteLine(html) set http2 = CreateObject("Chilkat_9_5_0.Http") ' To use NTLM authentication, set the ' NtlmAuth property = 1 http2.NtlmAuth = 1 ' The session log can be captured to a file by ' setting the SessionLogFilename property: http2.SessionLogFilename = "ntlmAuthLog.txt" ' Examination of the HTTP session log will show the NTLM ' back-and-forth exchange between the client and server. ' This call will now use NTLM authentication (assuming it ' is supported by the web server). html = http2.QuickGetStr("http://localhost/xyz.html") ' Note: If (http2.LastMethodSuccess <> 1) Then outFile.WriteLine(http2.LastErrorText) WScript.Quit End If outFile.WriteLine("HTTP status code for NTLM authentication: " & http2.LastStatus) set http3 = CreateObject("Chilkat_9_5_0.Http") ' To use Digest Authentication, set the DigestAuth property = 1 ' Also, no more than one of the authentication type properties ' (NtlmAuth, DigestAuth, and NegotiateAuth) should be set ' to 1. http3.DigestAuth = 1 http3.SessionLogFilename = "digestAuthLog.txt" ' This call will now use Digest authentication (assuming it ' is supported by the web server). html = http3.QuickGetStr("http://localhost/xyz.html") If (http3.LastMethodSuccess <> 1) Then outFile.WriteLine(http3.LastErrorText) WScript.Quit End If outFile.WriteLine("HTTP status code for Digest authentication: " & http3.LastStatus) outFile.Close
© 2000-2019 Chilkat Software, Inc. All Rights Reserved.