Click here to Skip to main content
13,042,630 members (77,167 online)
Click here to Skip to main content
Articles » Languages » C# » Samples » Downloads


227 bookmarked
Posted 11 Apr 2005

A small C# Class for impersonating a User

, 11 Apr 2005
Introduced a class that simplifies Windows Impersonation in C#.
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>
		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 Service 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.


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
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:

German Developer Community  
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

You may also be interested in...

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