XenDesktop database creation script fails on DDC login creation

XenDesktop database creation script fails on DDC login creation

book

Article ID: CTX216659

calendar_today

Updated On:

Description

When running the XenDesktop database and login creation script on the SQL instance, the following error is returned by the SQL engine:

Failed to create login [DomainName\DDC_name$] for controller [DomainName\DDC_name$]
(login may already exist but with the wrong SID)
** An error was encountered during execution of batch. Exiting.

Resolution

1 - In the database creation script, search for the failing CREATE LOGIN statement. Example:

declare @LoginName sysname;
set @LoginName = (select name from sys.server_principals
                   where sid = 0x010500000000000515000000BB0988001915CC1B1F08F42AC8A01800);
 
-- Create login if it doesn't already exist.
if @LoginName is null begin
    create login [DOM1\DDCSERVER01$] from windows;
    if @@error = 0
        print N'Login [DOM1\DDCSERVER01$] for controller [DOM1\DDCSERVER01$] created';
    else
        raiserror(N'Failed to create login [DOM1\DDCSERVER01$] for controller [DOM1\DDCSERVER01$] (login may already exist but with the wrong SID)', 18, 1);
end else
    print N'Login [' + @LoginName + N'] for controller [DOM1\DDCSERVER01$] already exists';
go


2 – Verify that the error message is true (that the login already exists with a different SID):
 
select name, [sid] from sys.server_principals
where name = ' DOM1\DDCSERVER01$'
 
>> Compare the value in column SID with 0x010500000000000515000000BB0988001915CC1B1F08F42AC8A01800
 
3 – If the value is different, drop (delete) the login and recreate it from the statement in step 1.

 

Problem Cause

Login from windows already exists with a different SID