Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) HTTP Authentication (Basic, NTLM, Digest, Negotiate)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. 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.)
integer li_rc oleobject loo_Http string ls_Html oleobject loo_Http2 oleobject loo_Http3 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Set the Login and Password properties for authentication. loo_Http.Login = "chilkat" loo_Http.Password = "myPassword" // To use HTTP Basic authentication.. loo_Http.BasicAuth = 1 ls_Html = loo_Http.QuickGetStr("http://localhost/xyz.html") if loo_Http.LastMethodSuccess <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Http return 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. Write-Debug "HTTP status code for Basic authentication: " + string(loo_Http.LastStatus) // Examine the HTML returned for the URL: Write-Debug ls_Html loo_Http2 = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http2.ConnectToNewObject("Chilkat.Http") // To use NTLM authentication, set the // NtlmAuth property = 1 loo_Http2.NtlmAuth = 1 // The session log can be captured to a file by // setting the SessionLogFilename property: loo_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). ls_Html = loo_Http2.QuickGetStr("http://localhost/xyz.html") // Note: if loo_Http2.LastMethodSuccess <> 1 then Write-Debug loo_Http2.LastErrorText destroy loo_Http destroy loo_Http2 return end if Write-Debug "HTTP status code for NTLM authentication: " + string(loo_Http2.LastStatus) loo_Http3 = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http3.ConnectToNewObject("Chilkat.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. loo_Http3.DigestAuth = 1 loo_Http3.SessionLogFilename = "digestAuthLog.txt" // This call will now use Digest authentication (assuming it // is supported by the web server). ls_Html = loo_Http3.QuickGetStr("http://localhost/xyz.html") if loo_Http3.LastMethodSuccess <> 1 then Write-Debug loo_Http3.LastErrorText destroy loo_Http destroy loo_Http2 destroy loo_Http3 return end if Write-Debug "HTTP status code for Digest authentication: " + string(loo_Http3.LastStatus) destroy loo_Http destroy loo_Http2 destroy loo_Http3 |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.