|
Article relates to
|
Sitefinity
2.6
,
2.7
|
|
Created by
|
Rebecca, Telerik
|
|
Last modified
|
Nov 14, 2006
|
Problem
The application fails to access the Membership Services database.
Description
The following error is displayed when attempting to log in the Primavera sample and newly created projects.
Reasons
No permission to access the SQL Server database. No permission to access the
~/App_Data
folder.
When SQL Server connection is used with Windows authentication, the Project Manager impersonates the account that runs the ASPNET process to an existing Windows account that can access the database. However, when you run the site, there is no impersonation and the account that is trying to connect to the database is the ASPNET account.
Membership Services in Sitefinity
To comply with the latest features of ASP.NET 2.0 framework, Sitefinity uses Membership Services. When creating a new project, you can choose to have your Memberships in the project database or in a different one.
The Sitefinity web.config file has two connection strings: one for Memberships and one for the Sitefinity database. The first one is under the configuration tag and is named SitefinityMembership, the second one is under the Telerik/settings tag and is located in an add tag. This means that Memberships are managed separately from Sitefinity and because of this, some additional permissions should be given for the database and some additional operations should be done outside Sitefinity. Note that the ASPNET process is restricted for security reasons, and for that matter, we cannot administer the Membership Services from within the Sitefinity web application.
More
As described in
AdministrationManual > Installation and Deployment > Creating Individual Web Sites > Sitefinity Projects
, there are two types of projects in Sitefinity: bare projects and self-contained projects.
- About Primavera in Sitefinity 2.6
The Primavera sample site is a
bare
project. It contains only the site-specific information and is run and managed by the common CMS application. It is placed in the Sitefinity
2.6 web application folder and inherits all settings from the Sitefinity 2.6 Web.config file.
So it uses the same database configuration (located in
Sitefinity2.6\Web.config) for Membership users and a different Sitefinity database. The default database is located in
Sitefinity2.6\App_Data\aspnetdb.mdf
file. This file is created by ASPNET on first use and this is why we did not copy it in the
Sitefinity2.6\App_Data
with the installation.
To run the Primavera sample, you need to have SQL Express installed.
Otherwise, you need to change the connection string to use the appropriate Membership database. To fit your database to use Membership Services, you need to use the
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe
tool.
- About self-contained projects
If you need to set Membership Services for a
self-contained
project, you should change the web.config
file contained in the project root folder to reflect your database. Basically, when creating a Sitefinity project, you should choose the database for it. If you choose
SQL Server,
you have two options for Memberships: to use the same DB, or not.
If you clear the
Use thisSQL Server DB for Membership Users
checkbox, you just need to have SQL Express installed and it will create the database for Memberships on first admin login, as long as the Membership connection string has not been changed in the Web.config file. Otherwise, you can create the Memberships in another database by running the
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe
tool.
If you leave the checkbox selected,you have to run the
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe
tool
to create the Membership objects in the database you are going to use for your project and set the connection string for the Membership Services to point to this database.
Using the same
SQLServer 2000/2005 database for Sitefinity project and Membership Services
-
Create a new
SQL Server DB
(Test).
-
Run the
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe
and select this DB (Test) for Membership Services.
-
In the Create Project Wizard, choose Test DB and do not clear the
Use this SQL Server DB for Membership
checkbox.
-
Open the web.config file after the project is created and find this node:
<add
name="SitefinityMembership"
connectionString=
"
...
"
providerName="System.Data.SqlClient"/>
-
Set it this way:
<add
name="SitefinityMembership
"
connectionString=
"Data Source=localhost;
Initial Catalog=Test; Integrated Security=True"
providerName
="System.Data.SqlClient
"/>
Using SQL Express database
-
Set the database for Membership Services after creating the project. You can do this in the Web.config:
<add
name
="SitefinityMembership"
connectionString="datasource=.\SQLEXPRESS; Integrated Security=SSPI;
AttachDBFilename=|DataDirectory|aspnetdb.mdf;UserInstance=true"
providerName
="
System.Data.SqlClient"/>
-
Delete the ASPNETDB.MDF and ASPNetDB.mdb files from under App_Data folder if there any.
-
Set full permissions to App_Data folder for the local machine ASPNET account. If using Windows Server 2003, grant permissions for the NETWORK SERVICE role.
-
Restart the ASP.NETapplication so that changes take effect.
Creating SQL authentication
- Run the Create Project Wizard.
-
Type the name of the project and select the "self-contained" checkbox.
-
At the next wizard step you need to create your database. If you are using SQL server, you need to create a database from the Server Management Studio.
-
Create SQL user from the server Security folder by specifying the user name and password and also a default SQL database which should be the same as the one created in step 3.
-
From your database, under the security folder, add your newly created user and grant owner permissions for Schemas and Database role membership.
-
Run the
aspnet_regsql.exe
tool that configures your SQL database to use Membership Services. When running it, set your SQL credentials by choosing SQL authentication and a database name.
-
Select the "Use this SQL Server Database for Membership Users" checkbox and the “Use SQL authentication” radio button.
-
Enter your credentials and click Next.
-
Choose some layouts and themes for your project.
-
Check that your two connection strings point to the appropriate database.
Creating Windows authentication
-
Run the Create Project Wizard.
-
Type the name of the project and select the "self-contained" checkbox.
-
At the next wizard step, if you are using windows authentication and one database for the Sitefinity project and Membership Services, create the database from SQL Server and add a user with ASPNET permissions. This has to be done, as Windows needs to know the process to which permissions should be given.
-
Run the
aspnet_regsql.exe
tool that configures your SQL database to use Membership Services. When running it, choose Windows authentication and a database name.
-
Choose some layouts and themes for your project.
-
Check that your two connection strings point to the appropriate database.
-
Give the account that runs the ASPNET process the appropriate permissions for the
Sitefinity2.7\Projects
folder.