Using the ActiveDirectory Provider, when I execute Membershhip.GetUser()
i get an error message:
The parameter 'username' must not be empty.
Here is the membership configuration:
<membership defaultProvider="AspNetActiveDirectoryMembershipProvider" >
<providers>
<clear/>
<add name="AspNetActiveDirectoryMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ADConnectionString"
attributeMapUsername="sAMAccountName"/>
</providers>
</membership>
<authentication mode="Windows"/>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
I'm trying to access this method from Visual studio unit test method. Thanks for any help :)
The problem was that the current thread principal has not been set.
Adding the follwing row:
Thread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
is initialize the current principlal and the GetUser() is back to work.