Click here to Skip to main content
15,898,771 members
Everything / Impersonation

Impersonation

impersonation

Great Reads

by gmaran23
Enumerate remote processes and services with a Windows Identity that is part of the local Administrator’s group.
by Karthickeyan.k
Running a process as the user that began the install, when creating a Deployment Project
by ASP.NET Community
Sometimes you'll find it necessary to impersonate the user's identity on a thread with an ASP.NET.  You may also need a delegate access the user to
by Member 10262330
I developed this DLL to have a more powerful utility and to simplify SP and query.

Latest Articles

by Member 10262330
I developed this DLL to have a more powerful utility and to simplify SP and query.
by ASP.NET Community
Sometimes you'll find it necessary to impersonate the user's identity on a thread with an ASP.NET.  You may also need a delegate access the user to
by gmaran23
Enumerate remote processes and services with a Windows Identity that is part of the local Administrator’s group.
by Karthickeyan.k
Running a process as the user that began the install, when creating a Deployment Project

All Articles

Sort by Score

Impersonation 

18 Jan 2011 by #realJSOP
The best I can do is provide a link to the MSDN documentation because your question isn't providing enough information to provide any semblence of a more accurate answer. Instead of posting code, go to this link and READ THE INFORMATION THOROUGHLY. It just indicate might what you're doing...
27 Jun 2011 by TheyCallMeMrJames
Asma, this is no small task and the question you're asking isn't really specific enough for this forum.You can make use of libraries such as AForge.net[^] which will have you on your way down this kind of development, but you'll have to do the heavy lifting on your own.Facial recognition...
4 Aug 2015 by Dave Kreskowiak
It's not that the workstation has your permissions. YOU have the permissions. Well, your account does. Anything you launch is launched AS YOU and inherits your secruity token.This includes the IIS Express web server that is launched when you debug your site on your dev machine. Since it's...
18 Jan 2011 by Devadutta Achary
Hi All, I am trying to run an application under a different logon user account. For this I am using the the function CreateProcessWithLogonW(). But I am not able to achieve the requirement. Any help is appreciated. Thanks in advance.
18 Jan 2011 by Nish Nishant
In addition to John's MSDN links, here's a fairly comprehensive article article on this topic here on Code Project:GUI-Based RunAsEx[^]
8 Apr 2011 by wooga111
Hello All,I am creating a web application that has a database. To log onto that database by impersonating a user with right to the db in the web.config file:This impersonate works correctly and I am able to get to the database with no problems.On page init I need to check to see...
15 Nov 2011 by Member 1216111
Hi friendsBackground of my question is a monitoring solution (SCOM) that I have to provide for others in the department.I like to have the possibility that I can see the same what the other employes of each usergroup can see. As I'm working with more rights as the others I always have...
24 Nov 2011 by RaisKazi
Try by providing Full-Rights permissions to "IIS_IUSRS" and "Network Services" Accounts to your Folder in which you are uploading Files.
16 Jul 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Go for - ASP.NET Authorization[^].Nice Article on CodeProject - ASP.NET authentication and authorization[^].Another Example - what is authorization in asp.net | authorization rules in web.config to allow or deny resources to particular user or role in asp.net.[^].You can also refer...
30 Sep 2014 by virang_21
You can use slightly different variant of LogonUser[^]IntPtr lnToken; Console.WriteLine("User Before Impersonation : " + WindowsIdentity.GetCurrent().Name); int TResult =...
17 Jun 2016 by Dave Kreskowiak
The user you impersonate has to have permissions to the network share you're trying to open the file from.Also, a UNC path is \\servername\sharename\folderpath\filename
8 Apr 2011 by Ramu Sangabathula Original
Not sure, I have created a sample with impersonation and checked whether the signed in user belong to a role or not, and without impersanation also, both gave me positive results. Not sure why you are facing the issue. can you send me your code to repro. But if you want to connect to database...
13 Apr 2011 by 23741
What is the safest (and easiest way) for an ASP.NET MVC application to do impersonation in a section of code where an uploaded file can be written to a network share (in the same domain)? I am trying to avoid anything to do with "act as part of the operating system" type priveleges.I do...
13 Apr 2011 by Peace ON
I have come across few links regarding Impersonation in Asp.NET MVC while googling.http://stackoverflow.com/questions/1909114/impersonation-asp-net-mvc-controller-action-vs-web-formshttp://stackoverflow.com/questions/1405612/impersonation-in-asp-net-mvcFind it helpful for your...
3 Aug 2011 by Member 8105804
I am having trouble getting the correct type of impersonation token using WindowsIdentity.impersonate(). My code attempts to access a file share using the account of the user who is running it, who has been denied access to it. When this process fails the I attempt to impersonate the...
3 Aug 2011 by Espen Harlinn
"My code attempts to access a file share using the account of the user who is running it, who has been denied access to it. When this process fails the I attempt to impersonate the Administrator account"Sounds like things are working as they should - you need the administrator password...
2 Nov 2011 by Chris Niedbala
I have a Windows Server 2008 domain controller that shares out a particular file folder on the network. I have developed an ASP.NET app that allows outside clients (via the Internet) to browse this folder and download documents (based on permissions handled by the app). In order to bolster...
24 Nov 2011 by here_is_kunal
When I trying to upload an image file to webserver using ASP.NET it through an exception "Access denied". I've used the following code to upload image file: ImageUploader.PostedFile.SaveAs(Server.MapPath(imagePath) + imageName);But, When I try to upload an image file by classic asp in...
24 Nov 2011 by koolprasad2003
yes give full rights to Network Services user as RaisKazi told.in Impersonation use UserId and Password. Impersonation suggest on whos behalf you are running web application
26 Mar 2012 by Manjunathabe011
Hi All,I have a scenario where I need to do double hop authentication. I want to Impersonate the Users in WCF service layer but want to pass the same Windows credentials of Client to DAL. My DB needs windows authentication. How can I achieve this. Thanks,Manju
26 Apr 2012 by andrew_dk
I've developed a COM+ server component (dll) that uses the ITaskScheduler and ITask interfaces to create and edit tasks for a specific .exe also created by the company I work for. The component is called from a classic ASP page (VBScript) and is part of an office package we are developing. The...
1 Jul 2012 by Zoltán Zörgő
To have all extension associations, your user needs a full profile. As I know, no logonType is creating or loading the profile for you. Here I found something you might find of use:...
8 Oct 2012 by WebMaster
Hello all,I'm tring to use the Impersonator class to copy a file from a PC to a server in another domain (without trust), but I receive the error in the object. using (new Impersonator("username", "domain", "password")) { File.Copy(@"C:\Temp", targetPath); }in detail the issue is...
10 Oct 2012 by Blake Miller
Do you impersonate the user prior to the COM calls?COM call could be executing in different thread, for which your impersonation is not set.
10 Oct 2012 by chaau
Make sure your IUsr_... user has SeImpersonatePrivilege privilege. The easiest way to check and/or set it is via secpol.msc. Go to User Rights Assignments->Impersonate a client after authentication and add the IUsr_... user there
4 Jul 2013 by _mak
Is it possible to assign roles using the Exchange web services in c#? Like you programatically automate of adding the role ApplicationImpersonation and assign the role to the users in Office 365 Exchange?
16 Jul 2013 by Mathi2code
Hi,I have a page where all can view the page in that page I have a link which redirects to another page.when I click on that link I need to provide impersonation concept where only few users can view that page. The user Id and the Password will be maintained in the DB.Please provide...
5 Mar 2014 by Tisha Shaffer
Maybe Impersonization is the wrong word, I need to run a process on the local PC that the program runs on as a different user than the user that is logged on. From what I understand, when using ProcessStartInfo, setting the UserName, Password and Domain will accomplish this task.I simplified...
16 Nov 2017 by Member 10736689
i have impersonation set to true in my web.config file and supplied the username and the password, which has admin rights. Why am i getting this error?Could not load file or assembly 'Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its...
20 May 2014 by ZurdoDev
The class you used is for when you only want a piece of your code to be impersonated. If you always want to impersonate another user you don't even need to write code, there is a web.config setting for that.Here is a link to a .net 2003 article (first one that came up in search) but it...
27 Sep 2014 by mehdimughal
I am trying to get a token programitcally to access windows server's shared folder but i get this exception: The specified network password is not correctThis is the impersonation class:using System;using System.Collections.Generic;using System.Text;using...
29 Nov 2014 by Member 10736689
I do not have impersonation enabled in my webconfig. Instead I have an impersonation class where i activate impersonation around the code where ever necessary, and deactivate it back. I create a pdf of a template pdf by populating the form fields, I have to use impersonation to do this because...
12 May 2015 by Richard Deeming
That code is running on the server.If it works, it will open Windows Explorer on the server, where nobody will ever see it.It might appear to work when you run your site in Visual Studio, but that's only because the server and client are the same computer in that specific case.There...
12 Jun 2015 by Dev O'Connor
Afternoon All,Hoping you can shed some light here, i have an application that runs on an RDS 2012 RD Session host, it loops through the the process list from Win32_Process and compiles a list of who is running a specific instance of an process.Now, what i want to be able to achieve is to...
12 Jun 2015 by Dave Kreskowiak
What kind of app is this that you're monitoring and trying to relaunch?If it's an application that puts up any kind of user interface at all your users will not be able to see it, even if you launch the app as that user.While it is possible to remotely launch an application, it is now...
14 Jun 2015 by Andy Lanng
A service can only run on the default desktop. If you need to monitor each users desktop activity then each session will require an exe to be running. There are ways you can hide the exe but they aren't so easy.This article has a section on hiding apps from the taskbar.How To Make a...
4 Aug 2015 by Josiah Bradbury
I have an MVC application that uses Directory.getfiles() to scrape a network share for a file list and displays them to the used. This has worked fine on my development machine, but when I have deployed this to the web server I get the following:Access to the path {path}; is...
10 Dec 2015 by ZurdoDev
Do not use DllImport in a .Net application unless necessary. In this case, impersonation is native to .Net so use .Net libraries.However, if you want the code to run as a user without asking for their password then you have to turn on Windows Authentication in IIS so that windows will...
17 Jun 2016 by Strikerzz Arut
Opening an excel sheet using StartInfo is not working.What I have tried:I tried impersonating using the impersonation class, it is not working. Then I passed my user credential using Process.StartInfo.UserName and Process.StartInfo.Password, it is not working. I am opening a CMD prompt...
17 Jun 2016 by Strikerzz Arut
Process.StartInfo.LoadUserProf...
13 Jul 2016 by maverick1991
I have deployed a windows service "ServiceName" at a client machine in UAT.The UAT system has been logged on remotely using "ABC" username and "XYZ" password. The service picks the request from DB to generate reports in pdf format and launches a PDFGeneration.exe.In task manager the...
6 Apr 2017 by daviddelombaerde
Hi, What am I trying to do: I'm logged on as a standard User, with no admin rights. I have an admin account that I can use to acces other laptops on the network. I manually go to explorer fill in \\PCID\C$\Path, I get the windows-security dialog where windows asks for network authentication...
4 Apr 2017 by Jochen Arndt
You need the credentials of the remote systems which are usually not the same as on your local system. But these can't be used to start the Explorer on your local system. If you can perform your required tasks using a network connection to the shares instead of starting the Explorer you can...
6 Apr 2017 by daviddelombaerde
I used this example: Connect to a UNC Path with Credentials[^]. I didn't need the list of all the subfolders in the UNC path, but I needed to open this location in explorer. So I adjusted this to: public void Explorer_Click(object sender, RoutedEventArgs e) { ...
7 Jul 2017 by MayukhSen
Hi friends! I am trying to use impersonation in c# but I am not able to succeed. I am using What I have tried: #region Dlls // ------------------------------------------------------------------ [DllImport("advapi32.dll", SetLastError = true)] private static extern...
7 Jul 2017 by KarstenK
You cant get admin rights without user consent, so you must asked for it. Here is an fitting article on user elevation with C#. For deeper knowledge are the article about user elevation is a bit older but the techniques are working also on Windows 10. A good article enlighting User Impersonation.
16 Nov 2017 by Member 13525589
I ran into this same problem, when trying to use a Windows app to call into a web-service using impersonation. The windows app was launched from Visual Studio, and at first I assumed it would "inherit" my authorization (since I was using my admin credentials in the code); but it would not work...
22 Feb 2018 by Uberbob77
Hi there, I've a very puzzling situation that I've been struggling to resolve. I have a web application hosted in IIS on a Windows Server 2003 (SP2) operating system running on ASP.NET V4. It uses Windows authentication to identify the user and AD group membership to check their access levels....
12 Sep 2018 by RmcbainTheThird
Wild guess here. Is there a service that has not been started/installed on the failing vm?
5 Oct 2018 by Arpan_Patel
I have further investigated and found the root cause of this issue, see the details below and how to fix the same. 1. Actually I have installed Outlook and configured email account (user email account who does not have Impersonation Access) on the VM where i was facing issue, Upon restart of...
25 Aug 2020 by Ann_Swap
Hi, I have couple of connection strings in web.config, ideally using those connection strings and the credentials specified (in web.config) I will have to open a connection and do an insert - for both the connections (lets says connection1 and...
19 Feb 2013 by gmaran23
Enumerate remote processes and services with a Windows Identity that is part of the local Administrator’s group.
4 Feb 2013 by genese1977
Hello EverybodyI'm writing an application that allows to impersonate a user if required.However, the impersonation keeps failing with message: "Logon failure: unknown user name or bad password".Even the error sounds pretty clear, it can't be the case, cause the credentials are valid and...
17 Nov 2011 by Karthickeyan.k
Running a process as the user that began the install, when creating a Deployment Project
5 May 2014 by Hardik Turakhia
I am using C# .net 4.5 While the application is connecting to a shared path and copying files. This is done using impersonisation. But after running once the code, I can see that the connection is alive to that server, although no data is being transferred. Note: I am using Resource Monitor to...
27 Jun 2011 by Sergey Alexandrovich Kryukov
Let's be serious: is it about programming or art? Formally, part of information about person's head is hidden by the hair. From the stand point of a person having just a photograph, this information does not exist. You can only fantasize about the shape, color and other characteristics of the...
30 Jun 2012 by M_Mogharrabi
Hi all,I have written a win application that works on a network.In one of its forms user can browse and select file from local computer and add it to a list, so the application copies these files to a folder in My Network Places that no users can access to it but one that i have created...
20 May 2014 by Member 9428144
We have web apps calling the Impsersoate Class represented in this article:A small C# Class for impersonating a User[^]The class is currently called in Page_Load. Is there a way to call this class one time to set impersonation for the entire session rather than on each Page_Load? I tried...
8 Jan 2014 by ASP.NET Community
Sometimes you'll find it necessary to impersonate the user's identity on a thread with an ASP.NET.  You may also need a delegate access the user to
5 May 2014 by Anas Tasadduq
WNetCancelConnection2As idle63 said.
5 Sep 2017 by Member 10262330
I developed this DLL to have a more powerful utility and to simplify SP and query.
27 Jun 2011 by asma89
i have a picture that contain a real time image of any human and i want to make make him bald like i want that his hairs should be get removed from his head at run time on any button click , how shoud i do that in c# ?
3 Sep 2013 by alexandrvslv
Combine code from 2 links:Accessing Password Protected Network Drives in Windows in C#?A complete Impersonation Demo in C#.NETAnd do folowing steps //1. Logining IntPtr token; IntPtr tokenD; if (!NativeMethods.LogonUser(login.User, login.Domain, login.Password,...
10 Dec 2015 by Member 10286747
Hi,I know impersonation is possible with the below code [DllImport("advapi32.dll", SetLastError = true)] public static extern bool LogonUser( string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, ...
9 Feb 2012 by hhseiki
Hello, I'm doing this:1- Using impesonation (...) { 2- define process info (filename = path/winword.exe, arguments= myfile.doc) 3- ProcessStartInfo.LoadUserProfile = false 4- ProcessStartInfo.UseShellExecute = false 5- process.start }and I'm getting this...
5 Jan 2014 by arun_g
I hosted my application on the windows server 2008 and which throws a Server error in 'test' applicationand the description is not shown and says error can't be displayed and it hides the error set the configuration settings in web.config file to customErorrs mode="RemoteOnly" or set it to...
4 Mar 2014 by Tisha Shaffer
Hi all,I have seen many questions and answers on this subject, however, I can't seem to find the right answer for my situation. I have code that works perfectly as long as I don't set the username, password and domain of the processStartInfo object.Dim p As New ProcessStartInfo() ...
5 Oct 2018 by Arpan_Patel
I have Windows Service which listen On-Premise Exchange Mail boxes using EWS with Impersonation Access. I have one Admin User (Service Account) which has Impersonation Access and I have configured the same user for my Windows Service Logon. I am using NTLM Authentication in C#.Net to login and...
27 Mar 2023 by Member 10736689
Below is the code i am using, it works locally but the web application published to a server it does not work. I have tried impersonation and still nothing. It gives no error message it just does nothing. Any help?Dim openthis As String = System.Environment.CurrentDirectory ...
12 May 2015 by Valery Possoz
HelloUse ClickOnce.https://msdn.microsoft.com/en-us/library/t71a733d.aspx[^]You will need to create a console, winform or wpf project and publish it using clickonce.https://msdn.microsoft.com/en-us/library/31kztyey.aspx[^]Once you have a working program that does what you...