Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Overriding NTLM authentication dialog.

101 views
Skip to first unread message

jbch...@gmail.com

unread,
Dec 15, 2006, 11:12:19 PM12/15/06
to
Hi,

I have a .net 2.0 application that uses the InternetExplorer Object to
traverse websites. It reads the traversal through a script file.

I want to be able to get past NTLM authentication dialogs using the
IEObject programmatically.

I saw the other topic which is very similar with the WebBrowser
control, but i cannot seem to get it to work. It is not throwing any
exceptions, but it is not logging in. I need some help to get it
working.

Here is what i have so far:


Private Sub buttonTestNTLM_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles buttonTestNTLM.Click
If (objExplorer Is Nothing) Then
objExplorer = New SHDocVw.InternetExplorer
End If
objExplorer.Visible = True
objExplorer.Navigate2("about:blank")
Dim browserProxy As BrowserRemotingProxy = New
BrowserRemotingProxy(objExplorer)
objExplorer.Navigate2("http://ntlm.authentication.website/")
End Sub

Public Class BrowserRemotingProxy
Inherits MarshalByRefObject
Implements COMVB.IAuthenticate, COMVB.IServiceProvider

Public Sub New(ByRef ieObj As SHDocVw.InternetExplorer)
Dim sp As COMVB.IServiceProvider = DirectCast(ieObj,
COMVB.IServiceProvider)
Dim theProfferService As COMVB.IProfferService = Nothing
Dim objectProffer As IntPtr = IntPtr.Zero
Dim cookie As Integer = 0

objectProffer = sp.QueryService(COMVB.SID_SProfferService,
COMVB.IID_IProfferService)
theProfferService =
DirectCast(Runtime.InteropServices.Marshal.GetObjectForIUnknown(objectProffer),
COMVB.IProfferService)
theProfferService.ProfferService(COMVB.IID_IAuthenticate, Me,
cookie)
End Sub

Public Function QueryService(ByRef guidService As System.Guid,
ByRef riid As System.Guid) As IntPtr Implements
COMVB.IServiceProvider.QueryService
If (guidService = COMVB.IID_IAuthenticate And riid =
COMVB.IID_IAuthenticate) Then
Return
Runtime.InteropServices.Marshal.GetComInterfaceForObject(Me,
GetType(COMVB.IAuthenticate))
Else
Return IntPtr.Zero
End If
End Function

Public Sub Authenticate(ByRef phwnd As IntPtr, ByRef pszUsername As
String, ByRef pszPassword As String) Implements
COMVB.IAuthenticate.Authenticate
phwnd = IntPtr.Zero

pszUsername = "username"
pszPassword = "password"
End Sub

End Class

Class COMVB
' IServiceProvider interface

<Runtime.InteropServices.Guid("6d5140c1-7436-11ce-8034-00aa006009fa"),
_

Runtime.InteropServices.InterfaceTypeAttribute(Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)>
_
Public Interface IServiceProvider
Function QueryService(ByRef guidService As Guid, ByRef riid As
Guid) As IntPtr
End Interface

' IProfferService interface

<Runtime.InteropServices.Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0"),
_

Runtime.InteropServices.InterfaceTypeAttribute(Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)>
_
Public Interface IProfferService
Sub ProfferService(ByRef guidService As Guid, ByVal psp As
COMVB.IServiceProvider, ByRef cookie As Integer)
Sub RevokeService(ByVal cookie As Integer)
End Interface

' IAuthenticate interface
<Runtime.InteropServices.ComImport(),
Runtime.InteropServices.InterfaceType(Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown),
Runtime.InteropServices.ComConversionLoss(), _

Runtime.InteropServices.Guid("79EAC9D0-BAF9-11CE-8C82-00AA004BA90B")> _
Public Interface IAuthenticate
Sub Authenticate(ByRef phwnd As IntPtr, ByRef pszUsername As
String, ByRef pszPassword As String)
End Interface

Public Shared SID_SProfferService As New
Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0")
Public Shared IID_IProfferService As New
Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0")
Public Shared IID_IAuthenticate As New
Guid("79EAC9D0-BAF9-11CE-8C82-00AA004BA90B")
End Class


Thanks in advance,
John

0 new messages