VB.NET Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB.NET Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
PFX
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression
Misc

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

(VB.NET) 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 = 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.)

Download: Chilkat .NET Assemblies

Dim http As New Chilkat.Http()

Dim success As Boolean

'  Any string unlocks the component for the 1st 30-days.
success = http.UnlockComponent("Anything for 30-day trial")
If (success <> true) Then
    TextBox1.Text = TextBox1.Text & http.LastErrorText & vbCrLf
    Exit Sub
End If


'  Set the Login and Password properties for authentication.
http.Login = "chilkat"
http.Password = "myPassword"

Dim html As String
html = http.QuickGetStr("http://localhost/xyz.html")
'  Note:
If (html = vbNullString ) Then
    TextBox1.Text = TextBox1.Text & http.LastErrorText & vbCrLf
    Exit Sub
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.
TextBox1.Text = TextBox1.Text & "HTTP status code for Basic authentication: " _
     & http.LastStatus & vbCrLf

'  Examine the HTML returned for the URL:
TextBox1.Text = TextBox1.Text & html & vbCrLf


Dim http2 As New Chilkat.Http()

'  To use NTLM authentication, set the
'  NtlmAuth property = True
http2.NtlmAuth = true

'  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 (html = vbNullString ) Then
    TextBox1.Text = TextBox1.Text & http2.LastErrorText & vbCrLf
    Exit Sub
End If


TextBox1.Text = TextBox1.Text & "HTTP status code for NTLM authentication: " _
     & http2.LastStatus & vbCrLf


Dim http3 As New Chilkat.Http()

'  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.
http3.DigestAuth = true

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")
'  Note:
If (html = vbNullString ) Then
    TextBox1.Text = TextBox1.Text & http3.LastErrorText & vbCrLf
    Exit Sub
End If


TextBox1.Text = TextBox1.Text & "HTTP status code for Digest authentication: " _
     & http3.LastStatus & vbCrLf
 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser