Skip to content

Ulysses Neves

Microsoft Entra ID, authentication, and hybrid identity troubleshooting.

Menu
  • Início
  • Microsoft Azure
  • Microsoft AD FS
  • Microsoft 365
  • Contact
Menu

AD FS – Migrating ADFS configuration Database from WID to SQL using SSMS

Posted on 22 de January de 2021

Hi all. Today I will share with you the steps to migrate the AD FS configuration database from WID to SQL server using the SQL Server Management Studio (SSMS). These instructions will help Windows admins planning to migrate to SQL databases in order to be able to escalate more than 100 Relying Party Trusts, have more than 30 AD FS servers and other improvements that are described in this document.

The AD FS configuration database stores all configuration data that represents a single AD FS instance or Federation Service. This configuration data can be stored in either a SQL Server database or using the Windows Internal Database feature included with Windows Server since 2008 to 2019.

Requirements to run the migration

  • At least one SQL Server or SQL service with High availability. We are using Windows server version 2019 with SQL Service.
  • One AD FS server as primary or more than one for High availability. We are running AD FS on a Windows server 2019 version.
  • SSMS installed in both AD FS and SQL servers. We are using SSMS version 18.8.

Starting the migration

To start the migration, follow steps below on AD FS server:

Download SSMS latest version – https://aka.ms/ssms


Install SSMS tool in your currently Primary ADFS Server.

Check the current Database Connection String and Name by running the PowerShell cmdlet below:

Get-WmiObject -namespace root/ADFS -class SecurityTokenService

Take the highlighted connection string shown in the ConfigurationDatabaseConnectionString parameter above.

Run command below to stop AD FS Service:

net stop adfssrv

Open SSMS and connect to the instance below taken from previous step:

Click Connect.

After connecting to the WID database, we’ll see both AD FS configuration databases to be migrated as below:

Note: Depending on the AD FS farm behavior level, you might see a different AD FS configuration Database name as below:

Windows Server VersionFBLAD FS Configuration Database Name
2012 R21AdfsConfiguration
20163AdfsConfigurationV3
20194AdfsConfigurationV4
Reference: https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/deployment/upgrading-to-ad-fs-in-windows-server#ad-fs-farm-behavior-levels-fbl

Detaching de WID databases

Let’s detach the databases from WID via query: 1-Right-click the Database’s connection and 2-Select New Query.

Use the below SQL Commands in the Query option:

USE [master]
GO
EXEC master.dbo.sp_detach_db @dbname = N'AdfsArtifactStore'
GO
EXEC master.dbo.sp_detach_db @dbname = N'AdfsConfigurationV4'
GO

Copy the Database files below from “C:\Windows\WID\Data” folder to the desired directory on the Destination SQL Server. In our SQL server, the destination will be “C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA”.

C:\Windows\WID\Data\AdfsConfigurationV4.mdf
C:\Windows\WID\Data\AdfsConfigurationV4_log.ldf
C:\Windows\WID\Data\AdfsArtifactStore.mdf
C:\Windows\WID\Data\AdfsArtifactStore.ldf

Source (AD FS server):

Destination (SQL Server):

In the SQL server, follow the instructions below to attach the copied databases:

In SQL Server, open SSMS and connect to the default database:

Attach the Databases to the Destination SQL Server using a new Query with commands below:

GO
CREATE DATABASE [AdfsConfigurationV4] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\AdfsConfigurationV4.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\AdfsConfigurationV4_log.ldf' )
  FOR ATTACH
GO
USE [master]
GO
CREATE DATABASE [AdfsArtifactStore] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\AdfsArtifactStore.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\AdfsArtifactStore_log.ldf' )
  FOR ATTACH
GO
ALTER DATABASE AdfsConfigurationV4 set enable_broker with rollback immediate
GO

After running the query, we see the AD FS configuration databases and the successful query’s result as below:

Configure AD FS Account’s permission in the SQL service

In order to have the appropriate permissions in the new server, the AD FS service account must have at least a public login and the db_genevaservice roles into SQL to access both databases.

To validate the permissions in SSMS, go to Security > Logins. If you don’t see the AD FS service account, right-click on Logins and select New login

1 – Keep selected Windows authentication.
2 – Type the AD FS service account in the Login name’s Box.

In case you don’t know which account is used by AD FS service, in the AD FS server, run command below:

Get-ItemProperty -Path HKLM:\SYSTEM\CURRENTCONTROLSET\SERVICES\ADFSSRV | Select ObjectName 

After configuring the AD FS service account, make sure it has the correct roles selecting option User Mapping > Select the AD FS databases and check the roles:

Updating the main Database Connection string in AD FS Server

In AD FS server, check if the AD FS service is stopped. If not, stop the service and proceed to next step:

Run commands below to update the connection string:
Note: Customize the command according to your SQL server/instance.

$temp= Get-WmiObject -namespace root/ADFS -class SecurityTokenService
$temp.ConfigurationdatabaseConnectionstring="data source=<SQLCluster\SQLInstance>; initial catalog=AdfsConfigurationV4;integrated security=true"
$temp.put()

Start AD FS Service and check if you have Event ID 100 into Event Viewer > Applications and Service Logs > AD FS > Admin.

Updating the AdfsArtifactStore Database Connection string for Primary ADFS Server

Now let’s configure the connection string for database AdfsArtifactStore running command below:
Note: Customize the command according to your SQL server/instance.

