I'm trying to set up an intranet site and wanted to use the ASP.NET membership and role management providers. I want however to use my local MS SQL Server 2005 rather than an .mdf file stored on the site. I'm running win 2003 server with asp.net 3.5 and MS SQL 2005.
Iv'e created the aspnetdb database using
aspnet_regsql.exe –A m –E
and this seems ok and has been created as a database within MS SQL 2005 with all the tables
and added the following to my web.config file
<connectionStrings>
<!--remove name="LocalSqlServer"/-->
<add name="LocalSql2005Server" connectionString="data source=127.0.0.1;Integrated Security=SSPI" />
</connectionStrings>
<system.web>
<membership defaultProvider="AspNetSql2005MembershipProvider">
<providers>
<add name="AspNetSql2005MembershipProvider"
type="System.Web.Security.SqlMembershipProvider,
System.Web, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="LocalSql2005Server"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
passwordStrengthRegularExpression="" />
</providers>
</membership>
<roleManager enabled="true" cacheRolesInCookie="true"
cookieName=".ASPXROLES" cookieTimeout="30" cookiePath="/"
cookieRequireSSL="false" cookieSlidingExpiration="true"
cookieProtection="All" defaultProvider="AspNetSqlRoleProvider"
createPersistentCookie="false" maxCachedResults="25">
<providers>
<clear />
<add connectionStringName="LocalSql2005Server" applicationName="/"
name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider, System.Web,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
<profile>
<providers>
<clear />
<add name="AspNetSql2005ProfileProvider"
connectionStringName="LocalSql2005Server" applicationName="/"
type="System.Web.Profile.SqlProfileProvider, System.Web,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
<properties>
<add name="FirstName" />
<add name="LastName" />
<add name="LastVisited" />
<add name="Age" />
<add name="Member" />
</properties>
</profile>
and also included:
<authentication mode="Forms">
<forms name=".ASPXAUTH"
loginUrl="Login.aspx"
protection="All"
timeout="30"
path="/"
requireSSL="false"
slidingExpiration="true"
cookieless="UseDeviceProfile" />
</authentication>
Then tried to create a form page:
<form id="form1" runat="server">
<asp:CreateUserWizard ID="CreateUserWizard1" Runat="server"
BorderWidth="1px" BorderColor="#FFDFAD" BorderStyle="Solid"
BackColor="#FFFBD6" Font-Names="Verdana">
<TitleTextStyle Font-Bold="True" BackColor="#990000"
ForeColor="White"></TitleTextStyle>
</asp:CreateUserWizard>
</form>
when I try running this and enter valid data though I get:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Instead of the
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I tried creating a user called poweruser (with password set to secret) in MS SQL Server and giving it db owner access to the aspnetdb databsse and then tried the following connection:
<add name="LocalSql2005Server" connectionString="data source=ANDYS-PC\ANDYS-PC,1433;Integrated Security=SSPI;Initial Catalog=aspnetdb;User ID=poweruser;Password=secret" />
My SQL server is called 'ANDYS-PC' as well as the computers name. But this still gives the same error. I also tried combinations using 12.0.0.1 instead of PC\SERVER but still get the same error.
Can anyone advise what I'm doing wrong or have missed. I'm pretty new to setting up security and roles on a site so please bear with me and any help would be appreciated
Thanks
Andy
Iv'e created the aspnetdb database using
aspnet_regsql.exe –A m –E
and this seems ok and has been created as a database within MS SQL 2005 with all the tables
and added the following to my web.config file
<connectionStrings>
<!--remove name="LocalSqlServer"/-->
<add name="LocalSql2005Server" connectionString="data source=127.0.0.1;Integrated Security=SSPI" />
</connectionStrings>
<system.web>
<membership defaultProvider="AspNetSql2005MembershipProvider">
<providers>
<add name="AspNetSql2005MembershipProvider"
type="System.Web.Security.SqlMembershipProvider,
System.Web, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="LocalSql2005Server"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
passwordStrengthRegularExpression="" />
</providers>
</membership>
<roleManager enabled="true" cacheRolesInCookie="true"
cookieName=".ASPXROLES" cookieTimeout="30" cookiePath="/"
cookieRequireSSL="false" cookieSlidingExpiration="true"
cookieProtection="All" defaultProvider="AspNetSqlRoleProvider"
createPersistentCookie="false" maxCachedResults="25">
<providers>
<clear />
<add connectionStringName="LocalSql2005Server" applicationName="/"
name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider, System.Web,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</roleManager>
<profile>
<providers>
<clear />
<add name="AspNetSql2005ProfileProvider"
connectionStringName="LocalSql2005Server" applicationName="/"
type="System.Web.Profile.SqlProfileProvider, System.Web,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
<properties>
<add name="FirstName" />
<add name="LastName" />
<add name="LastVisited" />
<add name="Age" />
<add name="Member" />
</properties>
</profile>
and also included:
<authentication mode="Forms">
<forms name=".ASPXAUTH"
loginUrl="Login.aspx"
protection="All"
timeout="30"
path="/"
requireSSL="false"
slidingExpiration="true"
cookieless="UseDeviceProfile" />
</authentication>
Then tried to create a form page:
<form id="form1" runat="server">
<asp:CreateUserWizard ID="CreateUserWizard1" Runat="server"
BorderWidth="1px" BorderColor="#FFDFAD" BorderStyle="Solid"
BackColor="#FFFBD6" Font-Names="Verdana">
<TitleTextStyle Font-Bold="True" BackColor="#990000"
ForeColor="White"></TitleTextStyle>
</asp:CreateUserWizard>
</form>
when I try running this and enter valid data though I get:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Instead of the
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I tried creating a user called poweruser (with password set to secret) in MS SQL Server and giving it db owner access to the aspnetdb databsse and then tried the following connection:
<add name="LocalSql2005Server" connectionString="data source=ANDYS-PC\ANDYS-PC,1433;Integrated Security=SSPI;Initial Catalog=aspnetdb;User ID=poweruser;Password=secret" />
My SQL server is called 'ANDYS-PC' as well as the computers name. But this still gives the same error. I also tried combinations using 12.0.0.1 instead of PC\SERVER but still get the same error.
Can anyone advise what I'm doing wrong or have missed. I'm pretty new to setting up security and roles on a site so please bear with me and any help would be appreciated
Thanks
Andy