impersonation

Impersonate user in codebehind

末鹿安然 提交于 2019-11-30 15:14:05
问题 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 implement impersonation in an ASP.NET application I'd like direction on how/where to start the debugging process. Here are my files: Test.aspx: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="TraceFile_Test" %> <!DOCTYPE

Impersonate user in codebehind

痴心易碎 提交于 2019-11-30 13:59:01
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 implement impersonation in an ASP.NET application I'd like direction on how/where to start the debugging process. Here are my files: Test.aspx: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="TraceFile_Test" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional

Copy files over network via file share, user authentication

寵の児 提交于 2019-11-30 06:57:33
I am building a .net C# console program to deploy file to a windows file share server (folder that is being shared). The path is :: \\192.168.0.76\htdocs\public On running I am getting the error: [09:35:29]: [Step 1/3] Unhandled Exception: System.UnauthorizedAccessException: Access to the path '\\192.168.0.76\htdocs\public' is denied. [09:35:29]: [Step 1/3] at DeployFileShare.Program.CopyDir(String source, String dest, String[] exclude, Boolean overwrite) [09:35:29]: [Step 1/3] at DeployFileShare.Program.Deploy(String num, String source) [09:35:29]: [Step 1/3] at DeployFileShare.Program.Main

Impersonation and NetworkCredential

偶尔善良 提交于 2019-11-30 05:13:23
I need to pass a NetworkCredential object with the credentials of the currently impersonated user to a web service from an asp.net application. My code looks like this: WindowsIdentity windowsIdentity = HttpContext.Current.User.Identity as WindowsIdentity; WindowsImpersonationContext context = windowsIdentity.Impersonate(); try { var client = GetClient(); client.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials; Log("WindowsIdentity = {0}", windowsIdentity.Name); Log("DefaultNetworkCredentials = {0}", CredentialCache.DefaultNetworkCredentials.UserName);

Application pool identity or Impersonation

为君一笑 提交于 2019-11-30 01:54:26
(A question of similar vein has been asked before but both the question and the accepted answer do not provide the detail I am looking for) With the intention of running an asmx web service under a dedicated domain account what are the usage scenarios and/or pros and cons of using an Application Pool with the identity of the domain account versus Impersonation? We have 3 small internal web services that run under relatively low load and we would like to switch them to running under their own domain accounts (for the purpose of integrated security with SQL Server etc). I appear to have the

Impersonate with username and password?

五迷三道 提交于 2019-11-30 00:46:17
WindowsIdentity identity = new WindowsIdentity(accessToken); WindowsImpersonationContext context = identity.Impersonate(); ... context.Undo(); Where do i declare a administraotr UserName and Passowrd ? the accessToken param doesn't help me too much... Do I have to import DLL'S for it ? Stefan You need to get the user's token. Use the p/invoke LogonUser from the advapi32.dll: [DllImport("advapi32.dll", SetLastError = true)] public static extern bool LogonUser( string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken); Example: IntPtr

Classic ASP page is impersonating NT AUTHORITY\ANONYMOUS LOGON

前提是你 提交于 2019-11-29 23:34:36
问题 We have a classic ASP application. I'm trying to clone it on the same server, with the same instance of IIS7, so we have a dev version. I copied the files, and duplicated all of the configuration that I can find in IIS manager. The problem is DB access. The new copy is using the same Application Pool as the old one and the same connection string, but when I create ADODB.Connection and call conn.Open(str) with the same old connection string, that call throws "Login failed for user 'NT

System.Diagnostics.Process impersonating other user

笑着哭i 提交于 2019-11-29 16:19:02
I have the following code which is working. My callback method is called with the program's output as it is generated. var proc = new System.Diagnostics.Process(); //proc.StartInfo.Domain = DOMAIN; //proc.StartInfo.UserName = USERNAME; //proc.StartInfo.Password = BuildPasswordString(); proc.StartInfo.UseShellExecute = false; proc.StartInfo.FileName = EXEC_PATH; proc.StartInfo.Arguments = EXEC_ARGS; proc.StartInfo.RedirectStandardOutput = true; proc.Start(); proc.OutputDataReceived += proc_OutputDataReceived; proc.BeginOutputReadLine(); proc.WaitForExit(); However, as soon as I uncomment those

Impersonate admin account to edit registry key not working (C#)

可紊 提交于 2019-11-29 15:43:59
I am using the following code to edit a registry key in the local machine hive ('SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\%SID%'). Everything seems to be fine until I actually try to open the registry key (with write permissions); a SecurityException is thrown with the message 'Requested registry access is not allowed.' I've checked and rechecked the permissions for the registry key and the user I'm impersonating and it all checks out. The code runs fine when logged into the impersonated user's account, but when logged in as a restricted user, it fails. It's as if the

Starting remote Windows services with ServiceController and impersonation

谁说胖子不能爱 提交于 2019-11-29 14:42:40
I have a .NET MVC3 application that needs to be able to turn a remote service on and off. In order to do this I am impersonating a specific user account via WindowsIdentity.Impersonate(). To test the user's permissions I can log in as the user and execute sc.exe \\[server] start [service] from the command prompt. I also know that the impersonate command is working as expected because the application runs anonymously and therefore cannot control services on my local machine ( . ) without impersonation, but can control local services with impersonation. However, when I put it together and