问题
Does anybody have an examples of this, from what I've read umbraco kicks up a bit of a stink but I can't find any examples
回答1:
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.
回答2:
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:
- db_datareader
- db_datawriter
- db_ddladmin
- db_securityadmin
- 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.
来源:https://stackoverflow.com/questions/3046860/can-the-sqlmembershipprovider-be-used-with-umbraco