Built-in controls with custom providers

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

  1. John

    John Guest

    Hi

    I have created custom membership/role/profile providers as per the
    web.config below. My questions are;

    1. Have I defined them correctly?

    2. How can I make the Login and Create User Wizard controls to use these
    providers instead of the standard providers?

    Thanks

    Regards

    web.config follows

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

    <connectionStrings>
    <add name="Events" 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"/>-->
    <add name="Membership" connectionString="Data
    Source=.\MSSQLSERVER;Integrated Security=True;User
    Instance=True;AttachDBFilename=|DataDirectory|Membership.mdf"
    providerName="System.Data.SqlClient"/>
    </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="MembershipProvider"
    type="System.Web.Security.SqlMembershipProvider, System.Web,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    connectionStringName="Membership" enablePasswordRetrieval="false"
    enablePasswordReset="true" requiresQuestionAndAnswer="false"
    applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed"
    maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6"
    minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
    passwordStrengthRegularExpression="" />
    </providers>
    </membership>

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

    <roleManager>
    <providers>
    <add name="RoleProvider" connectionStringName="Membership"
    applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web,
    Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <add name="WindowsTokenRoleProvider" 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. 1) I didn't check the syntax. Did you? Do you get any errors?

    2) Set the defaultProvider attribute to the name you gave to your custom
    providers, on each of the parent elements.

    For example:
    <membership defaultProvider="MembershipProvider">
    <providers>
    <add...
    </providers>
    </membership>


    Do the same for <profile> and <roleManager>

    Joshua Flanagan
    http://flimflan.com/blog
     
    Joshua Flanagan, Dec 17, 2005
    #2
    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. Jimmy
    Replies:
    2
    Views:
    344
    Jimmy
    Oct 2, 2006
  2. Tullamore

    Help - custom providers and instances

    Tullamore, Oct 31, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    302
    Tullamore
    Oct 31, 2006
  3. Replies:
    0
    Views:
    1,356
  4. John

    Built-in controls with custom providers

    John, Dec 16, 2005, in forum: ASP .Net Security
    Replies:
    0
    Views:
    148
  5. John

    Built-in controls with custom providers

    John, Dec 16, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    123
Loading...

Share This Page