snippetMinor
How to login with Windows Authentication mode after domain name changes in SQL Server?
Viewed 0 times
afterwithsqlmodeloginauthenticationnamechangeswindowshow
Problem
I am using SQL Servre 2008 R2. I recently changed my domain name and after that when I try to login to SSMS using Windows authentication, I get an error
Login Failed For User UserName
Microsoft Sql Server Error : 18456.
How to resolve it? Can somebody please help to get login in SSMS using Windows authentication mode again?
Thanks in advance
Login Failed For User UserName
Microsoft Sql Server Error : 18456.
How to resolve it? Can somebody please help to get login in SSMS using Windows authentication mode again?
Thanks in advance
Solution
You should login with SQL authentication (with your sa account)
and run this query:
You will then be able to login with your new domain name (be sure you change the domain name and username in the code).
If you need to recover your sa password you can read this article
http://v-consult.be/2011/05/26/recover-sa-password-microsoft-sql-server-2008-r2/
and run this query:
DROP LOGIN [OldDomain\UserName]
GO
CREATE LOGIN [NewDomain\UserName] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO
ALTER SERVER ROLE [sysadmin] ADD MEMBER [NewDomain\UserName]
GOYou will then be able to login with your new domain name (be sure you change the domain name and username in the code).
If you need to recover your sa password you can read this article
http://v-consult.be/2011/05/26/recover-sa-password-microsoft-sql-server-2008-r2/
Code Snippets
DROP LOGIN [OldDomain\UserName]
GO
CREATE LOGIN [NewDomain\UserName] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO
ALTER SERVER ROLE [sysadmin] ADD MEMBER [NewDomain\UserName]
GOContext
StackExchange Database Administrators Q#33637, answer score: 5
Revisions (0)
No revisions yet.