Sql-server – Login issues for the same SQL login on mirror server working fine on principal server

loginsSecuritysql serversql-server-2012

I will try my best to describe the situation, while we've been trying to figure this out:

We have this SQL Login [LA] which shows successful connection on principal server in the sql error logs [connection made from various apps]. This login shows successful connection on its mirror server as well.

Now, here is this another login [LB] which connects successfully on principal server but fails to connect on mirror server. [same application as above login LA connects]

Troubleshooting done:

  1. run sp_help_revlogin on both servers and matched the hashed password for login [LB]. Thus that confirms password is same for this login in terms of SQL login for both principal and mirror.

  2. SID's of login is same at both servers, so this should not be a problem as well.

  3. Application uses same creds to connect on principal which is a success but shows login failed on mirror server.

Since something is making the login unsuccessful attempts, login keeps getting locked out.

What else can i check as a DBA before passing this as an application issue to the app owners?

Please help me troubleshot to find the root cause of this issue, thank you.

Best Answer

If logins are getting locked, that indicates the password is incorrect. Either the server has the incorrect password recorded for the login, or the client is presenting the wrong password.

Since this is a mirroring environment, I'd bet the client is using the same password for both instances; meaning the password for the login on the mirror is not the same as the password for the login on the master.

Recreate the login on the mirror server with the known-good password, i.e. not the hashed version.

Ensure you get the sid correct (use copy-and-paste) from this query, ran against the principal server:

SELECT sp.name
    , sp.sid
FROM sys.server_principals sp
WHERE sp.name = 'login_name';

Use that sid in the CREATE LOGIN statement you run on the mirror:

CREATE LOGIN login_name
WITH PASSWORD = 'thepassword'
    , SID = 0x000000000000 --put the real sid here.
    , DEFAULT_DATABASE = tempdb;

The sid is only important because it links the login to the user inside the database.