Best way for unit testing authorization issues

bri189a

Well-known member
Joined
Sep 11, 2003
Messages
1,004
Location
VA
Im not sure the best way to do this. I need to write some unit tests that test that certain users have the ability to do certain things; the objects have role based permissions.

The problem is that in order to do this I have to impersonate one of 4 test users to get the permission set that is going to be tested. While impersonating myself is quite easy I cant find any .NET libraries that allow me to create a Windows identity/principal and make the unit test run in the context of that user.

Any ideas would be greatly appreciated. Id prefer not to hit the Windows APIs if possible; if that is the only solution, a pointer to someone who has already wrapped LogonUser or whatever it is (dont remember) would great.
 
Thanks PD...the code project link was exactly what I needed. Good re-usable class that has comments and implements disposing...nice to see good contributions like that.
 
Back
Top