Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » Samples » Downloads
 

A small C# Class for impersonating a User

By , 11 Apr 2005
 
zetaimpersonator_demo.zip
ImpersonatorDemo
App.ico
bin
ImpersonatorDemo.csproj.user
using System;
using System.IO;
using Tools;

namespace ImpersonatorDemo
{
	/// <summary>
	/// Main class for the demo application.
	/// Call this application with a low privileg account to test.
	/// </summary>
	class Program
	{
		/// <summary>
		/// The main entry point.
		/// </summary>
		[STAThread]
		static void Main( string[] args )
		{
			// Impersonate, automatically release the impersonation.
			using ( new Impersonator( "yourUsername", "yourDomain", "yourPassword" ) )
			{
				// The following code is executed under the impersonated user.
				string[] files = Directory.GetFiles( "c:\\windows" );
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Uwe Keim
Chief Technology Officer Zeta Producer Desktop CMS
Germany Germany
Member
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.
 
In his free time, he does climbing, running and mountain biking. Recently he became a father of a cute boy.
 
Some cool, free software from us:
 
Free Test Management Software - Intuitive, competitive, Test Plans. Download now!  
Homepage erstellen - Intuitive, very easy to use. Download now!  
Send large Files online for free by Email
Some random fun stuff in German

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 11 Apr 2005
Article Copyright 2005 by Uwe Keim
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid