Re: Wininet Authentication Problem

From: Jeffrey Cumpsty (jeffrey_at_cumpsty.co.uk)
Date: 01/24/05


Date: Mon, 24 Jan 2005 01:32:26 -0800

You are right about the setup. We have an ASP.Net/C# web server,
which is accessed through a proxy to handle the login for multiple
portals.

State is maintained through the MS Application Block.

Since this is a large company, they have an upgade path for the client
PC's, but currently we can not guarantee that the .Net framework is on
there. All we can guarantee is IE4, Office 97, and VB6 runtimes.
Because of this my client code needs to be in a VB6 Active X Control.

I was going to develop the solution using iFrames to maintain the
session. However I thought using Wininet API calls directly was the
better option.

It works great on my local PC, because there is no authentication
requirement. However when I copy the code over to the production web
server, every call I make is being redirected to the Login Page. My
call to InternetReadFile returns the HTML for this page, not the XML
and data that should be streamed via http.

Thanks in advance for any help.

Regards
Jeff Cumpsty

here is my function to get the data from the url...

Private Function InternetCallBack(ByVal url As String, ByRef ctrl As
LettersClientCtrl) As String
Const FUNCTIONNAME As String = "InternetCallBack"

On Error GoTo Err_Handler
    
    Dim hOpen As Long
    Dim hOpenUrl As Long
    Dim sUrl As String
    Dim bDoLoop As Boolean
    Dim bRet As Boolean
    Dim sReadBuffer As String * 2048
    Dim lNumberOfBytesRead As Long
    Dim sBuffer As String
    Dim file As String

    ' determine the url to call.
    sUrl = url
    
    ' Open a connection to the server.
    hOpen = InternetOpenAPI(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG,
vbNullString, vbNullString, 0)
    If hOpen = 0 Then
        Exit Function
    End If
    
    ' Open a connection to the server side processing page.
    hOpenUrl = InternetOpenUrlAPI(hOpen, sUrl, vbNullString, 0,
INTERNET_FLAG_RELOAD, 0)
    If hOpenUrl = 0 Then
        Exit Function
    End If
    
    bDoLoop = True
    
    ' Get file size
    While bDoLoop
        bRet = InternetReadFileAPI(hOpenUrl, sReadBuffer, 1,
lNumberOfBytesRead)
        If (Left$(sReadBuffer, 1) = "#") Then
              bDoLoop = False
        Else
              file = file & Left$(sReadBuffer, 1)
        End If
        ctrl.ChangeProgress
    Wend

    ' Download the file from the server.
    bDoLoop = True
    While bDoLoop
        sReadBuffer = vbNullString
        bRet = InternetReadFileAPI(hOpenUrl, sReadBuffer,
Len(sReadBuffer), lNumberOfBytesRead)
        sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
        ctrl.ChangeProgress
        If Not CBool(lNumberOfBytesRead) Then
            bDoLoop = False
        End If
    Wend

    If hOpenUrl <> 0 Then InternetCloseHandleAPI (hOpenUrl)
    If hOpen <> 0 Then InternetCloseHandleAPI (hOpen)

    ' return the buffer to the calling routine. It can process it as
needed.
    InternetCallBack = sBuffer

    Exit Function
    
Err_Handler:
    If hOpenUrl <> 0 Then InternetCloseHandleAPI (hOpenUrl)
    If hOpen <> 0 Then InternetCloseHandleAPI (hOpen)
    Err.Raise Err.Number, ErrorSource(Err.Source, FUNCTIONNAME,
MODULENAME)
End Function

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Relevant Pages

  • Wininet Authentication Problem
    ... server, every call I make is being redirected to the Login Page. ... Private Function InternetCallBack(ByVal url As String, ... Dim hOpenUrl As Long ... Dim bDoLoop As Boolean ...
    (microsoft.public.inetserver.iis.security)
  • Wininet Authentication Problem
    ... server, every call I make is being redirected to the Login Page. ... Private Function InternetCallBack(ByVal url As String, ... Dim hOpenUrl As Long ... Dim bDoLoop As Boolean ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Need Help | Rolling out new App. | Trouble with some computers
    ... Server as the back end. ... Option Compare Database ... Dim varReturn As Variant ... Dim lngAuth As Long, strDept As String, strFirst As String, strLast ...
    (microsoft.public.access.modulesdaovba)
  • Re: strange problem with smtpmail
    ... Note that remote server is a BLS server but a windows ... e-mails are send but arrive as HTML source instead of formatted HTML ... Public Function SendMailMessage(ByVal Recipient As String, ... Dim mMailMessage As New MailMessage ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Desperately need help to setup with asp net !!
    ... must be done by the Vb.net application on the server. ... What I have hard time to implement is passing data from the browser to ... Dim strConnection As String ... Dim con As New Data.SqlClient.SqlConnection ...
    (microsoft.public.dotnet.framework.aspnet)