Reason: Could not find a login matching the name provided - sql-server

Windows service with logon as domian\user1
Added login to instance with this user, mapped to databases needed.
Connection from service is using windows auth
When it runs, I get this error :
System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.Data.SqlClient.SqlException: Login failed for user domian\user1
Ive tried several things such as net use with the credentials, I know the password is correct.
Checked the spelling, the login matches.
What else?
[ update ]
Looking at the sql log, I see the same thing
Reason: Could not find a login matching the name provided
Its as if this login doesnt exist on the instance

Related

SQL Server v14 - Login Failure

We are using SQL server 2014, we update a password for a user login here
we click properties on a given login account and change the password here
we are certain we entering it correctly when we then try to login to the server using the login and password we get the following error
I don't know where else to look and what else to change -- when we do the same process on a different server it works without issue. But here its failing.
Where should we look and what else do we need to troubleshoot. Could it be we don't have access to certain databases, how do we fix this.
These are some of the errors coming through in the system logs
Message
Login failed for user ‘abc’. Reason: Failed to open the explicitly specified database ‘AMS'. [CLIENT---]
Message
Login failed for user 'abc’. Reason: Failed to open the database ‘Budget’ specified in the login properties. [CLIENT: ---]
Message
Login failed for user ‘abc’. Reason: Password did not match that for the login provided. [CLIENT: ----]
You must set a default database where the user AND relative login can access.
Logins are objects with a password
Users are objects, mapped to Logins, added to SQL Server entities.
Under Server -> Security -> Logins
Unser Database -> Security -> Users
Check also if the user is correctly mapped to the login.
To solve your problem you can set the master database as the default for your login.
You can find out more about the error in the SQLServer logs as described here https://learn.microsoft.com/en-us/sql/relational-databases/performance/view-the-sql-server-error-log-sql-server-management-studio?view=sql-server-ver16.
If you are looking for a quick fix to your problem, you can either:
assign more server roles to your login
or grant it an individual permission
use master;
grant CONNECT ANY DATABASE TO <login>;

Azure AD user unable to connect to Azure SQL Error: 18456,State:1,Class:14

BACKGROUND
The user is defined in Azure AD and in Azure SQL.
test.user#company.com is defined and active in Azure AD. I’m able to log in with this user in Azure portal.
I have created a contained database user with the clause "from external provider" in the Azure SQL database and added the user to the db_datareader system role. The commands commits without error. I have compared the Asset ID in Azure AD and the SID in database and they match. I have tried with different users.
I am able to login as an AD User assigned to the SQL servers assigned "Active Directory Admin"
SQL Server users also login without any issue
Login test in SSMS
I have set default database to the specific database I’m trying to log into (Options-Connect to database).
I have tried with different Authentication modes:
“Azure Active Directory – Universal with MFA” and
“Azure Active Directory – Password”
When I try to login with SSMS I get
Error: 18456, state 1, class 14.
When I query [sys].[event_log] it returns
[event_systype]= 4, [event_subtype_desc] = login_failed_for_user.
PROCESS FOLLOWED
I have a user defined in Azure AD. (test.user#company.com)
In my Azure SQL database, I have set an Active Directory administrator.
I have created a user in SSMS test.user#company.com with the following syntax:
CREATE USER [test.user#company.com] FROM EXTERNAL PROVIDER;
I have assigned the user to the db_datareader role with the following syntax:
ALTER ROLE db_datareader ADD MEMBER [test.user#company.com]
ISSUE: When I try to connect as test.user#company.com, the connection fails and I get this error:
Login Failed for user test.user#company.com
Details of error contains:
Error Number: 18456, State: 1, Class: 14
I have tried to find an answer on learn.microsoft.com, googled my ass off and found some useful resources on this, but none that actually helps me with pinpointing what to do to resolve the issue. If anybody have an Idea of what I'm doing wrong, ref "PROCESS FOLLOWED" I'd be forever grateful :)
I solved it by a workaround, setting up a new database.
I did not find the cause of the problem, but it must be related to database setup "DTU"-"Basic" or some setting that I have managed to set without remembering.
Anyways, my process works when I set up a new database with "DTU"-"Standard" Configuration.
It seems to be some kind of encoding problem. After almost giving up and using a different DB, I tried creating a new one, but without some special characters. And suddenly, it worked.
If you can't change your database's password, you can just edit the connection string in another editor and it works as well (Notepad, VS code, etc).

Getting login failed for user 'IIS APPPOOL\CoreApplications' even with username password

I'm getting the following error
Database Error: Cannot open database "TrendingDB" requested by
the login. The login failed. Login failed for user 'IIS
APPPOOL\CoreApplications'.
Even if I have a username password on my connection string. I use the same applications on the same 3 different environments, except that when I deployed the same application on another environment with it's own appsettings, it would give me the above error.
Not sure what I missed on the setup with this current environment. The username is verified to exist and can log in using the password. Also double checked the access to execute the stored procedure it's calling from the API.
The application is a .NET Core API.
{
"AppSettings": {
"Environment": "UAT",
"ConnectionString": "server=localhost\\SQLEXPRESS;database=TrendingDB;Connect Timeout=120;Trusted_Connection=True;User=webservice;Password=trending123"
}
}
You specify Trusted_Connection=True in your connection string. This uses the Windows Identity for the process and ignores any username and password you specify in the connection string. Remove that, so your connection string looks like
{
"AppSettings": {
"Environment": "UAT",
"ConnectionString": "server=localhost\\SQLEXPRESS;database=TrendingDB;Connect Timeout=120;User=webservice;Password=trending123"
}
}

sql server log messages abouts logins

After i logged in to SQL server using management studio i opened the log and i got a million messages showing
Login failed. The login is from an untrusted domain and cannot be used
with Windows authentication. [CLIENT: 222.186.61.5]
or
Login failed for user 'sa'. Reason: Password did not match that for
the login provided. [CLIENT: 222.186.61.5]
or
Login failed for user 'kisadmin'. Reason: Could not find a login
matching the name provided. [CLIENT: 222.186.61.5]
or
Login failed for user 'wwo'. Reason: Could not find a login matching
the name provided. [CLIENT: 104.217.216.169]
I have many more logs for many users and IP's which first appeared 10/6/2015 8:06:19 PM (and i have them everyday). Are these messages showing that i have been cyber attacked ?
What you see is a set of failed login tries, so, you can know for sure that someone tries to hack your database. Unfortunately, if there were successful attempts, then people might have read some data from your part. You need to kill all active connections and change the port you are using for your database.
Also, it would be nice if you would think about how people were able to try to log in to your database. Are you having by accident any public information about where your database server is (like error messages, for example)?

Weird "Login failed for user 'sa': in Event viewer

I'm hosting my web application on an azure VM. I've created a new user for MSSQLSERVER which my application can use to access the remote SQL server on that machine (so i do not use the sa user in my application). I have no problems at all accessing it, but i accidentally opened the Event Viewer and I found that each time I log into my application I get tens of messages that say
"Login failed for user 'sa'. Reason: An error occurred while
evaluating the password. [client: ......]
I first thought that it was an intruder, but then I realized that this message appears once I login to my application.
Why could this message be shown ?
It is a state 1 issue, password validation gets done all-right, the problem is it is disabled for that user, in this case your MSSQLSERVER user or sa.
Try logging in with sa, and log out to refresh credentials . grant all permissions to new user that you created, and log in with your newly created user. This should solve the problem [make sure that error number is either of 18470 or 18456].

Resources