I got this error message
Could not find the specified membership provider
Here's my web.config setting:
<connec开发者_运维百科tionStrings>
<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.
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>
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>
精彩评论