impersonation

Impersonation and NetworkCredential

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 { va...

Copy CD contents from cd storage server to network share

Hi all, I need to write a webapp (asp.net MVC) that copies the contents from a CD to a network share (eg. Z:\dir1). All servers are in the same domain. Process flow is as follows: - User inserts CD-ROM into cdserver1 (PrimeArray ProServer 3802 XT) - CD contents is copied to internal HDD automatically - User enters CD information in the ...

Connection problem from published Web Service to Microsoft Outlook Application

I know that this question has been asked before here, I used to have the same problem as Anjisan, I have a web service that could call Outlook Application from Visual Studio but couldn't from published code on IIS thanks to the Accepted Solution it worked on my pc when i published my web service to IIS by following this steps: (1)Enter ...

How can I impersonate a webservice file (asmx) from code?

Hello, Until recently, I've used the "<impersonate >" tag in web.config, followed by proper credentials. Now I'm trying to add another asmx file, that will impersonate to a different account, and trying to do that from code. Question is - How to impersonate (on every request) from code in an asmx file (webservice) ? (I'm using C#) I...

How do I authenticate via WCF and run under user impersonation in IIS at the same time?

I've migrated some code from plain old web services in .Net 2.0 to WCF but I missed a requirement in the code and now have an issue. The new WCF services take the currently logged on domain user and pass their details through to the server so they don't need to sign on. This means all WCF services run under the context of the user acces...

Cannot delete file in share using impersonation on ASP.NET site.

We have a web farm and are writing temp files for reports. We set up a file share and are using impersonation to write the temporary report files to that share. We gave the account doing the impersonation full control to the share and the folder itself. The files are writing correctly but are not being deleted. Is there something we're ...

Classic ASP Impersonation problem on IIS7 Windows 2008 server

Hi, I am trying to write to a file on a server (web05) from a classic asp site running on Windows 2008 serer on IIS7 (webadmin). This fails and web05 logs an anonymous logon attempt during the course of the save operation. Webadmin's site is running on an app pool in classic mode with a domain user as the process account. The process ...

Create a virtual directory in iis 6 programatically using vb.net as unprivileged user

I'm trying to write an application that will allow a non-administrator user to create virtual directories in IIS6. I've tried numerous different ways of impersonating a administrative account but nothing seems to work to create the virtual directory. Here's some of what I've tried: dim sDirPath as string = "IIS://remotehost/W3svc/1/ro...

ASP.NET Impersonation in web.config vs. running the app pool with custom identity

Ok so I'm using ASP.NET MVC. I'm supposed to upload a file and write it to a network share. I'm getting "Logon failure: unknown user name or bad password." when I try to write to the network location. I solved it on my machine by impersonating the file server account, added this to web.config: <identity impersonate="true" userName="xx...

How to access network share from moss 2007 web part using logged in user identity

We want to list files residing in a network share directory from the MOSS 2007 website web part. To do so i have impersonate the logged in user while accessing the network share directory using following code IPrincipal p = System.Web.HttpContext.Current.User; WindowsIdentity id = (WindowsIdentity)p.Identity; // impersonate temporaril...

WindowsIdentity.Impersonate and PostBack issue

I am writing an ASP website that uses Forms security and Active Directory. I allow the user to login using the Windows API: [DllImport("advapi32.dll", SetLastError = true)] public static extern bool LogonUser(string pszUsername, string pszDomain, string pszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); This give...

Possible to use Impersonation when launching a non-exe process in C#?

I need to be able to run a process as a different user, and I've found plenty of resources and different methods to do this. The problem is, I need to run a non-exe process, e.g. a path with html extension, or in my case, "http://somewebserver/someApp.application". There's a known problem in which launched processes don't inherit imper...

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 profile. I want to be able to do something like /my-profile/?__user_id=123 and have the u...

Impersonated process will not log on to Oracle with Windows Authentication

Hello. I am running a asp .net web service on IIS7. The latter is running on a Windows 2008 R2 Server. IIS7/the web service is configured for asp .net impersonation. The worker process owner is set to NETWORK SERVICE. The web service invokes sqlplus.exe impersonated with his/her domain account on the server. I can see that through the...

Creating local machine accounts using ASP.NET MVC

We are trying to create a web interface allowing local user accounts to be created on the web server. Only local administrators can have this right. It cannot be delegated under the local security policy. These are approaches we have tried so far: Running the Application Pool as a local administrator: this does work, but its not an a...

How to impersonate another user?

Hi there I'm working on an ASP.net app and i'm trying to impersonate a user I'm creating a windowsIdentity with a token WindowsIdentity winId = new WindowsIdenty( token ); this token was got by calling the un managed code [DllImport("advapi32.dll")] public static extern int LogonUserA(String lpszUserName, String lpszDomain, ...

Using WindowsIdentity to get a list of files/directories in ASP.NET while logged in using Forms Authentication

Edit 6: Using Windows Integrated authentication (with an account that has access to the share and the database), I can get the list of files/directories. However, refresh the page and get an UnauthorizedAccessException. Perhaps a NetBIOS or ActiveDirectory limitation. 5 months and still no solution, other than 'use impersonation' (via P...

Impersonation in windows application

Hello, I've written an extremely simple program to load an xml from one path and store it in All Users/Application Data. But i'm getting access denied error. So i want to impersonate the admin account and save the file. How to do that? Thank you. Regards NLV ...

How to open a file stored in a server from aspx page using UNC share path?

I am listing the files stored in a remote server in the aspx page grid view with the file name linked (href) to the UNC path of the file. when the user clicks the file name link, it should open the file from the server to allow the user read the file. I am using impersonation (Using mirror logon method) for file upload and delete in the ...

Is passing a windows security token between processes permitted

Imagine I have an existing process running under windows as a particular user. Would it be permitted for that process to take its current token (with something like OpenThreadToken and DuplicateTokenEx), pass it to another process on the same machine (perhaps through a network socket or some other IPC), and then expect that process to be...