bri189a Posted October 13, 2007 Posted October 13, 2007 I'm 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 can't 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. I'd prefer not to hit the Windows API's if possible; if that is the only solution, a pointer to someone who has already wrapped LogonUser or whatever it is (don't remember) would great. Quote
Administrators PlausiblyDamp Posted October 13, 2007 Administrators Posted October 13, 2007 Not tried these but they could be useful http://www.codeproject.com/csharp/zetaimpersonator.asp http://blogs.msdn.com/shawnfa/archive/2005/03/22/400749.aspx alternatively you could try using caspol.exe (loads of info about it here) to change the effective policies applied to the code. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
bri189a Posted October 14, 2007 Author Posted October 14, 2007 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.