VB.Net & C# Impersonation Library


I got an e-mail about the Impersonation that I implemented to connect to the Analysis Service data cube (which is also very handy when you need to perform network operations from your web page but only want a small section of code to use those credentials). I created a project over at Codeplex to host the classes and the library. There is documentation in the download file on how to use it. Here's the project description and link:

Link: http://impersonation.codeplex.com/

This solution includes two libraries for implementing impersonation in your ASP.NET, .Net, VB6 or Classic ASP applications.

  1. Impersonation Class Library for any .Net based application. This was written against framework 3.5 but also should work with 2.0 & 1.1 since a bulk of the code is calling Windows API's.
  2. Com Visible Impersonation Class Library that can be called from Classic ASP & Visual Basic 6 applications.

Notes: In Asp.Net the benefit of this as opposed to impersonating in the web.config (for the whole page) is that you can isolate heightend permissions down to blocks of code or individual lines of code. It also lets you do things like open trusted database connections without having to have the whole page run as a proxy account (this comes in especially handy if you use ADOMD to connect to OLAP cubes on SQL Server Analysis Services which only accepted trusted connections, no SQL accounts).

This solution was written in Visual Basic using Visual Studio 2008. To include in C# either compile this library and add a reference to the .DLL or port the code which is fairly small. There are other C# solutions available on the web and on code plex so I won't recreate the wheel (I'll find links in the future for those who want to keep their source in C# and not bother with porting).

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.