Search code examples
asp.netactive-directoryasp.net-membershipmembership-provider

Active Directory Membership Provider works only for the Administrator


Good day, I am pulling my hair on this one.. I have Active Directory Memebership Provider configured like this:

<system.web>
<membership>
<providers>
<clear/>
<add name="dev"
 type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web,       Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
 connectionStringName="DevTestConnStr"
 attributeMapUsername="sAMAccountName"
 connectionUsername="dev\Administrator"
 connectionPassword="Password" 
 applicationName="/web"  
  />

The provider is instantiated correctly but when I call this:

var user = Membership.Providers["myDomain"].GetUser("myUser", false);

the call always returns null, except the case when I pass "Administrator" into the call... I have run out of ideas on how to make it work. Please help!


Solution

  • Just as when I was already ready to bail, I decided to change my LDAP connection string from:

    "LDAP://dev.local/CN=Users,DC=Dev,DC=local" 
    

    to

    "LDAP://dev.local/DC=Dev,DC=local". 
    

    Now works as expected!