Custom memebrship provider problem

Discussion in 'ASP .Net Security' started by John, Dec 16, 2005.

  1. John

    John Guest

    Hi

    I am trying to setup a customised membership provider and I am getting the
    following error when trying to run the app;

    The entry 'AspNetSqlMembershipProvider' has already been added.

    The line is: <add name="AspNetSqlMembershipProvider"
    type="System.Web.Security.SqlMembershipProvider, System.Web,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    connectionStringName="LocalSqlServer" enablePasswordRetrieval="false"
    enablePasswordReset="true" requiresQuestionAndAnswer="true"
    applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed"
    maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
    minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
    passwordStrengthRegularExpression="" />

    What is the problem and how can I fix it? The complete web.config content is
    below.

    Thanks

    Regards

    Web.Config

    <?xml version="1.0"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    <appSettings/>

    <connectionStrings>
    <add name="Personal" connectionString="Data
    Source=.\MSSQLSERVER;Integrated Security=True;User
    Instance=True;AttachDBFilename=|DataDirectory|Events.mdf"
    providerName="System.Data.SqlClient"/>
    <remove name="LocalSqlServer"/>
    <add name="LocalSqlServer" connectionString="Data
    Source=.\SQLEXPRESS;Integrated Security=True;User
    Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf"/>
    </connectionStrings>

    <system.web>
    <compilation debug="true" strict="false" explicit="true"/>
    <pages>
    <namespaces>
    <clear/>
    <add namespace="System"/>
    <add namespace="System.Collections"/>
    <add namespace="System.Collections.Specialized"/>
    <add namespace="System.Configuration"/>
    <add namespace="System.Text"/>
    <add namespace="System.Text.RegularExpressions"/>
    <add namespace="System.Web"/>
    <add namespace="System.Web.Caching"/>
    <add namespace="System.Web.SessionState"/>
    <add namespace="System.Web.Security"/>
    <add namespace="System.Web.Profile"/>
    <add namespace="System.Web.UI"/>
    <add namespace="System.Web.UI.WebControls"/>
    <add namespace="System.Web.UI.WebControls.WebParts"/>
    <add namespace="System.Web.UI.HtmlControls"/>
    </namespaces>
    </pages>
    <authentication mode="Forms">
    <forms name="LoginAuthCookie" loginUrl="Login.aspx">
    <!--<credentials passwordFormat="Clear">
    <user name="john" password="password" />
    <user name="mike" password="test" />
    </credentials>-->
    </forms>
    </authentication>

    <authorization>
    <deny users="?" />
    </authorization>

    <!--<membership>
    <providers>
    <add connectionStringName="SqlServices"
    requiresQuestionAndAnswer="false"
    minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
    name="AspNetSqlProvider"
    type="System.Web.Security.SqlMembershipProvider" />
    </providers>
    </membership>-->

    <membership>
    <providers>
    <add name="AspNetSqlMembershipProvider"
    type="System.Web.Security.SqlMembershipProvider, System.Web,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    connectionStringName="LocalSqlServer" enablePasswordRetrieval="false"
    enablePasswordReset="true" requiresQuestionAndAnswer="true"
    applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed"
    maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
    minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
    passwordStrengthRegularExpression="" />
    </providers>
    </membership>

    <profile>
    <providers>
    <add name="AspNetSqlProfileProvider"
    connectionStringName="LocalSqlServer" applicationName="/"
    type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </providers>
    </profile>

    <roleManager>
    <providers>
    <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer"
    applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <add name="AspNetWindowsTokenRoleProvider" applicationName="/"
    type="System.Web.Security.WindowsTokenRoleProvider, System.Web,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </providers>
    </roleManager>

    </system.web>

    <location path="register.aspx">
    <system.web>
    <authorization>
    <allow users="*"></allow>
    </authorization>
    </system.web>
    </location>

    </configuration>
     
    John, Dec 16, 2005
    #1
    1. Advertising

  2. Hello John,

    use a different name for the provider or add a <clear /> element as a child
    to the <providers> element. The provider has already been registered in machine.config.

    ---------------------------------------
    Dominick Baier - DevelopMentor
    http://www.leastprivilege.com

    > Hi
    >
    > I am trying to setup a customised membership provider and I am getting
    > the following error when trying to run the app;
    >
    > The entry 'AspNetSqlMembershipProvider' has already been added.
    >
    > The line is: <add name="AspNetSqlMembershipProvider"
    > type="System.Web.Security.SqlMembershipProvider, System.Web,
    > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    > connectionStringName="LocalSqlServer" enablePasswordRetrieval="false"
    > enablePasswordReset="true" requiresQuestionAndAnswer="true"
    > applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed"
    > maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
    > minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
    > passwordStrengthRegularExpression="" />
    >
    > What is the problem and how can I fix it? The complete web.config
    > content is below.
    >
    > Thanks
    >
    > Regards
    >
    > Web.Config
    >
    > <?xml version="1.0"?>
    > <configuration
    > xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    > <appSettings/>
    > <connectionStrings>
    > <add name="Personal" connectionString="Data
    > Source=.\MSSQLSERVER;Integrated Security=True;User
    > Instance=True;AttachDBFilename=|DataDirectory|Events.mdf"
    > providerName="System.Data.SqlClient"/>
    > <remove name="LocalSqlServer"/>
    > <add name="LocalSqlServer" connectionString="Data
    > Source=.\SQLEXPRESS;Integrated Security=True;User
    > Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf"/>
    > </connectionStrings>
    > <system.web>
    > <compilation debug="true" strict="false" explicit="true"/>
    > <pages>
    > <namespaces>
    > <clear/>
    > <add namespace="System"/>
    > <add namespace="System.Collections"/>
    > <add namespace="System.Collections.Specialized"/>
    > <add namespace="System.Configuration"/>
    > <add namespace="System.Text"/>
    > <add namespace="System.Text.RegularExpressions"/>
    > <add namespace="System.Web"/>
    > <add namespace="System.Web.Caching"/>
    > <add namespace="System.Web.SessionState"/>
    > <add namespace="System.Web.Security"/>
    > <add namespace="System.Web.Profile"/>
    > <add namespace="System.Web.UI"/>
    > <add namespace="System.Web.UI.WebControls"/>
    > <add namespace="System.Web.UI.WebControls.WebParts"/>
    > <add namespace="System.Web.UI.HtmlControls"/>
    > </namespaces>
    > </pages>
    > <authentication mode="Forms">
    > <forms name="LoginAuthCookie" loginUrl="Login.aspx">
    > <!--<credentials passwordFormat="Clear">
    > <user name="john" password="password" />
    > <user name="mike" password="test" />
    > </credentials>-->
    > </forms>
    > </authentication>
    > <authorization>
    > <deny users="?" />
    > </authorization>
    > <!--<membership>
    > <providers>
    > <add connectionStringName="SqlServices"
    > requiresQuestionAndAnswer="false"
    > minRequiredPasswordLength="6"
    > minRequiredNonalphanumericCharacters="0"
    > name="AspNetSqlProvider"
    > type="System.Web.Security.SqlMembershipProvider" />
    > </providers>
    > </membership>-->
    > <membership>
    > <providers>
    > <add name="AspNetSqlMembershipProvider"
    > type="System.Web.Security.SqlMembershipProvider, System.Web,
    > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    > connectionStringName="LocalSqlServer" enablePasswordRetrieval="false"
    > enablePasswordReset="true" requiresQuestionAndAnswer="true"
    > applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed"
    > maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
    > minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
    > passwordStrengthRegularExpression="" />
    > </providers>
    > </membership>
    > <profile>
    > <providers>
    > <add name="AspNetSqlProfileProvider"
    > connectionStringName="LocalSqlServer" applicationName="/"
    > type="System.Web.Profile.SqlProfileProvider, System.Web,
    > Version=2.0.0.0,
    > Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    > </providers>
    > </profile>
    > <roleManager>
    > <providers>
    > <add name="AspNetSqlRoleProvider"
    > connectionStringName="LocalSqlServer"
    > applicationName="/" type="System.Web.Security.SqlRoleProvider,
    > System.Web,
    > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    > <add name="AspNetWindowsTokenRoleProvider" applicationName="/"
    > type="System.Web.Security.WindowsTokenRoleProvider, System.Web,
    > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    > </providers>
    > </roleManager>
    > </system.web>
    >
    > <location path="register.aspx">
    > <system.web>
    > <authorization>
    > <allow users="*"></allow>
    > </authorization>
    > </system.web>
    > </location>
    > </configuration>
    >
     
    Dominick Baier [DevelopMentor], Dec 16, 2005
    #2
    1. Advertising

  3. John

    Daniel TIZON Guest

    Hi John,
    The entry "ASPSQL Membership Provider is already defined in the
    MACHINE.CONFIG placed in then following folder.
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\
    If you want to override it, you should unregister the inherited before
    overriding it with the following statement
    <remove name="AspNetSqlMembershipProvider"/>
    <add name="AspNetSqlMembershipProvider" ...../>

    another solution consists to use another label for example :
    "MyMemberShipProvider"
    and to set it as the default membership provider with the following
    <membership defaultProvider="MyMemberShipProvider">
    <providers>
    <add name="MyMemberShipProvider" .... />
    </providers>
    </membership>

    I hope this helps

    --
    Daniel TIZON
    MCP - MCSD.NET - MCT


    "John" <> a écrit dans le message de news:
    ...
    > Hi
    >
    > I am trying to setup a customised membership provider and I am getting the
    > following error when trying to run the app;
    >
    > The entry 'AspNetSqlMembershipProvider' has already been added.
    >
    > The line is: <add name="AspNetSqlMembershipProvider"
    > type="System.Web.Security.SqlMembershipProvider, System.Web,
    > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    > connectionStringName="LocalSqlServer" enablePasswordRetrieval="false"
    > enablePasswordReset="true" requiresQuestionAndAnswer="true"
    > applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed"
    > maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
    > minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
    > passwordStrengthRegularExpression="" />
    >
    > What is the problem and how can I fix it? The complete web.config content
    > is below.
    >
    > Thanks
    >
    > Regards
    >
    > Web.Config
    >
    > <?xml version="1.0"?>
    > <configuration
    > xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
    > <appSettings/>
    >
    > <connectionStrings>
    > <add name="Personal" connectionString="Data
    > Source=.\MSSQLSERVER;Integrated Security=True;User
    > Instance=True;AttachDBFilename=|DataDirectory|Events.mdf"
    > providerName="System.Data.SqlClient"/>
    > <remove name="LocalSqlServer"/>
    > <add name="LocalSqlServer" connectionString="Data
    > Source=.\SQLEXPRESS;Integrated Security=True;User
    > Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf"/>
    > </connectionStrings>
    >
    > <system.web>
    > <compilation debug="true" strict="false" explicit="true"/>
    > <pages>
    > <namespaces>
    > <clear/>
    > <add namespace="System"/>
    > <add namespace="System.Collections"/>
    > <add namespace="System.Collections.Specialized"/>
    > <add namespace="System.Configuration"/>
    > <add namespace="System.Text"/>
    > <add namespace="System.Text.RegularExpressions"/>
    > <add namespace="System.Web"/>
    > <add namespace="System.Web.Caching"/>
    > <add namespace="System.Web.SessionState"/>
    > <add namespace="System.Web.Security"/>
    > <add namespace="System.Web.Profile"/>
    > <add namespace="System.Web.UI"/>
    > <add namespace="System.Web.UI.WebControls"/>
    > <add namespace="System.Web.UI.WebControls.WebParts"/>
    > <add namespace="System.Web.UI.HtmlControls"/>
    > </namespaces>
    > </pages>
    > <authentication mode="Forms">
    > <forms name="LoginAuthCookie" loginUrl="Login.aspx">
    > <!--<credentials passwordFormat="Clear">
    > <user name="john" password="password" />
    > <user name="mike" password="test" />
    > </credentials>-->
    > </forms>
    > </authentication>
    >
    > <authorization>
    > <deny users="?" />
    > </authorization>
    >
    > <!--<membership>
    > <providers>
    > <add connectionStringName="SqlServices"
    > requiresQuestionAndAnswer="false"
    > minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
    > name="AspNetSqlProvider"
    > type="System.Web.Security.SqlMembershipProvider" />
    > </providers>
    > </membership>-->
    >
    > <membership>
    > <providers>
    > <add name="AspNetSqlMembershipProvider"
    > type="System.Web.Security.SqlMembershipProvider, System.Web,
    > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    > connectionStringName="LocalSqlServer" enablePasswordRetrieval="false"
    > enablePasswordReset="true" requiresQuestionAndAnswer="true"
    > applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed"
    > maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7"
    > minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
    > passwordStrengthRegularExpression="" />
    > </providers>
    > </membership>
    >
    > <profile>
    > <providers>
    > <add name="AspNetSqlProfileProvider"
    > connectionStringName="LocalSqlServer" applicationName="/"
    > type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0,
    > Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    > </providers>
    > </profile>
    >
    > <roleManager>
    > <providers>
    > <add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer"
    > applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web,
    > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    > <add name="AspNetWindowsTokenRoleProvider" applicationName="/"
    > type="System.Web.Security.WindowsTokenRoleProvider, System.Web,
    > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    > </providers>
    > </roleManager>
    >
    > </system.web>
    >
    > <location path="register.aspx">
    > <system.web>
    > <authorization>
    > <allow users="*"></allow>
    > </authorization>
    > </system.web>
    > </location>
    >
    > </configuration>
    >
    >
    >
    >
     
    Daniel TIZON, Dec 16, 2005
    #3
  4. That is a reserved provider name. Try using the <clear> element to empty
    the list first:
    <providers>
    <clear/>
    <add.../>
    <providers>
     
    Keith Patrick, Dec 16, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BS
    Replies:
    3
    Views:
    2,063
    Alvin Bruney [MVP]
    Jun 17, 2004
  2. John
    Replies:
    2
    Views:
    9,095
    Keith Patrick
    Dec 16, 2005
  3. sloan
    Replies:
    5
    Views:
    1,515
    sloan
    Jun 4, 2006
  4. sloan
    Replies:
    1
    Views:
    514
    Chad Scharf
    Jul 3, 2007
  5. John

    Custom memebrship provider problem

    John, Dec 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    143
    Keith Patrick
    Dec 16, 2005
Loading...

Share This Page