Authentication failed when querying data from linked server with SQL authentication - sql

I have 2 SQL Servers on one machine. Lets call it Server1 and Server2. I need to access Server1 from Server2 through the linked server. And I have managed to configure it but querying the linked server works only when I am logged with windows authentication method to Server2. When I will log with SQL login 'sa' into Server2, I am getting an error when executing a query:
The OLE DB provider "..." for linked server ".." reported an error.
Authentication failed.
This is the security setting I am using in linked server configuration:
Linked server security tab
Please help.
Error Log from the remote server:
06/24/2022 09:23:33,Logon,Unknown,Login failed for user 'NT Service\MSSQL$SQLEXPRESS'. Reason: Could not find a login matching the name provided. [CLIENT: <local machine>]
06/24/2022 09:23:33,Logon,Unknown,Error: 18456<c/> Severity: 14<c/> State: 5.

Error Log from remote SQL server made me think, so I have added new user NT Service\MSSQL$SQLEXPRESS to remote server. Now I am available to run queries against linked server.
I am puzzled though why linked server is using network service account despite having configured remote sql login sa in security tab. I would appreciate if someone could clarify this to me.

Related

Create API acceess to SQL Server Express 2014

I have kind of simple issue but fail to resolve it.
Here's the issue: I have SQL Server Express 2014 installed on my PC. I have to use SQL Server authentication because it should work when network is down. As sa I created login and user e.g. user1. Then as user1 I created DB e.g. db1 and a few tables. Now I could login into db1 as user1 using SQL Server authentication. The problem is that this db1 will be used by application e.g. app1. This app1 has configuration file that has all credentials and other connection strings things. Well when I start that application it throws error "Can't connect to database". Then I look into log and see this: Error: 18456, Severity: 14, State: 8. Login failed for user 'user1'. Reason: Password did not match that for the login provided [CLIENT: .
Then I could disable credential check in configuration file of app1 and then I don't have problem to start app1 but I have to use credential check.
Then I tried to created ODBC connection and use the same credentials and I succeed to connect.
Could some give the idea what could be wrong and I can't connect to db1 from my app1?
Thanks
All set, Thanks for info. I installed client 2008 R2 and now it's working. The problem was with the type of authentication. In my case it was equal 'true' and expected exact SQL user password which I was not able to pass because it was encrypted. When I change the type to 'false' it started to use Windows authentication and that resolved my problem.
Ticket could be closed

Unable to connect to SQL Azure remotely from SSMS 2012

I am unable to connect to my SQL Azure database instance remotely using SQL Management Studio 2012. Firewall exception is in there for my local IP. I can connect successfully and admin the database using the browser based management link in my Azure account.
I just can't seem to connect to the database via SSMS or anything else like VS2012.
Here is the format I'm for my connection in SSMS:
Server Name: myservername.database.windows.net
Authentication: SQL Server Authentication
Login: myusername#myservername
Password: my-password
Connect to: (i've tried) "master", mydatabasename, <default>
Encryption: TRUE
Once again, I DO have the firewall rule active for my local IP address on the server instance of my Azure account.
When I attempt to connect, I receive this error:
A connection was successfully established with the server, but then an
error occurred during the pre-login handshake. (provider: SSL
Provider, error: 0 - the wait operation timed out.) (Microsoft SQL
Server, Error: 258)
When searching for that 258 error, I do not get many results related to SQL Azure. I appreciate any help.
Error 258 is generated due to some of the configuration within your machine if a secure network could be established between two endpoints and if one machine initiate secure channel. This problem could be very much machine specific and not SQL specific that why you did not find any resources on this regard.
Can you try using SQLCMD as described in the following troubleshooting guide and see if that works to isolate SSMS specific issues on the same machine:
http://social.technet.microsoft.com/wiki/contents/articles/1719.windows-azure-sql-database-connectivity-troubleshooting-guide.aspx
IF you capture and analyze network packets traffic you might be able to determine the root cause of connectivity error.

Connection via ODBC to SQL Server failing

I have a strange issue. I can connect from one Terminal server to the SQL server as an admin. I can also connect to the server via a straight SQL connection as a normal user. When I try and log on to the server using odbc I receive the following error.
07/08/2011 10:49:14,Logon,Unknown,Login failed for user ''. Reason: An attempt to login using SQL authentication failed. Server is configured for Windows authentication only. [CLIENT: 10.0.0.25]
07/08/2011 10:49:14,Logon,Unknown,Error: 18456 Severity: 14 State: 58.
The SQL server is definitely in mixed mode and a user is definitely set up in the connection. It must be a permissions issue.
Probably the user that tries to login does not have permission to the database he/she is trying to connect.
Go to the SQL Server > Security > Select the User - Right Click > Properties > User Mapping
And there select the database that user needs to access (check box in the map column)
I'm pretty sure that error had happened to me before that that's how I fixed it. Assuming it is true that your server is setup as mixed mode already.
If your using ado.net, make sure your using the ODBC data adapter, connectors and odbcCommands instead of the SQL ones. ;)

