Built-in controls with custom providers

  • Thread starter Thread starter John
  • Start date Start date
J

John

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