Wednesday, March 21, 2012

Login Failed for SQL Server db

I recently formatted my pc, everything is set but one thing, the sql server db.

I can't remember how I set the permission for my local machine for the db.

Error: Login Faile for <machineName>\ASPNET

How do I add the user to access the db?

Thanks all,

Zaththe ASPNET is a local account that you need to assign to some role in SQL server.
Create a new Logon in SQL server for that account and give that Login the appropriate DB permissions.

Do NOT make that account a member of your local Administrators group. youd never run a live server that way so dont do it with a dev server either.|||In Enterprise Manager, I added ASPNET for one of the roles.

Still login failed.

I added the new role to the db_owner, still failed.

I went to security folder, added ASPNET there as well in Logins, still no luck.

The conn string I am using is...

<add key="ConnectString" value="Data Source=localhost; Initial Catalog=dbName; User ID=ASPNET; Password=*********; Trusted_Connection=True;"
No wonder I like to stick to coding... LOL

Suggestions?

Thanks,

Zath|||When trusted_connection=true, the userid and password are not required as the user credentials are derived from the machine logon.

i.e the machines ASPNET account.

your connection string includes a userid and password which might be getting evaluated as SQL credentials even though your specifying to use a trusted_connection. (your mixing your security options)

adding the ASPNET machine account to a role is not the same as creating a SQL login with the name ASPNET.

try removinguser id andpassword from your connection string
or
try creating an actual SQL Login and turning off Trusted_Connection|||Try this url http://whoozoo.co.uk/winxpFilePerms.htm use it to configure file permissions
in Windows XP and then give Asp.net account read and write permissions for the application folder before setting up the SQL Server Permissions for same account with DBO permissions in the Database created for the application. Hope this helps.

Kind regards,
Gift Peddie|||I tried both ways and still no luck.

With just the id and password, I get this error...
Login failed for user 'ASPNET'. Reason: Not associated with a trusted SQL Server connection

And with the Trusted_Connection and no id or pw, just the login failed.

Ironically, I work in IIS Admin and am familiar with permissions, but this db thing has me stumped... LOL

I even tried to create a new test db but with the same results.

Any more suggestions will be helpful,

Thanks again,

Zath|||SUCCESS!!!!!

I knew I would get it, I always do... It's a curse I tell ya, a curse... LOL

In SQL Server Enterprise Manager, under the db in question, go to Security Folder, then logins (which I did before)

Create the the new user, in this case I created ASPNET.

But, don't use SQL Server Authentication, but use Windows Authentication.

Input the new user, then choose from the drop down list your local machine name.

I did however create the ASPNET user in the wwwroot folder permissions, don't know if this was required first, most likely... but I'm in.....

And don't know why the userid and pw didn't work, but doesn't matter now....

Used this conn string...

----
<add key="ConnectString" value="Data Source=localhost; Initial Catalog=dbName; Integrated Security=SSPI; PWD=Trusted_Connection=True;"
---
I'm sure when I'm ready to transfer to "production" server and change the conn string, it will work fine because it does in my main app!

Thanks for the help everyone!

Zathsql

No comments:

Post a Comment