Getting Login error in sql server 2008

I have SQL server 2008 and it was working fine ,but today while starting SQL server I am getting the following error :
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)"
In SQL Server Configuration Manager--> sql server services --> MS sql server and all other service status is showing as stopped(previously it was running). I have tried to make it start but the request failed..I have checked the event log ,its showing "The SQL Server (MSSQLSERVER) service failed to start due to the following error:
The service did not start due to a logon failure" ....My SQL server is taking windows authentication and few days back I have changed the PWD ..can it b the reason..pls help.
Note: Its not remote connection..the server is My system only..
Thanks Stuart for ur suggestions but the problem was a bit different.
I got the sloution from http://dotnet.org.za/thea/archive/2004/06/09/2069.aspx
Its working Now :-)
In server properties in security, check that server authentication is set to
SQL SErver and Windows Authentication mode.
EDIT: I had similar error after installation of service pack, the install switched the server authentication mode to windows only.
1.Management Studio
2.Object browser should be open in the left hand pane
3.Right click on the server instance name
4.Select properties from the menu choices
5.Server Properties dialog opens
6.Select security on the left hand menu items
7.On the right, there will be server authentication, select 'SQL Server and Windows Authentication Mode'
This should allow you to log in as sa, once running and you are in, make changes if required to Logins and Roles

Unable to Connect to SQL Server 2005 Db From Vista x64 Windows Service

I'm trying to connect to a remote SQL Server 2005 db from a .NET Windows service running in Vista Home Premium x64. I can access the remote db from a console app with no problem. I can connect to a local db from the Windows service with no problem. I was able to connect from a service from XP with no problem. There's no firewall or anti-virus running. How do I configure this service to be able to connect to the remote db?
I've tried to connect by running the Windows service as a local admin account, LocalSystem, LocalService, and NetworkService.
The connection string:
Data source=SERVER_NAME;Initial Catalog=DB_NAME;Integrated Security=True;
The error:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
MORE INFO:
I have also tried to connect using SQL Server authentication with no success:
Data Source=SERVER_NAME;User ID=USER_ID;Password=PWD;Initial Catalog=DB_NAME
This connection string works from the console app too.
MORE INFO:
I ran Process Monitor for the Windows Service and the console app. The Windows service showed \SERVER_NAME\pipe\sql\query was ACCESS DENIED but the console app showed SUCCESS when reading/writing files to \SERVER_NAME\pipe\sql\query.
Good Lord! Why all the gibberish and complex responses on this site. Create a User Account
Either local or Domain and set the service to use that account. Then go into your SQL Server and Add you new account to the Database and set permissions. Voila!
Oh yeah, dont plague yourself with SQL Authentication. Integrated Security is much easier to maintain and without a password in your web.config your much safer.
1) open a command prompt. Type "ping SERVER_NAME". Does it respond? You may have a DNS or connectivity issue if this doesn't work.
2) "telnet SERVER_NAME 1443". Do you see anything or does it refuse your connection? This will definitively tell you whether or not someone is listening on the other end.
3) Go into SQL Server Management Studio. Right click Properties of your server. Select "Connections" from the left side. Is "Allow Remote Connections" checked?
4) Since you're running using network service/system, you will need to make sure you have a login configured on your server for the machine account DOMAIN\CLIENTSYSTEMNAME$. Note the $ sign. This is your machine account, and this will be the user that SQL Server will see.