0

我收到此错误消息

找不到指定的会员提供者

这是我的 web.config 设置:

<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>

我正在尝试将 ASP.NET Membership 与 ActiveDirectory 身份验证一起使用。在我添加另一个连接字符串和角色管理器之前,使用 AD 的身份验证工作正常。那么,这个设置有什么问题呢?

谢谢你。

4

2 回答 2

3

角色管理器未关闭

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

        <membership defaultProvider="MyADMembershipProvider">
//here 
</roleManager>
于 2010-02-22T06:48:24.543 回答
1

好吧,Membership节点与 处于同一级别providers,也许你应该用</providers>before关闭<membership>

此外,membership应该与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>
于 2010-02-22T04:56:10.897 回答