Questions tagged [impersonation]

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

1522 questions
9
votes
3 answers

Windows Impersonation: A Flaw in the Ointment

In my journey to master the nuances of user impersonation in Windows I first had an issue about getting impersonation to a remote database to occur at all (see this SO question) but I finally figured that out. My next hurdle is…
Michael Sorens
  • 35,361
  • 26
  • 116
  • 172
9
votes
3 answers

System.DirectoryServices.AccountManagement.UserPrincipal - localhost but not iis

Why does the code below work fine when I run my web application localhost but not when I install it to an IIS server? using (HostingEnvironment.Impersonate()) { UserPrincipal activeUser = UserPrincipal.Current; String activeUserSid =…
RichardD
  • 315
  • 1
  • 4
  • 11
8
votes
2 answers

Can I impersonate a user on a different Active Directory domain in .NET?

I have two Active Directory domains, A and B. Users in domain A need to run an application on their desktops to view and manipulate a resource located on a server in domain B. Each user also has an account in domain B. Is it possible to…
John Ingle
  • 1,490
  • 2
  • 11
  • 12
8
votes
3 answers

Why doesn't LogonUser(...) work for domain accounts?

I've been trying to use LogonUser(...) to get an access token for a user account, as in this MSDN sample. // Call LogonUser to obtain a handle to an access token. bool returnValue = LogonUser(userName, domainName, Console.ReadLine(), …
GraemeF
  • 11,327
  • 5
  • 52
  • 76
8
votes
2 answers

Impersonate user over a VPN in a desktop application

I'm having problems trying to impersonate an active directory user in a desktop application. Every time I use the LogOn API the result is false. The user and domain do exist since I can also authenticate the user over the…
8
votes
2 answers

Is it possible to unit test a class that makes P/Invoke calls?

I want to wrap a piece of code that uses the Windows Impersonation API into a neat little helper class, and as usual, I'm looking for a way to go test-first. However, while WindowsIdentity is a managed class, the LogonUser call that is required to…
Rytmis
  • 31,467
  • 8
  • 60
  • 69
8
votes
1 answer

App Domain Level Impersonation

I am developing an application that needs to load plug-ins into separate child app domains. Only one plug-in is loaded into one child app domain. Each plug-in requires different Windows identity and those identities are different from the Windows…
user595010
8
votes
1 answer

Impersonate user in codebehind

I'd like to impersonate a specific user in code to perform some file manipulation on a remote machine. The problem I'm having is that I am unable to get impersonation to work. I'm using the code from the Microsoft article found here: How to…
zeroef
  • 1,949
  • 23
  • 32
8
votes
3 answers

How do I configure IIS so that the user's domain credentials are used when connecting to SQL server?

We've recently released the latest version of our intranet application, which now uses windows authentication as standard, and needs to be able to connect to a configured SQL server with the end-user's domain credentials. Lately we've found that on…
Matt Winward
  • 1,255
  • 2
  • 15
  • 43
8
votes
3 answers

Process.Start() impersonation problem

Trying to start process with another access token, without success, it runs as the non-impersonated user. using (WindowsIdentity identity = new WindowsIdentity(token)) using (identity.Impersonate()) { Process.Start("blabla.txt"); } How to make…
DxCK
  • 4,402
  • 7
  • 50
  • 89
8
votes
2 answers

Execute SSIS package from stored procedure as proxy user without xp_cmdshell

I am trying to run an SSIS package through a stored procedure, but I am getting an Access is denied error when I try to import a CSV. I put the package inside a job and ran it and it worked as long as I used a proxy account. I am trying to replicate…
8
votes
2 answers

Impersonation in ASP.NET MVC

I have an Action that needs to read a file from a secure location, so I have to use impersonation to read the file. This code WORKS: [AcceptVerbs(HttpVerbs.Get)] public ActionResult DirectDownload(Guid id) { if…
Emad
  • 4,110
  • 5
  • 30
  • 35
8
votes
3 answers

Package.Open Requested registry access is not allowed

We are calling System.IO.Packaging.Package.Open() in an ASP.NET application. Further, a Windows impersonation has been performed before calling this because the package to be opened is stored in a secure location and the impersonation is required…
Mont
  • 301
  • 3
  • 10
8
votes
1 answer

LogonUser, LOGON32_LOGON_INTERACTIVE and LOGON32_LOGON_NETWORK

Can anyone provide a clear explanation of the difference between LOGON32__LOGON_INTERACTIVE and LOGON32_LOGON_NETWORK when used with LogonUser? The MS documentation is here. But I'm not clear what should be used. The scenario is similar to a telnet…
Bruce Blackshaw
  • 986
  • 1
  • 7
  • 10
8
votes
2 answers

Is it possible to impersonate a user without logging him on?

Is it possible to impersonate a user without supplying user name/password? Basically, I'd like to get the CSIDL_LOCAL_APPDATA for a user (not the current one) using the ShGetFolderPath() function. All I currently have is a SID for that user.
dennisV
  • 1,119
  • 3
  • 19
  • 34