Wininet Authentication Problem

Discussion in 'ASP .Net Security' started by Jeffrey Cumpsty, Jan 21, 2005.

  1. Feroze,

    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


    Message 2 in thread
    From: Feroze [msft] ()
    Subject: Re: Wininet Authentication Problem


    View this article only
    Newsgroups: microsoft.public.dotnet.framework.aspnet.security,
    microsoft.public.inetserver.iis.security, microsoft.public.winhttp,
    microsoft.public.inetsdk.programming.wininet
    Date: 2005-01-20 17:53:34 PST


    Can you give more detail on what exactly the configuration is? I am
    assuming
    that you have a VB6 client using Wininet, to communicate with a
    server. The
    server side is written in asp.net/c#. It seems as if you want to pass
    some
    information into the vb6 control, which resides on the webapp.

    So, what problems are you having when you turn on security? WHat do
    you mean
    by "turning on security" ?

    --
    feroze
    Jeffrey Cumpsty, Jan 21, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TmVpbA==?=

    How to Use WinInet for FTP in vb.net

    =?Utf-8?B?TmVpbA==?=, Sep 21, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    1,253
    =?Utf-8?B?TmVpbA==?=
    Sep 21, 2004
  2. Jonathan Allen

    Re: How to Use WinInet for FTP in vb.net

    Jonathan Allen, Sep 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,005
    AlexL [Xceed]
    Sep 28, 2004
  3. Sjaakie Helderhorst

    wininet.dll, lastdllerror=6, what does it mean?

    Sjaakie Helderhorst, Feb 5, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    770
    Sjaakie Helderhorst
    Feb 5, 2004
  4. Jack Gibson

    wininet and ASP.NET server controls

    Jack Gibson, Sep 11, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    384
    Jack Gibson
    Sep 11, 2005
  5. Jeffrey Cumpsty

    Wininet Authentication Problem

    Jeffrey Cumpsty, Jan 19, 2005, in forum: ASP .Net Security
    Replies:
    2
    Views:
    142
    Jeffrey Cumpsty
    Jan 24, 2005
Loading...

Share This Page