How to create a SQL Server account for a non-English Windows service account?

Given Windows Server 2008 R2, in which service accounts use a non-English display language, with SQL Server 2008, the following Transact-SQL statement fails:

CREATE LOGIN [NT AUTHORITY\NETWORK SERVICE] FROM WINDOWS ... 

with the following error:

Windows NT user or group "NT AUTHORITY \ NETWORK SERVICE" was not found. Check the name again.

(or the same non-English message for service accounts, depending on the context).

The same statement succeeds if the service accounts use English as their display language.

The reason seems clear: for example, in the German system, the display name for this account is NT-AUTORITÄT\NETZWERKDIENST , and the name NT AUTHORITY\NETWORK SERVICE (with a space) is not recognized. Also, the non-localized name NT AUTHORITY\NETWORKSERVICE (without space) does not work.

My question is: how do I rewrite the above expression so that it works regardless of the display language? Or am I forced to find out the localized name (in InstallScript in my case)? Then i can use

 CREATE LOGIN [NT-AUTORITÄT\NETZWERKDIENST] FROM WINDOWS 

which is working...

+7
sql-server tsql windows-server-2008-r2 locale
Jun 27 '11 at 17:15
source share
3 answers

From what I tried and from what I read in the German forum entitled "Famous SID im SQL Server nutzen" , this is not possible. Obviously, unfortunately, SQL Server CREATE LOGIN was designed to accept only a localized name in the format DOMAIN \ username.

A hint from the same thread is to look at the "Localized Service Names" section of the "Configuring Windows Service Accounts" section for the local names that should be used in the CREATE LOGIN statement.

The only alternative is to try to find out the system language of the Windows system running SQL Server, and then use the Localized Service Names table to find the localized service account name and use it to create a working CREATE LOGIN statement.

+4
Jul 23 2018-11-11T00:
source share

You must be able to change the language for this to work.

 SET LANGUAGE us_english CREATE LOGIN [NT AUTHORITY\NETWORK SERVICE] FROM WINDOWS ... 

I work on Swiss German servers with us_english for SQL Server and we never had to do such things. Therefore, I assume that SQL Server takes care of its own language settings.

NTN

+2
Jun 27 2018-11-11T00:
source share

This works for me on SQL Server 2008R2:

 IF (SELECT COUNT(*) FROM sys.server_principals WHERE sid=0x010100000000000514000000)=0 BEGIN DECLARE @cmd VARCHAR(200) SET @cmd = N'CREATE LOGIN [' + SUSER_SNAME(0x010100000000000514000000) + '] FROM WINDOWS' EXEC (@cmd) PRINT 'Created network service server login from SID' END ELSE PRINT 'Network service account found from SID, server login not created' 

Can anyone check this in non-English Windows - German, Italian?

+2
Aug 08 '14 at 1:00 a.m.
source share



All Articles