Sql connection string using sql authentication

I use this sql connection string:

string connection = "data source=OSBORNECHARLES2;initial catalog=TWO; integrated security=False;User ID=userid;Password=PWD"; 

I get this error:

A connection to the server was successfully established, but then an error occurred during the login process. (supplier: shared memory Supplier, error: 0 - there is no process at the other end of the pipe.)

If I set integrated security=True; , it works.
If I log in with another window user, I get an error.

Could you tell me why I get this error.

+4
source share
3 answers

I'm going to take a chance here. I would suggest that your SQL instance is installed only for Windows \ Integrated logins. The user password \ password that you set in the connection string is intended only for logging in to the SQL system; you cannot transfer it to other Windows users in this way. It would seem that you are trying to impersonate using the connection string. I wish everything was so simple.

Thus, you probably need to enable mixed-mode protection in your sql instance and create accounts for that user, or you must impersonate the Windows user in your application and then use integrated protection.

+3
source

I think you can use this

 Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword; 
+2
source

I know this is an old question, but which provider did you use. According to this post, "SSPI" works with both SQLClient and Oledb, while "true" / "false" only works with SQLClient.

Here is another useful post on this subject, which explains that using "SSPI" or "true" will result in an attempt to use the windows credentials of the current user.

I agree with some other comments. Possible reasons: 1) SQL authentication is not enabled on the server. To troubleshoot, you can do the following: a. Try accessing through SQL authentication through SSMS. If it succeeds than you know, SQL authentication is enabled. 2) The user to whom you are trying to log in with this failure does not have permission. a. Verify that the user has a master server. As an additional measure (although I don’t think it is important) make sure that the main server is bound to the main database object in its default database.

If it is a remote server, you will need to enable all the necessary services that can be performed in SQL Server Configuration Manager.

+1
source

Source: https://habr.com/ru/post/1432287/


All Articles