Will
Will

Reputation: 1164

App.Config Vs Web.Config

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

Upvotes: 0

Views: 1339

Answers (3)

Carlos Landeras
Carlos Landeras

Reputation: 11063

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?

Upvotes: 1

Thorsten Dittmar
Thorsten Dittmar

Reputation: 56697

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.

Upvotes: 0

Mentok
Mentok

Reputation: 597

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.

Upvotes: 0

Related Questions