Wininet Authentication Problem

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

  1. Can anyone help?

    We have an internal web application which uses a proxy to handle user
    authentication.

    Sessions, and Authentication are handles by a client side cookie.

    I have a requirement to download files from the server to the client
    and process them with data (they are word documents).

    THe application works fine outside the authenticated environment, but
    once the security is put into it, I can not access my download
    scripts.

    Server side code is asp.net, C#. Client side has to be VB6, and is
    presently using Wininet.dll.

    Does anyone know how I can get the session from the web page, and pass
    it into the VB6 ActiveX Control that resides on it?

    Regards
    Jeff Cumpsty
    Jeffrey Cumpsty, Jan 19, 2005
    #1
    1. Advertising

  2. 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

    -----------------
    This posting is provided as-is. It offers no warranties and assigns no
    rights.

    See http://weblogs.asp.net/feroze_daud for System.Net related posts.
    ----------------

    "Jeffrey Cumpsty" <> wrote in message
    news:...
    > Can anyone help?
    >
    > We have an internal web application which uses a proxy to handle user
    > authentication.
    >
    > Sessions, and Authentication are handles by a client side cookie.
    >
    > I have a requirement to download files from the server to the client
    > and process them with data (they are word documents).
    >
    > THe application works fine outside the authenticated environment, but
    > once the security is put into it, I can not access my download
    > scripts.
    >
    > Server side code is asp.net, C#. Client side has to be VB6, and is
    > presently using Wininet.dll.
    >
    > Does anyone know how I can get the session from the web page, and pass
    > it into the VB6 ActiveX Control that resides on it?
    >
    > Regards
    > Jeff Cumpsty
    Feroze [msft], Jan 21, 2005
    #2
    1. Advertising

  3. 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!
    Jeffrey Cumpsty, Jan 24, 2005
    #3
    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,263
    =?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,029
    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:
    785
    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:
    391
    Jack Gibson
    Sep 11, 2005
  5. Jeffrey Cumpsty

    Wininet Authentication Problem

    Jeffrey Cumpsty, Jan 21, 2005, in forum: ASP .Net Security
    Replies:
    0
    Views:
    133
    Jeffrey Cumpsty
    Jan 21, 2005
Loading...

Share This Page