Need to Impersonate user forAccessing Network resource, Asp.Net Account

16,059

Solution 1

Just calling LogonUser is not enough. You need to impersonate that user. You can impersonate for just the access to the network resource.

Sample code can be found on MSDN.

Solution 2

You could add an

<identity impersonate="true" userName=""/>

tag to your web.config but that might not be ideal as you probably don't want to run the entire site as that user...

Can you map the network share as a local drive with the DomainName & Password... and then pull files to the website via the mapped drive ?

NET USE Z: \\SERVER\Share password /USER:DOMAIN\Username /PERSISTENT:YES
Share:
16,059
SharePoint Newbie
Author by

SharePoint Newbie

Updated on June 04, 2022

Comments

  • SharePoint Newbie
    SharePoint Newbie almost 2 years

    I need to access a network resource on which only a given Domain Account has access. I am using the LogonUser call, but get a "User does not have required priviliege" exception, as the web application is running with the asp.net account and it does not have adequate permissions to make this call.

    Is there a way to get around it? Changing the identity or permissions of the ASP.Net account is not an option as this is a production machine with many projects running. Is there a better way to achieve this?

    Using Asp.Net 2.0, Forms Authentication.

    Kind Regards.