For SQL Server 2012 and above, as What's New in SQL Server Installation states:
BUILTIN\administrators and Local System (NT AUTHORITY\SYSTEM) are not automatically provisioned in the sysadmin fixed server role.
In my case this has become a problem: I have a WiX installer which uses a
Custom Action C++ code to setup database data (create the database, views, procedures, data etc.).
Custom Action runs as user
NT AUTHORITY\SYSTEM, but this account does not have permission to execute
CREATE DATABASE scripts.
Is it correct to give
NT AUTHORITY\SYSTEMwhile installing software? Or maybe there is a better solution?
If it is correct, is it possible to find the proper user name for
NT AUTHORITY\SYSTEM? I need this name in order to change permissions*. In different locales this name is different, for example,
NT AUTHORITY\SYSTEM to the
IF NOT EXISTS ( SELECT name FROM master.sys.server_principals WHERE IS_SRVROLEMEMBER ('sysadmin', name) = 1 AND name LIKE 'NT AUTHORITY\SYSTEM' ) EXEC master..sp_addsrvrolemember @loginame = N'NT AUTHORITY\SYSTEM', @rolename = N'sysadmin'
name LIKE 'NT AUTHORITY\%' will not work because sometimes there will be more than one
NT AUTHORITY\... user. I encountered a case like that on one of my virtual machines.