Creating SQL Server Windows logins with SSMS if computer name is longer than 15 characters

Posted: (EET/GMT+2)

 

I was today working with SQL Server database security configuration on a new Windows Server 2025 installation. The computer name of the machine is quite long, over the old NETBIOS/SAM limit of 15 characters. My task was to add a local user as a valid login to SQL Server.

So, when I attempted to use SSMS (SQL Server Management Studio) version 22.9 to add a new Windows login top SQL Server, the "Select User or Group" dialog box under the "New Login" dialog (opens by pressing the "Search" button), I got an error.

Usually, I enter the name of the computer first, then the backslash, and finally the account name. For example:

servername\username

After entering this, I click the "Check Names" button. But this time, it showed this error:

The following object is not from a domain listed
in the Select Location dialog box, and therefore
is not valid: myserver-withverylongname\MyUserName.

Okay, what's the problem then? The real Windows account name is using the 15-character version, but SSMS user interface shows the long name, and because there is a mismatch, you cannot proceed.

The best solution I've found is to run the CREATE LOGIN command directly in the query editor:

CREATE LOGIN [myserver-withve\MyUserName] FROM WINDOWS;

Note how I've truncated the long computer name to 15 characters: myserver-withve. If you don't want to count your letters, you can run this in PowerShell:

$env:COMPUTERNAME

This will print the name truncated to the correct length.

Once you have run the SQL CREATE LOGIN command successfully, you can then return to the SSMS GUI operations for setting additional options for the login.

So the problem is only in creating the login, after that, SSMS still is willing to do what you need to do.

I didn't have the chance to verify if this worked in previous SSMS versions, but I'm pretty sure it has. If you know more, let me know.