0

Basically I'm needing to do this in app.config:

<system.web>
       <identity impersonate="true" userName="Username" password="Password"/>
</system.web>

How do I accomplish this? Currently been researching this with no luck? any help would be very much appreciated

Will
  • 1,084
  • 5
  • 20
  • 42
  • `identity` is part of `web.config`. What exactly you want to acheive – Satpal Jun 27 '13 at 12:25
  • I'm building a console app and I'm getting access denied when I call the exe. I did the exact same thing in a web app and use the impersonate code above not getting the error – Will Jun 27 '13 at 13:00

3 Answers3

1

USe NetworkCredential class:

NetworkCredential myCred = new NetworkCredential(
    SecurelyStoredUserName,SecurelyStoredPassword,SecurelyStoredDomain);

It will allow you to enter websites, access remote shared folders , etc...

By the way, what are you trying to achieve?

Carlos Landeras
  • 11,025
  • 11
  • 56
  • 82
0

I'm not sure you can impersonate from the app.config - What you might need to do is launch a process in your code that impersonates another user. Take a look at this related post.

Community
  • 1
  • 1
Mentok
  • 597
  • 4
  • 6
0

You can not impersonate another user like that in a desktop application. Look into impersonation. One question that might help you is this one. This entry on CodeProject implements a C# class that helps you impersonate another user.

Community
  • 1
  • 1
Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139