Wednesday, August 10, 2016

Message 15063, Login Already Exists

Recently, I received an error from a Share-Point 2013 database creation from the Farm Account

As you all know, while triggering a new database from SharePoint Site its uses a farm account to create a new database on SQL Server, and during the creation as a DBA its our responsibility to grant necessary permissions, in my case I have granted DB_Creator server role as per MS recommendations.
after the database has created by the farm and is the owner of the database, but still its not able to access within the database. Very strange huh..
and then I got involved in to the issue to have it fixed.

I tried to add users, since it does not exist in the database, but the user has db_owner rights when I tired to add Farm account to the database from the login in properties users mappings in the GUI very strange. and I received an error while tried to add and hit OK.

The login already has an account under a different user name. 15063

I verified the database login and user info by running the below script. 

SELECT  l.loginname , u.name AS username
FROM    sysusers u INNER JOIN master..syslogins l ON u.sid = l.sid

I found that the users is mapped to [DBO]. So  I changed the database owner to 'sa'
by running the below script

sp_changedbowner 'sa'

and then I ran the below statements to grant access to the existing farm account. 

CREATE USER [domain\FARMacocunt] FOR LOGIN [domain\FARMacocunt]
GO

ALTER ROLE [db_owner] ADD MEMBER [domain\FARMacocunt]
GO

That's how I resolved the issue,  but I do not know why it happened to behave like this during the time of new database creation.