I'm using the Microsoft Enterprise Library's security block (EntLib version 4.1), specifically the library's support for authorization using AzMan as the authorization provider. I'm using impersonation (WindowsIdentity.Impersonate()) in my NUnit tests to
impersonate test accounts with various levels of authorization. Everything works as expected when I launch an NUnit test from the right-click context menu (TestDriven). However, when I try to run the test from the NUnit GUI it fails with the following error:
System.IO.FileLoadException : Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Common, Version=184.108.40.206, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Access is denied.
The above error only occurs when I'm impersonating a test user while running the test using the NUnit GUI. The test users are domain accounts. All domain accounts are included in the local Users group on my development machine.
More interesting facts:
If I put the test users in the local Administrators group the tests run fine from the NUnit GUI, but obviously this is not desirable.
If I access the method under test by actually running the application and logging in (Windows authentication) as one of the test users everything works as expected.
As stated above, if I run the test from the right-click context menu it works fine.
My development machine is Windows XP SP3. I have the AzMan 1.2 primary interop assembly installed and registered in the GAC.
The error occurs as soon as I reference the EntLib security block with the following line:
IAuthorizationProvider authorizationProvider = AuthorizationFactory.GetAuthorizationProvider();