开发者

Can the SQlMembershipProvider be used with umbraco

Does anybody have an examples of this, fr开发者_开发百科om what I've read umbraco kicks up a bit of a stink but I can't find any examples


You can do it for members in front-end, but not users in the back-end. doing so is very easy, just change the providers section in web.config. I have used umbraco with SQlMembershipProvider, as well as custom membership providers I had implemented my self.


Yes, you absolutely can use the SqlMembershipProvider with Umbraco. First, you must add your connection string to the config file.

 <add name="umbracoDbDSN" connectionString="Server=myhost.myexampledomain.com;Database=mydatabasename;User Id=myuserid; Password=myhardtobreakpassword;" providerName="System.Data.SqlClient" />

Make sure that the username and password to access the database will actually give proper access to Umbraco.

Second, you must ensure that the SqlClient data provider is added to DbProviderFactories section of system.data:

<add name="SqlClient Data Provider"
           invariant="System.Data.SqlClient"
           description=".Net Framework Data Provider for SqlServer"
           type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />  

Third, you must add the SqlServerMembershipProvider to the providers section:

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

Make sure that the connectionstring you reference from your provider matches the connectionstring you defined earlier, and give the application an appropriate name.

Fourth, add the SqlServerRoleProvider to the providers section of roleManager:

<add name="SqlServerRoleProvider"
          type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
          connectionStringName="umbracoDbDSN"
          applicationName="MyUniqueUmbracoApplication"
          />

Fifth, add it in the providers section of profie:

<add name="SqlProfile" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="umbracoDbDSN" applicationName="MyUniqueUmbracoApplication" />

Sixth, run aspnet_regsql.exe on your database to setup the database to use the SqlMembershipProvider (Configuring the database with aspnet_regsql.exe).

Seventh, restart IIS after rolling out the new config file. Ensure that IIS is setup to use the new provider.

Here's another resource for configuring the database: Configuring ASP.NET SqlMembershipProvider.

To configure database permissions, here's the instructions: Configuring Umbraco database security. The important part is to add the user for the data provider to:

  1. db_datareader
  2. db_datawriter
  3. db_ddladmin
  4. db_securityadmin
  5. public

If your config file looks a bit different, you are likely using a different version of Umbraco. I am using 7.0.3 for this example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