impersonation

How to run an external command as a specific user in PHP

北慕城南 提交于 2019-11-28 02:17:44
问题 I thought of suPHP but that's not what I need. It doesn't serve to my purposes to run the whole PHP script as a different user. I just need to run one single linux command line as a different user. Is it possible? 回答1: You could try the shell_exec function and sudo edit : seeing as sudo prompts for a password, you'd might wanna use proc_open, which allows you to use pipes. See this comment for how to create a custom password pipe. 回答2: I believe you should try another approach. The "setuid".

LogonUser works only for my domain

佐手、 提交于 2019-11-28 01:28:42
问题 I need to impersonate a user using C#. I use the LogonUser Win32 API. This works fine when impersonating users from the same domain as the currently logged-in user. However I get "false" as response when I try to impersonate users from other domains. What can cause this? 回答1: You should try calling GetLastError right after LogonUser fail to see if any error information is given. http://msdn.microsoft.com/en-us/library/ms679360(VS.85).aspx There may be some issue with calling GetLastError from

How can I get elevated permissions (UAC) via impersonation under a non-interactive login?

梦想的初衷 提交于 2019-11-28 00:58:57
I have a class library that keeps system-wide configuration data in the registry (HKLM\Software\XXX). This library is used in various applications (services, windows forms, web apps, console apps) on various versions of Windows (XP, 2003, 7, 2008 R2). Because of this, the identity of the app is not consistent and may not even be a member of the machine's Administrators group. So I've created an AD domain admin user and do impersonation to gain write access to the registry. This works perfectly in XP/2003, but not in UAC-enabled systems (7/2008R2). It is my understanding that only interactive

Passthrough (impersonation) authentication with ASP.NET and TFS api

送分小仙女□ 提交于 2019-11-28 00:12:20
I'm trying to enable passthrough or impersonation authentication inside an ASP.NET website that uses the TFS2010 API. I've got this working correctly with Cassini, however with IIS 7.5 (Windows 7) something is going wrong. I found this blog post on the subject, and tried the following: private static void Test() { TfsTeamProjectCollection baseUserTpcConnection = new TfsTeamProjectCollection(new Uri(Settings.TfsServer)); // Fails as 'baseUserTpcConnection' isn't authenticated IIdentityManagementService ims = baseUserTpcConnection.GetService<IIdentityManagementService>(); // Read out the

Process.Start() impersonation problem

吃可爱长大的小学妹 提交于 2019-11-27 23:14:54
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 this work properly? You need to set the ProcessStartInfo.UserName and Password properties. With UseShellExecute set to false. If you only have a token then pinvoke CreateProcessAsUser(). Try this example from http://msdn.microsoft.com/en-us/library/w070t6ka.aspx private static void ImpersonateIdentity(IntPtr logonToken) { // Retrieve the Windows identity

Open a shared file under another user and domain?

此生再无相见时 提交于 2019-11-27 22:37:51
I have a C# console application that needs to read a shared file on a machine in another domain. When the application tries to access the file an exception occurs as the local user does not have permission to access the shared resource. Currently I overcome this problem manually by open the shared folder from the run and put the username and password into the windows authentication dialog then run the application. How can I do it programmatically? a) p/invoke LogonUser with LOGON32_LOGON_NEW_CREDENTIALS and create a new WindowsIdentity with the new token, then use normal file access. b) p

Impersonate user in Windows Service

允我心安 提交于 2019-11-27 20:09:43
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 following. ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = CommandDetails.Command; startInfo.WorkingDirectory = Settings.RoboCopyWorkingDirectory; startInfo.Arguments = commandLine; startInfo.UseShellExecute = false; startInfo.CreateNoWindow = true; startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; //

Impersonation the current user using WindowsImpersonationContext to access network drive

一笑奈何 提交于 2019-11-27 18:57:33
问题 I need to access a remote drive from a Web App. The drive isn't accessible to the ASP.NET process, so I want to impersonate the current user for the request. I saw some basic examples using WindowsImpersonationContext, and have tried the following. WindowsImpersonationContext impersonationContext = null; try { impersonationContext = ((WindowsIdentity)User.Identity).Impersonate(); file.SaveAs(filePath); } finally { if (impersonationContext != null) { impersonationContext.Undo(); } } I'm still

How to Start/Stop a Windows Service from an ASP.NET app - Security issues

假如想象 提交于 2019-11-27 18:12:35
Here's my Windows/.NET security stack: A Windows Service running as LocalSystem on a Windows Server 2003 box. A .NET 3.5 Website running on the same box, under "default" production server IIS settings (so probably as NETWORKSERVICE user?) On my default VS2008 DEV environment I have this one method, which gets called from the ASP.NET app, which works fine: private static void StopStartReminderService() { ServiceController svcController = new ServiceController("eTimeSheetReminderService"); if (svcController != null) { try { svcController.Stop(); svcController.WaitForStatus

Impersonation and CurrentUser Registry Access

南笙酒味 提交于 2019-11-27 17:53:11
问题 Environment: Windows XP SP3, C#, .Net 4.0 Problem: I'm attempting to add access to an impersonated users registry hive in an impersonation class and I'm running into issues based on the type of user being impersonated (or more accurately the limitation seems to be on the impersonating user). I was originally following an impersonation example from CodeProject which showed a call to LoadUserProfile() taking place after impersonation was started using a duplicate token generated througha call