views:

677

answers:

2

Hi,

I got this error message

Could not find the specified membership provider

Here's my web.config setting:

<connectionStrings>
<add name="MyConnectionString" connectionString="Data Source=MyHostName;Initial Catalog=MyDB;User ID=userid;Password=*****" providerName="System.Data.SqlClient" />
    <add name="ADConnectionString" connectionString="LDAP://demo.stl.local/DC=stl,DC=local"/>
</connectionStrings>
    <system.web>

    <customErrors defaultRedirect="~/error.aspx"/>

    <siteMap defaultProvider="default">
        <providers>
            <clear/>
            <add name="default" type="System.Web.XmlSiteMapProvider" siteMapFile="web.sitemap" securityTrimmingEnabled="true"/>
        </providers>
    </siteMap>

    <roleManager enabled="true" defaultProvider="SqlRoleManager">
        <providers>
            <add connectionStringName="MyConnectionString" applicationName="MyAppDemo" name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider"/>
                        </providers>

        <membership defaultProvider="MyADMembershipProvider">
            <providers>
                <add name="MyADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName"/>
            </providers>
        </membership>

I'm trying to use ASP.NET Membership with ActiveDirectory authentication. The authentication with AD was working fine until I added another connection-string and roleManager. So, what's wrong with this setting?

Thank you.

+1  A: 

Well, the Membership node is at the same level as the providers, maybe you should just close with </providers> before <membership>.

Also, membership should be separate from roleManager.

<roleManager enabled="true" defaultProvider="SqlRoleManager">
    <providers>
        <add connectionStringName="MyConnectionString" applicationName="MyAppDemo" name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider"/>
    </providers>
</roleManager>

<membership defaultProvider="MyADMembershipProvider">
    <providers>
        <add name="MyADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName"/>
    </providers>
</membership>
GoodEnough
Sorry, it was my typo I just added to </providers> the question. It's here with the web.config
Angkor Wat
Ok, I verified and membership should not be inside roleManager, they are both separate nodes.
GoodEnough
+2  A: 

The role manager is not closed

<roleManager enabled="true" defaultProvider="SqlRoleManager">
        <providers>
            <add connectionStringName="MyConnectionString" applicationName="MyAppDemo" name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider"/>
                        </providers>

        <membership defaultProvider="MyADMembershipProvider">
//here 
</roleManager>
Amgad Fahmi