impersonation

Open a shared file under another user and domain?

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 usernam...

C#: Eventlog, impersonation and Access Denied Win32Exception

Hi, I am using a dedicated account (with SDDL policy) to write event log entries to a custom event log. For this I use WindowsImpersonationContext and obtain a token with LogonUser: WindowsIdentity impersonationIdentity = new WindowsIdentity(ptr); WindowsImpersonationContext impersonationContext = impersonationIdentity.Impe...

impersonation for windows service using config file

Currently to run windowsservice as a fixed user we set the logon properties on the windows service (where we specify the username and password to run as). but iam willing to have this feature of running the windows service as a fixed user as impersonation in web application mentioned in the config file. kindly throw your thoughts on t...

Impersonating users through NTLM

I have an internal application which has two levels of security. FormsAuthentication for client-facing application and NTLM Integrated authentication for management interface. I can easily impersonate clients by just creating the proper .ASPXAUTH cookie with the FormsAuthentication class' methods. However generating HTTP Authentication ...

Impersonate FormsAuthenticated user in HttpHandler for WCF call

I'm using HttpHandlers to generate PDF report files "on-the-fly" using the authenticated user context. However, to create the report PDF file I need to call a method on a secure WCF service with the context of the caller (the authenticated user). I saw plenty of answers for the Windows authentication but I'm using plain old Forms authen...

"Impersonated" User Not Propagated To SQL Server 2000

I need to "impersonate" a user in a VB.NET 2008 WinForms application, so that the application can accept the Active Directory login of any user on a PC regardless of who is actually logged in to Windows. I want the application's My.User to be the AD account of the person who logged in to the application. I succeeded in this with the foll...

A proper way to access files on different machine using C#

I want to read files off of different windows machine on the same network, NOT part of the same domain though. (ASP.NET C# app) Tried FileStream (can't authenticate), tried FileWebRequest (reverts to FileStream when file:/// is used), and impersonation (support.microsoft.com/kb/306158#4) Which says "impersonation failed" on my Vista. Upd...

Why can't I open a file using impersonation on a remote machine?

I have a WCF service written in C# being hosted on a remote machine, running as the local administrator account. From my machine logged in as an active directory user, I am sending a command that simply tells it to open a file on the network. I have access to the file, but the administrator account on the host machine does not. I'm using...

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

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 runn...

Asp.Net Impersonation over a VPN

I'm doing a spot of development from home over a VPN. The project is an Asp.Net 2.0 (Using 3.5 SP1) app that uses impersonation. The account that is impersonated is on the domain at work but when ever I attempt to run the app I get the following error: 'Logon failure: unknown user name or bad password.' The impersonation is requ...

A .NET custom attribute to perform impersonation?

I have some methods that need to run as a certain service account, so I do the normal thing: public DoSomeWorkAsServiceAccount() { ... // assume I am given tokenHandle WindowsIdentity newId = new WindowsIdentity(tokenHandle); WindowsImpersonationContext impersonatedUser = newId.Impersonate(); ... // do the work...

Possible to impersonate in app.config for console application?

I know you can impersonate in web.config, Is the exact same thing possible in app.config for a console application? ...

ASP.NET impersonation credentials

In my app's config there is a impersonation tag containing username and password and I'm wondering what should these credentials be to make the app work - are these the credentials of some user in the domain or the IIS server or what? ...

Network logon from an impersonation token

In a service impersonating a client (using ImpersonateNamedPipeClient), I try to call CreateProcessAsUser. The executable filename is a UNC path located on a third computer (neither the server, nor the client connected to the pipe). The call fail with the error code 5 (ACCES DENIED). I tried to use WNetAddConnection2 to authenticate the...

Impersonate User for Silverlight Unit Test

I'm attempting to write some tests using the Silverlight Unit Test Framework (the unsupported, unofficial MS library Microsoft.Silverlight.Testing). I need to impersonate three different users when testing some functionality of our application. Our application is for internal use at our company, so the authenticated user may get differe...

Desktop and application menu freezes after ImpersonateLoggedOnUser

Hi. I use the following to elevate the rights of a c++ windows application: LogonUser() LoadUserProfile() ImpersonateLoggedOnUser() The functions do their work and there is no error. But as soon as I want to interact with my application again (clicking on a menu like "File" "Edit", and even right clicking on the desktop) the applicati...

How to get/set data of(into) visual components (of winodws programs) programmatically?

Let me clarify the question a bit. I am talking about windows GUI programs. Say a program-window has a dialog box (or a confirm button) asking user input. How can I provide input to that program using my program (written in say C#, Java or Python). Or say, a program window is showing some image in one of its panels. How can I grab that f...

Is it possible to create a NetworkCredential object from the current HTTP context?

This is related to this question which hasn’t had much success in the context of SharpSVN so I’m rephrasing in a pure .NET security context. I’m wondering if it’s possible to create a NetworkCredential object based on the current logged on user in an ASP.NET app without explicitly requesting username and password (it’s an integrated auth...

Can I programmatically do a "net use" on a file share?

Within a VB.NET program, I want to read files from a filesystem, then write a compressed version of those files to a remote, secure fileshare, using different credentials. The analogous operation at the cmd prompt is: net use s: \\server\share /user:foo P@ssw0rd copy a+b | compress > s:\foo.bin net use s: /delete Is this possible? ...

Impersonation in ASP.NET MVC

I have a MVC web application on an intranet and want to be able to create files on our FTP server to send to outside partners. The code for impersonation uses the WindowsImpersonationContext. System.Security.Principal.WindowsImpersonationContext impersonationContext; impersonationContext = ((System.Security.Principal.WindowsIdentity)U...