Questions tagged [impersonation]

Impersonation is a process whereby an application assumes another identity or security context during execution.

1522 questions
203
votes
9 answers

How to get HttpClient to pass credentials along with the request?

I have a web application (hosted in IIS) that talks to a Windows service. The Windows service is using the ASP.Net MVC Web API (self-hosted), and so can be communicated with over http using JSON. The web application is configured to do…
adrianbanks
  • 81,306
  • 22
  • 176
  • 206
154
votes
7 answers

How do you do Impersonation in .NET?

Is there a simple out of the box way to impersonate a user in .NET? So far I've been using this class from code project for all my impersonation requirements. Is there a better way to do it by using .NET Framework? I have a user credential set,…
ashwnacharya
  • 14,601
  • 23
  • 89
  • 112
48
votes
7 answers

How to use LogonUser properly to impersonate domain user from workgroup client

ASP.NET: Impersonate against a domain on VMWare This question is what I am asking, but the answer does not provide details on how the _token is derived. It seems to only use WindowsIdentity.GetCurrent().Token so there's no impersonation…
RichardTheKiwi
  • 105,798
  • 26
  • 196
  • 262
47
votes
4 answers

How to get Windows user name when identity impersonate="true" in asp.net?

I'm creating an intranet asp.net mvc application that everyone in the company should have access to. I need to run the website impersonated for database access etc., but I want to know who each user is. When I look at Page.User.Identity.Name it's…
MrDustpan
  • 5,508
  • 6
  • 34
  • 39
39
votes
3 answers

Run Code as a different user

Is there a way to tell my code to run as a different user? I am calling NetUserSetInfo via a PInvoke and I need to call it as a different user. Is there a way to do that?
Vaccano
  • 78,325
  • 149
  • 468
  • 850
36
votes
2 answers

How can I fix the Kerberos double-hop issue?

I'm having some trouble calling a web service from within a web application and I was hoping someone here might be able to help. From what I can tell, this seems to have something to do with the Kerberos double-hop issue. However, if it is, I'm not…
Steve Platz
  • 2,215
  • 5
  • 28
  • 27
33
votes
3 answers

Windows Impersonation from C#

How can a C# program running as LocalSystem impersonate the login identity of another user temporarily? Roughly speaking I have a Windows Service that I'd like to run as LocalSystem but at times impersonate user XYZ (when connecting to a db using…
user53794
  • 3,800
  • 2
  • 30
  • 31
30
votes
3 answers

Impersonate tag in Web.Config

I'm using impersonate tag in my web.config in Asp.net 4.0 website. Below is my Web.Config code:
user572844
30
votes
3 answers

Start a .Net Process as a Different User

I want to start a Process with Admin rights. When I run the code below the Process complains saying it needs Admin rights: public class ImpersonationHelper : IDisposable { IntPtr m_tokenHandle = new IntPtr(0); WindowsImpersonationContext…
İbrahim Akgün
  • 1,527
  • 11
  • 37
  • 63
30
votes
1 answer

Run ExeCommand in customAction as Administrator mode in Wix Installer

I am new to wix installer. I have developed a set-up using wix installer for my application and I need to execute a Custom Action to run a command in cmd.exe. In XP it works fine. But in Windows 8 & 7 the cmd prompt needs to be run as…
Dah Sra
  • 4,107
  • 3
  • 30
  • 69
28
votes
8 answers

Django user impersonation by admin

I have a Django app. When logged in as an admin user, I want to be able to pass a secret parameter in the URL and have the whole site behave as if I were another user. Let's say I have the URL /my-profile/ which shows the currently logged in user's…
ibz
  • 44,461
  • 24
  • 70
  • 86
25
votes
1 answer

Impersonate user in Windows Service

I am trying to impersonate a domain user in a windows service with the service logged in as the Local System Account. So far, I am only able to get this to work by logging the service and set the process using the user credentials, like the…
H20rider
  • 2,162
  • 5
  • 29
  • 47
25
votes
1 answer

Impersonation in ASP.NET MVC

I have a MVC web application on an intranet and want to be able to create files on our FTP server to send to outside partners. The code for impersonation uses the WindowsImpersonationContext. System.Security.Principal.WindowsImpersonationContext…
Jason Kemp
  • 253
  • 1
  • 3
  • 6
24
votes
2 answers

WindowsImpersonationContext & Impersonate() not found in ASP.Core

I had the following in a .NET Framework 4.0 assembly: var newId = new WindowsIdentity(duplicateTokenHandle); WindowsImpersonationContext newId = ImpersonatedIdentity.Impersonate(); I'm porting it to ASP.Core, but WindowsImpersonationContext and…
BanksySan
  • 27,362
  • 33
  • 117
  • 216
24
votes
5 answers

Impersonate using Forms Authentication

I have an ASP.NET site that must use Forms Authentication and not Windows Authentication to access a ActiveDirectoryMembershipProvider. The site must use forms because they need a designed input form instead of the browser authentication popup that…
1
2 3
99 100