How to impersonate a user for the session

Posted on 2008-11-05
Last Modified: 2012-08-14
I have an asp app. I want to store some pdf documents in a folder that I have disabled anonymous access. Right now when I go to the folder I get a prompt for a user and password. I have already authenticated them via my own app. I would like to pass or impersonate a user account for the that folder. I need to be for the whole session. how would I accomlish this. This is not

I have been trying this code, but when I go to the folder I still get a prompt:

     Dim objLogon

     ' create an object for impersonating IIS to use a valid domain user instead of anonymous user IUSR_machinename
     Set objLogon = Server.CreateObject("LoginAdmin.ImpersonateUser")

     ' any domain user who has rights to access active directory
     objLogon.Logon "USERNAME", "PASSWORD", "DOMAIN"
Question by:jrking1978
    LVL 16

    Expert Comment

    Please have a look at

    This will explain how to impersonate a user from Active Server Pages.

    Author Comment

    That is what the code is from above. I have a page outside the folder that I have secured. It has a link to a file inside that folder. I out the above code on the page to force it to log in. When I load the page, I do not get an error. but when I click the link to go to the file inside the secure folder I get the pop up prompt asking me for my username and password.

    Accepted Solution

    I ended up using a streaming object and put the file on my server in a place that was not being published

    Set objStream = Server.CreateObject("ADODB.Stream")
    LVL 16

    Expert Comment

    Ok. Sorry the example didn't help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Lync server 2013 Backup Service Error ID 4049 – After File Share Migration
    Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now