impersonation

Start a .Net Process as a Different User

南楼画角 提交于 2019-11-26 03:29:06
问题 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 m_impersonatedUser; #region Win32 API Declarations const int LOGON32_PROVIDER_DEFAULT = 0; const int LOGON32_LOGON_INTERACTIVE = 2; //This parameter causes LogonUser to create a primary token. [DllImport(\"advapi32.dll\", SetLastError = true)] public static

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

南笙酒味 提交于 2019-11-26 02:17:47
问题 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 blank. Is it possible to get the user\'s windows account name even though the site is running impersonated? Edit: Here\'s a little more info. I have a site in IIS 6 running with anonymous access enabled. The site is running under a system account

Windows Impersonation from C#

坚强是说给别人听的谎言 提交于 2019-11-26 01:59:13
问题 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 windows integrated security). Most important of all: Is there a way to do this without knowing the other user\'s password? Note: if a password is mandatory is there a recommended strategy for storing a password securely (c# and/or vbscript). 回答1: It

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

笑着哭i 提交于 2019-11-26 01:29:38
问题 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 impersonation, the idea being that the user who makes the request to the web application should be the user that the web application uses to make the request to the service. The structure looks like this: (The user highlighted in red is the user being referred

How do you do Impersonation in .NET?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-25 21:45:10
问题 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, (username, password, domain name) which represents the identity I need to impersonate. 回答1: Here is some good overview of .NET impersonation concepts. Michiel van Otegem: WindowsImpersonationContext made easy WindowsIdentity.Impersonate Method (check