Problem

When trying to create a login the following error appears:

USE [master]
GO
CREATE LOGIN [Domain\LoginName] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO

 Msg 15025, Level 16, State 2, Line 1

The server principal ?Domain\LoginName? already exists.

 

Solution

First check if the login is already created:

select * from sys.server_principals where name LIKE '%Domain\LoginName%'

(0 row(s) affected)

 

In my situation the login wasn?t already created so the only thing left was to check if there was some other login created on this instance with the same SID.

 

...

 

So, I found out the user's SID by executing:

SELECT SUSER_SID('Domain\LoginName')

 

Then I queried the sys.server_principals to see the corresponding login name:

select * from sys.server_principals where sid = 0x010500000000000515000000BE043E329THSTU52828BA6288AE30000

The result shows another login having the same SID as the one I was trying to create. It seems that the account was renamed in AD but the SID remained unchanged and because the login wasn?t dropped,  SQL Server continues to recognize that account even though the name is now different.

The solution is to delete the already existing login and create the new one.  Off course, prior to deletion, a good idea would be to save the login?s rights.

 

 


No feedback yet