Sunday, 22 May 2022

SQL Server : Unable to connect to the database, error message Logon Login failed for user 'USER01'. Reason: Password did not match that for the login provided. [CLIENT: 10.xxx.xxx.xxx]


In this article, you will be able to see how to troubleshoot when you are unable to connect to the database and getting an error message "Logon Login failed for user 'USER01'. Reason: Password did not match that for the login provided. [CLIENT: 10.xxx.xxx.xxx]."

Please allow me to explain you as per the error message it seems that Password you are providing for user "USER01" is not matching with actual one.

You can follow the below steps as a troubleshooting :
1. If you have SQL Server Management Studio, please re-try and test connectivity with the login and correct password.

2. If you are checking from Application Server then check the user / password settings with an udl file from the application server; just follow the steps below :

2.1) Create a new empty text file like "test.txt" (For example, right mouse click on an empty place on your desktop, select "New" and "Text Document")
2.2) Rename the file as "test.udl"
As soon as you renamed the file, text file icon should change to a UDL icon
2.3) Double click on test.udl file and you'll receive a window titled "Data Link Properties"
2.4) Provide the correct username and password; Test Connectivity from application server

3. You can check if there is any orphan user by the same login using below command:
-- command to check orphan user, this will give you the SID:
Use [YourDB_Name]
GO
EXEC sp_change_users_login 'Report'
GO

If that is the orphan user, than to fix the orphan user using below command:

-- First drop the user from login and then re-create using below script.
-- get the sid using above command for corresponding user
use master
go
CREATE LOGIN login name WITH PASSWORD = 'login password', sid='' -- use the same SID given by above script
GO

Tuesday, 2 November 2021

AWS : How to connect S3 Bucket from EC2 Instance which is in Private VPC without Internet access?

Problem:

How to upload the files to S3 bucket from the Win Server (i.e. EC2 Instance) which is in private vpc with no general internet access?

 

Solution:

First of all, as you already know to enable an upload you need to ensure that there is a connectivity between Server and S3 Buckets.

So there are different approaches based upon Setup and Configuration, few options explained as follows:

1. If the EC2 instance and the S3 bucket are in the same AWS region, Then Using VPC Endpoint : You can use VPC Endpoints and associate it with the route table of the EC2 instance's subnet which would allow traffic to the S3 service in that region even if you don't have a NAT or Internet gateway associated with your subnet.

For more about S3 VPC endpoints:
    S3 VPC endpoint in detail:
        [+] https://docs.aws.amazon.com/vpc/latest/userguide/vpc-endpoints-s3.html
    create a VPC Endpoint:
        [+] https://aws.amazon.com/blogs/aws/new-vpc-endpoint-for-amazon-s3/

2. If the EC2 instance and the S3 bucket are in different AWS regions, Then Using NAT Gateway or Internet Gateway: You have to make use of either NAT Gateway or Internet gateway to allow traffic from your instance to the S3 service in that region.
If you dont want to keep the internet open on the server, you can later deny traffic between your EC2 Instance and S3 Service after copying the backup file on to S3 Bucket.

For more about NAT\Internet Gateways:
    NAT gateways :
     [+] https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html
    Internet gateways :
     [+] https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Internet_Gateway.html