I have a website that I created. In the Appdata folder I created a database (info.mdf).
I connected it to SQLEXpress
I have added NETWORK SERVICE to available users in SQL mngmnt studio. I went to user mapping and added my database. I selected the db_owner, public and aspnet_Membership_FullAccess. I did the same process with my local username but I guess because of the way I setup my database the local user shows up as dbo under the users in the actual database.
I altered my web.config to say:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="MembershipConnection" connectionString="Server=machinename\SQLEXPRESS; Initial Catalog=Info;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
</authentication>
<membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="1720">
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MembershipConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
<add name="SqlProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="MembershipConnection"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="10"
passwordAttemptWindow="30"
minRequiredPasswordLength="3"
minRequiredNonalphanumericCharacters="0"
applicationName="/" />
</providers>
</membership>
<roleManager enabled ="true" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
I also tried Trusted_Connection=Yes in the connection string as well as Integrated Security=SSPI
The error I get is:
[SqlException (0x80131904): Cannot open database "Info" requested by the login. The login failed. Login failed for user 'MachineName\\username'.]
Ideas?
http://msdn.microsoft.com/en-us/library/ff647396.aspx
This link says that in order to do windows authentication, you must have
Trusted_Connection=Yes
or
Integrated Security=SSPI
in the connection string. Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.