Karan Parmar
Karan Parmar

Reputation: 41

Connection string ignores userId and pwd provided and logins with the Windows authentication user

In the .net core I'm having a connection string something like this, Data Source=.\\SQLEXPRESS;Initial Catalog=TestDB;MultipleActiveResultSets=True;User Id=AdminUser;Password=Admin;Integrated Security=True,TrustServerCertificate=True

I've added a user as AdminUser to the SQL and for the testing purpose I deleted it. But even after that it get succedeed and ignores the given UserId and Pwd but instead it should throw me the error something like 'Login failed for the user' but it shouldn't.

I found that the Integrated Security was ignoring the user id and pwd, so I tried removing it and then it was throwing the error like this:

System.Data.SqlClient.SqlException : A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) ---- System.ComponentModel.Win32Exception : No process is on the other end of the pipe.

I've also used the Trusted_Connection=True, but still same issue for it too that stated above.

Upvotes: 0

Views: 112

Answers (1)

Rahul Timbaliya
Rahul Timbaliya

Reputation: 36

Like if you have to connect sql server with the Windows Based Authentication then use Integrated Security=True;

Server=server;Database=database-name;Connect Timeout=120;Encrypt=False;MultipleActiveResultSets=true;Integrated Security=True;

Used SQL Server Authentication then Use User ID=usename; Password=password; Server=server;Database=database-name;User ID=username;Password=password;Connect Timeout=120;Encrypt=False;TrustServerCertificate=False;MultipleActiveResultSets=true

Upvotes: 0

Related Questions