Unable to connect to SQL Server database - sql-server

I'm trying to use the ASP.NET Web Site Administration Tool. When I click on the Security, I kept getting this message.
There is a problem with your selected data store. This can be caused
by an invalid server name or credentials, or by insufficient
permission. It can also be caused by the role manager feature not
being enabled. Click the button below to be redirected to a page where
you can choose a new data store.
The following message may help in diagnosing the problem:
Unable to connect to SQL Server database.
First of, which SQL Server does this administration tool trying to connect too? How do I change the "Current User Name" to other user name? It's automatically used my Windows authentication logged on user name. If I can change this and the password, it might just work.

Your web.config has a connection string. See this question for the full details on how to change that:
ASP.NET Website Administration Tool: Unable to connect to SQL Server database

Related

Authenticating WCF Service - SQL Server

I am following http://msdn.microsoft.com/en-us/library/ff647294.aspx to add authentication to a WCF. My SQL Server is on a different machine than the development server. In Step 1, I am not using SQLExpress but using SQL Server 2012. When I get to the Step 8: Create a User in the User Store, under Security Tab of ASP.net Web Site Administration Tool I see the following message:
There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.
The following message may help in diagnosing the problem: Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.
So looks like setting Windows Authentication is the problem. I am not sure what in the multi-step process I have to modify to add authentication to my WCF. Any help will be appreciated.
The example in Your link Access to SQL server is given to a local user NetworkService. This is the default Identity for the Application pool.
In Your case you cannot use a local user account, since the SQL Server is on a different machine.
You need to:
Create a domain account
Grant Access to SQL server to that domain account
Change the Identity for Your Application pool to that of the domain accout

Unable to log in to server in SQL Server 2008 R2 Management Studio

