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
(DataFlex) 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 = True. To use NTLM authentication, set the NtlmAuth property = True. Likewise, to use Negotiate authentication, set the NegotiateAuth property = True. 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.)
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp String sHtml Handle hoHttp2 3 Handle hoHttp3 String sTemp1 Integer iTemp1 Boolean bTemp1 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // Set the Login and Password properties for authentication. Set ComLogin Of hoHttp To "chilkat" Set ComPassword Of hoHttp To "myPassword" // To use HTTP Basic authentication.. Set ComBasicAuth Of hoHttp To True Get ComQuickGetStr Of hoHttp "http://localhost/xyz.html" To sHtml Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End // 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. Get ComLastStatus Of hoHttp To iTemp1 Showln "HTTP status code for Basic authentication: " iTemp1 // Examine the HTML returned for the URL: Showln sHtml Get Create (RefClass(cComChilkatHttp)) To hoHttp2 If (Not(IsComObjectCreated(hoHttp2))) Begin Send CreateComObject of hoHttp2 End // To use NTLM authentication, set the // NtlmAuth property = True Set ComNtlmAuth Of hoHttp2 To True // The session log can be captured to a file by // setting the SessionLogFilename property: Set ComSessionLogFilename Of hoHttp2 To "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). Get ComQuickGetStr Of hoHttp2 "http://localhost/xyz.html" To sHtml // Note: Get ComLastMethodSuccess Of hoHttp2 To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp2 To sTemp1 Showln sTemp1 Procedure_Return End Get ComLastStatus Of hoHttp2 To iTemp1 Showln "HTTP status code for NTLM authentication: " iTemp1 Get Create (RefClass(cComChilkatHttp)) To hoHttp3 If (Not(IsComObjectCreated(hoHttp3))) Begin Send CreateComObject of hoHttp3 End // To use Digest Authentication, set the DigestAuth property = True // Also, no more than one of the authentication type properties // (NtlmAuth, DigestAuth, and NegotiateAuth) should be set // to True. Set ComDigestAuth Of hoHttp3 To True Set ComSessionLogFilename Of hoHttp3 To "digestAuthLog.txt" // This call will now use Digest authentication (assuming it // is supported by the web server). Get ComQuickGetStr Of hoHttp3 "http://localhost/xyz.html" To sHtml Get ComLastMethodSuccess Of hoHttp3 To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp3 To sTemp1 Showln sTemp1 Procedure_Return End Get ComLastStatus Of hoHttp3 To iTemp1 Showln "HTTP status code for Digest authentication: " iTemp1 End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.