Set-AdfsProperties –artifactdbconnection "Data source=<SQLCluster\SQLInstance>;Initial Catalog=AdfsArtifactStore;Integrated Security=True"
Restart AD FS service running command Restart-Service adfssrv.

In case you have Secondary ADFS Servers

In this lab I don’t have a secondary AD FS server but in case you have, follow instructions below in all secondary AD FS servers:

Stop ADFS Service with PowerShell using command Stop-Service adfssrv and run commands below to update the connection string:

$temp= Get-WmiObject -namespace root/ADFS -class SecurityTokenService
$temp.ConfigurationdatabaseConnectionstring="data source=<SQLCluster\SQLInstance>; initial catalog=AdfsConfigurationV4;integrated security=true"
$temp.put()

Start AD FS service with command Start-Service adfssrv and check if event ID 100 shows up in the AD FS Admin logs.

Note: After moving successfully to SQL Database, in case you have more than one AD FS server, all AD FS servers in the farm become primary.

Summary

In this article, we covered how to migrate your AD FS configuration database from WID to SQL using SSMS.

I hope you have enjoyed reading this article and it helps you when administering your AD FS environment.

Enjoyed the article? Like and share. 🙂

Note: I do not represent the organization I work for, all the opinions expressed here, are my own. This post is provided AS IS with no warranties or guarantees and confers no rights.

In case you have any suggestions or feedback, please leave a comment.

[ ]’s

Ulysses Neves

4 thoughts on “AD FS – Migrating ADFS configuration Database from WID to SQL using SSMS”

  1. Thomas says:
    22 de September de 2021 at 01:32

    Wow, thanks so much. I had MS support to help me with this and paid 5 hours of support and they can’t even get it done but your instruction is so great that I went through the ADFS database migration from WID to SQL just only once.
    Thanks so much!

    Reply
    1. Uneves says:
      22 de September de 2021 at 04:59

      Nice to be able to help! 🙂
      Remember, I do not represent the organization I work for, all the opinions and steps expressed here, are my own. This post is provided AS IS with no warranties or guarantees and confers no rights.

      Reply
  2. Phil says:
    15 de October de 2021 at 12:42

    This will definitely come in handy. Thank YOU for taking the time to publish this instructional.

    Reply
    1. Uneves says:
      15 de October de 2021 at 12:54

      Nice to be able to help and thank you for the feedback. 🙂

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Microsoft Authenticator Will Block Jailbroken Devices in 2026 — What You Need to Know 17 de March de 2026
  • Enhancing Azure role activation security with FIDO2/Passkeys 23 de September de 2024
  • Microsoft Entra ID CAP | Enforcing WHfB using Authentication Strength 21 de April de 2024
  • Troubleshooting Error Code ‘0x000005e’ in WHfB: PIN Authentication Woes 11 de February de 2024
  • WHfB: Fixing Windows Hello for Business error ‘LogoncertTemplateReady: NO (StateNoTemplate)’ 29 de December de 2023

Archives

  • March 2026
  • September 2024
  • April 2024
  • February 2024
  • December 2023
  • September 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019

Tags

#aaddownleveldevice #aadhybridjoin #adfs #adfsonsql #azuread #azureauth #azureCA #azuredevice #azurehybridjoin #azuremfa #azuresecurity #capolicy #cloudkerberostrust #conditionalaccess #conditionalaccesspolicy #deviceregistration #gmsaaccount #gopasswordless #hybridaadjoin #mfaserver #msadfs #msazure #msidentity #namedlocation #sslcertificatevalidation #tshootadfs #tshoothybridjoin #tshootwaptrust #waptrust #WHFBcerttrust #whfbdeployment #WHfBhybridsetup #widdatabase adconnect authenticationcontext authenticationstrength az500 azuread azuremfa azurepim azuresecurity cloudsecurity microsoft365 msazure WHfB
©2026 Ulysses Neves | Design: Newspaperly WordPress Theme
Ulysses Neves
Gerenciar Consentimento de Cookies
Para fornecer as melhores experiências, usamos tecnologias como cookies para armazenar e/ou acessar informações do dispositivo. O consentimento para essas tecnologias nos permitirá processar dados como comportamento de navegação ou IDs exclusivos neste site. Não consentir ou retirar o consentimento pode afetar negativamente certos recursos e funções.
Funcional Always active
O armazenamento ou acesso técnico é estritamente necessário para a finalidade legítima de permitir a utilização de um serviço específico explicitamente solicitado pelo assinante ou utilizador, ou com a finalidade exclusiva de efetuar a transmissão de uma comunicação através de uma rede de comunicações eletrónicas.
Preferências
O armazenamento ou acesso técnico é necessário para o propósito legítimo de armazenar preferências que não são solicitadas pelo assinante ou usuário.
Estatísticas
O armazenamento ou acesso técnico que é usado exclusivamente para fins estatísticos. O armazenamento técnico ou acesso que é usado exclusivamente para fins estatísticos anônimos. Sem uma intimação, conformidade voluntária por parte de seu provedor de serviços de Internet ou registros adicionais de terceiros, as informações armazenadas ou recuperadas apenas para esse fim geralmente não podem ser usadas para identificá-lo.
Marketing
O armazenamento ou acesso técnico é necessário para criar perfis de usuário para enviar publicidade ou para rastrear o usuário em um site ou em vários sites para fins de marketing semelhantes.
  • Manage options
  • Manage services
  • Manage {vendor_count} vendors
  • Read more about these purposes
Ver preferências
  • {title}
  • {title}
  • {title}