I have a SQL Server 2008 R2 instance and can log in using the sa user. But I want to define another user (administrator) to log in with SQL Server Management Studio, so I did the following:
Logged in to the server in Management Studio as sa.
Right clicked on the database name.
Clicked on properties.
Then under permission, I select the required username (administrator).
And I grant him all the permission.
But when I tried to log in using administrator, I got the following error:
Login failed for user “administator” Error 18456.
Can anyone advise what might be the problem?
If the server encounters an error that prevents a login from succeeding, the client will display the following error mesage.
Msg 18456, Level 14, State 1, Server <server name>, Line 1
Login failed for user '<user name>'
This usually means that your connection request was successfully received by the server name you specified but the server is not able to grant you access for a number of reasons and throws error: 18456.
This eventID sometimes provides also state 1 which actually isn’t that useful as due to security reasons any error is converted to state 1 unless you can check logging on the server.
Microsoft does not provide very useful message boxes so below are some explanations why you get the error.
Invalid userID: SQL Server is not able to find the specified UserID on the server you are trying to get. The most common cause is that this userID hasn’t been granted access on the server but this could be also a simple typo or you accidentally are trying to connect to different server (Typical if you use more than one server)
Invalid password: Wrong password or just a typo. Remember that this username can have different passwords on different servers.
less common errors: The userID might be disabled on the server. Windows login was provided for SQL Authentication (change to Windows Authentication. If you use SSMS you might have to run as different user to use this option). Password might have expired and probably several other reasons….
18456 state 1 explanations: Usually Microsoft SQL Server will give you error state 1 which actually does not mean anything apart from that you have 18456 error. State 1 is used to hide actual state in order to protect the system, which to me makes sense. Below is a list with all different states and for more information about retrieving accurate states visit Understanding "login failed" (Error 18456) error messages in SQL Server 2005
SQL Authentication not enabled: If you use SQL Login for the first time on SQL Server instance than very often error 18456 occurs because Windows Authentication (only) is set in Server properties (security section).
To Access Server Properties,
- Open SQL Server Management Studio, go to Object Explorer pane (use view if you can’t see it).
- Use the connect button to connect to database engine for your server. Once connected you will see it in object explorer.
- Right click server and click properties. Server Properties window will appear.
See below screenshot that might be causing SQL login to fail
You should set Server Authentication to SQL Server Windows Authentication
To resolve this error follow the steps below on computer with SQL Server 2005.
Create new user with Administrator privilege with same username and password as of SQL Server 2008 in operating system.
On SQL Server database create new user by expanding DatabaseNode >> Security >> Login >> - Create New User and add this new user with Windows Authentication radio button selected. - This user can be only added by selected Windows Authentication it is Operating system’s User Login.
Once above two steps are completed when connected from SQL Server 2008 to SQL Server 2005 using Windows Authentication it will connect successfully.
How to fix? Check this link video SQL Server and Windows Authentication Mode page.
Source
You need to add a server login:
Connect to your SQL Server with SSMS as sa.
Drill into the server's Security folder in SSMS's Object Explorer pane.
Right-click on the server's Security > Logins folder that appears in Object Explorer.
Click on New Login... in the context menu that appears.
Provide details of the new login in the Login - New dialog that opens - particularly its General, Server Roles, and User Mappings pages (along the left). (See the screenshots of each page with sample input at the bottom of the answer.)
You may need to add a database user depending on your needs, but a server login (like your sa login) is necessary to connect to the SQL Server instance using Windows or SQL Server authentication. Mapping the new login to a database user (in the Login - New dialog's User Mappings page) will create a new user in the mapped database if you specify a username that does not already exist; alternatively you can map the new login to an existing database user.
Another SO question speaks to the differences between server logins and database users.
Login - New (General page)
SQL Server authentication
or
Windows authentication
Login - New (Server Roles page)
Login - New (User Mappings page)
SQL Server authentication
or
Windows authentication

Unable to open database when website hosted in IIS

When I run my website from Visual Studio it all works fine. Now I am trying to move forward and start testing the multi tenancy part, so I had to move my website to IIS.
For some reason I can't get access to the database. The error I get when I open a page that requires database access is:
Cannot open database "GWD" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\gwd'.
Exception Details: System.Data.SqlClient.SqlException: Cannot open
database "GWD" requested by the login. The login failed. Login failed
for user 'IIS APPPOOL\gwd'.
Another forum describes how to add NT AUTHORITY\NETWORK SERVICE. But that doesn't resolve the issue. I did create the NT AUTHORITY\NETWORK SERVICE and added the dbowner for all existing databases (including master) but no result.
I am out of ideas, can anybody help?
You'll need to change the application pool identity to NETWORK SERVICE as well. Fire up Internet Information Services (IIS) Manager, drill down to Application Pools, and select the Application Pool that you're using. (Not sure? Drill down to your virtual directory under Sites on the left side and then click Basic Settings on the right.) Then click your Application Pool, click Advanced Settings, and then change Identity under Process Model to NetworkService.
In SQL Server Management Studio, you'll need to add the NT AUTHORITY\NETWORK SERVICE user under Security for your database, but it sounds like you already did that.
You see the error "Cannot open database "GWD" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\gwd....." because you copy the application to the IIS server and the membership provider has been added in the web.config file without an applicationName attribute.
I suggest you add an “applicationName” attribute to your provider declaration. Example:
<membership>
<providers>
<add name ....
.
.
.
.
applicationName="/yourWebApp" />
</providers>
</membership>
Just look in the aspnet_Application table to find out the application name that was used when creating the users/data during development.
I hope it helps.
#Nicholas Piasecki has offered one potential solution, and the other would be to leave the app pool as it, and instead grant the AppPoolIdentity that it is currently running under access to the database instead.
First, you'd need to add a new Windows login to the SQL Server for the user: 'IIS APPPOOL\gwd'.
Once you do that, you'll be able to add that user to the database with the appropriate permissions, just as you did for Network Service.
i think you must read this article
Configure IIS, asp.net and SQL Server from codeproject
In this article you will learn how to configure IIS and SQL Server using Network SERVICE (with screenshot)
Content of this article
Install IIS
Configure IIS for Network SERVICE
Configure SQL Server PERMISSIONs
On your IIS
Select the application pool you use on your site > right click > click Advance Settings. On Identity select "NetworkService"
enter image description here
On you database [SQL]
Create Login for NT AUTHORITY\NETWORK SERVICE. Modify User Mapping
enter image description here

In sql server - report server URL acces denied error

when trying to open report server url http://<>/Report server
i am getting error
/ does not have enough permissions rsAcessdenied error.
how to add domain account in reporting services to get all the privileges so that i can open the report server URL.
Go to the management screen at http://<>/Reports using an account with admin access.
Ask your SQL Server DBA what account to use or get them to do this.
Then click on the properties tab, click new role assignment, and add the account which is getting the access denied message (It probably just needs the browser role.)

Get SQL Server Connection info from app without debugging?

We are troubleshooting a SQL Server 2005 connection issue on a closed-source third-party ASP.NET application. The application is a .NET application and the developing company is using a custom formatted configuration file that stores the SQL Server authentication information.
The application when trying to connect to our SQL Server box is getting a "Cannot open database 'databasename'. Login failed for user 'username'" error. We have tested connecting to the SQL Server box from the web server using SQL Server Management Studio and the login information provided to their app, it works perfectly.
Is there any easy way that we can sniff/determine the SQL Server Connection information they are trying to use inside their SqlCommand? Debugging their code is not an option, as it is compiled in Release Mode, and we don't have source. We simply need something to be able to identify why their app cannot connect.
run profiler and choose Security Audit: Audit Login, Audit Login Failed and Audit Logout events. choose all columns.
from that you'll get the app name, and the user that tries to log in from the login failed event.
once you get that check which database is default for that user in SQL Server users.
I just asked some of the guys here and they both recommended trying reflector. If you had some hard coded values in the library, you should be able to see something there.

Resources