Skip to content

Commit 98d450b

Browse files
committed
update
1 parent 9d86f86 commit 98d450b

1 file changed

Lines changed: 11 additions & 157 deletions

File tree

support/windows-server/active-directory/troubleshoot-ad-fs-sso-issue.md

Lines changed: 11 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,20 @@ If the application that you want to access is not Microsoft Online Services, wha
103103
If the application is Microsoft Online Services, what you experience may be controlled by the **PromptLoginBehavior** setting from the trusted realm object. This setting controls whether Microsoft Entra tenants send prompt=login to AD FS. To set the **PromptLoginBehavior** setting, follow these steps:
104104

105105
1. Open Windows PowerShell with the "Run as administrator" option.
106-
2. Get the existing domain federation setting by running the following command:
106+
2. Set the PromptLoginBehavior setting by running the following commands:
107107

108108
```powershell
109-
Get-MgDomainFederationConfiguration -DomainId <DomainName> | FL *
110-
```
111-
112-
3. Set the PromptLoginBehavior setting by running the following command:
113-
114-
```powershell
115-
New-MgDomainFederationConfiguration -DomainId <domain_id> -PromptLoginBehavior <TranslateToFreshPasswordAuth|NativeSupport|Disabled> -FederatedIdpMfaBehavior <acceptIfMfaDoneByFederatedIdp|enforceMfaByFederatedIdp|rejectMfaByFederatedIdp> -PreferredAuthenticationProtocol <WsFed|SAMLP>
109+
Connect-MgGraph -scopes Domain.ReadWrite.All, Directory.ReadWrite.All
110+
$tdo= Get-MgDomainFederationConfiguration -DomainID <domain_id>
111+
Update-MgDomainFederationConfiguration -DomainId <domain_id> -InternalDomainFederationId $tdo.Id -PromptLoginBehavior <translateToFreshPasswordAuthentication|nativeSupport|disabled>
112+
Disconnect-MgGraph
116113
```
117114

118115
The values for the PromptLoginBehavior parameter are:
119116

120-
1. **TranslateToFreshPasswordAuth**: Microsoft Entra ID sends wauth and wfresh to AD FS instead of prompt=login. This leads to an authentication request to use forms-based authentication.
121-
2. **NativeSupport**: The prompt=login parameter is sent as is to AD FS.
122-
3. **Disabled**: Nothing is sent to AD FS.
117+
1. **translateToFreshPasswordAuth**: Microsoft Entra ID sends wauth and wfresh to AD FS instead of prompt=login. This leads to an authentication request to use forms-based authentication.
118+
2. **nativeSupport**: The prompt=login parameter is sent as is to AD FS.
119+
3. **disabled**: Nothing is sent to AD FS.
123120

124121
<a name='non-azure-ad-scenario'></a>
125122

@@ -215,7 +212,7 @@ If the application that you want to access is Microsoft Online Services for Offi
215212
2. If the SupportsMFA setting is FALSE, set it to TRUE by running the following command:
216213

217214
```powershell
218-
New-MgDomainFederationConfiguration -DomainId <DomainName> -FederatedIdpMfaBehavior "acceptIfMfaDoneByFederatedIdp"
215+
Update-MgDomainFederationConfiguration -DomainId <DomainName> -FederatedIdpMfaBehavior "acceptIfMfaDoneByFederatedIdp"
219216
```
220217

221218
### Check if SSO is disabled
@@ -268,7 +265,7 @@ Then, check the external sign-in functionality using IdpInitiatedSignOn. Use the
268265
```
269266

270267
2. From a computer that is outside of your network, visit the following page:
271-
`https://<FederationInstance>/adfs/ls/idpinitiatedsignon.aspx`
268+
`https://<FederationInstance>/adfs/ls/idpinitiatedsignon`
272269

273270
3. Enter the correct credentials of a valid user on the sign-in page.
274271

@@ -885,132 +882,6 @@ DS Mapper Usage : Disabled
885882
Negotiate Client Certificate : Disabled
886883
```
887884

888-
### Run script to automatically detect problems
889-
890-
To automatically detect problems with the proxy trust relationship, run the following script. Based on the problem detected, take the action accordingly.
891-
892-
```powershell
893-
param
894-
(
895-
[switch]$syncproxytrustcerts
896-
)
897-
function checkhttpsyscertbindings()
898-
{
899-
Write-Host; Write-Host("1 – Checking http.sys certificate bindings for potential issues")
900-
$httpsslcertoutput = netsh http show sslcert
901-
$adfsservicefqdn = (Get-AdfsProperties).HostName
902-
$i = 1
903-
$certbindingissuedetected = $false
904-
While($i -lt $httpsslcertoutput.count)
905-
{
906-
$ipport = $false
907-
$hostnameport = $false
908-
if ( ( $httpsslcertoutput[$i] -match "IP:port" ) ) { $ipport = $true }
909-
elseif ( ( $httpsslcertoutput[$i] -match "Hostname:port" ) ) { $hostnameport = $true }
910-
## Check for IP specific certificate bindings
911-
if ( ( $ipport -eq $true ) )
912-
{
913-
$httpsslcertoutput[$i]
914-
$ipbindingparsed = $httpsslcertoutput[$i].split(":")
915-
if ( ( $ipbindingparsed[2].trim() -ne "0.0.0.0" ) -and ( $ipbindingparsed[3].trim() -eq "443") )
916-
{
917-
$warning = "There is an IP specific binding on IP " + $ipbindingparsed[2].trim() + " which may conflict with the AD FS port 443 cert binding." | Write-Warning
918-
$certbindingissuedetected = $true
919-
}
920-
$i = $i + 14
921-
continue
922-
}
923-
## check that CTL Store is set for ADFS service binding
924-
elseif ( $hostnameport -eq $true )
925-
{
926-
$httpsslcertoutput[$i]
927-
$ipbindingparsed = $httpsslcertoutput[$i].split(":")
928-
If ( ( $ipbindingparsed[2].trim() -eq $adfsservicefqdn ) -and ( $ipbindingparsed[3].trim() -eq "443") -and ( $httpsslcertoutput[$i+10].split(":")[1].trim() -ne "AdfsTrustedDevices" ) )
929-
{
930-
Write-Warning "ADFS Service binding does not have CTL Store Name set to AdfsTrustedDevices"
931-
$certbindingissuedetected = $true
932-
}
933-
$i = $i + 14
934-
continue
935-
}
936-
$i++
937-
}
938-
If ( $certbindingissuedetected -eq $false ) { Write-Host "Check Passed: No certificate binding issues detected" }
939-
}
940-
function checkadfstrusteddevicesstore()
941-
{
942-
## check for CA issued (non-self signed) certs in the AdfsTrustedDevices cert store
943-
Write-Host; Write-Host "2 – Checking AdfsTrustedDevices cert store for non-self signed certificates"
944-
$certlist = Get-Childitem cert:\LocalMachine\AdfsTrustedDevices -recurse | Where-Object {$_.Issuer -ne $_.Subject}
945-
If ( $certlist.count -gt 0 )
946-
{
947-
Write-Warning "The following non-self signed certificates are present in the AdfsTrustedDevices store and should be removed"
948-
$certlist | Format-List Subject
949-
}
950-
Else { Write-Host "Check Passed: No non-self signed certs present in AdfsTrustedDevices cert store" }
951-
}
952-
function checkproxytrustcerts
953-
{
954-
Param ([bool]$repair=$false)
955-
Write-Host; Write-Host("3 – Checking AdfsTrustedDevices cert store is in sync with ADFS Proxy Trust config")
956-
$doc = new-object Xml
957-
$doc.Load("$env:windir\ADFS\Microsoft.IdentityServer.Servicehost.exe.config")
958-
$connString = $doc.configuration.'microsoft.identityServer.service'.policystore.connectionString
959-
$command = "Select ServiceSettingsData from [IdentityServerPolicy].[ServiceSettings]"
960-
$cli = new-object System.Data.SqlClient.SqlConnection
961-
$cli.ConnectionString = $connString
962-
$cmd = new-object System.Data.SqlClient.SqlCommand
963-
$cmd.CommandText = $command
964-
$cmd.Connection = $cli
965-
$cli.Open()
966-
$configString = $cmd.ExecuteScalar()
967-
$configXml = new-object XML
968-
$configXml.LoadXml($configString)
969-
$rawCerts = $configXml.ServiceSettingsData.SecurityTokenService.ProxyTrustConfiguration._subjectNameIndex.KeyValueOfstringArrayOfX509Certificate29zVOn6VQ.Value.X509Certificate2
970-
#$ctl = dir cert:\LocalMachine\ADFSTrustedDevices
971-
$store = new-object System.Security.Cryptography.X509Certificates.X509Store("ADFSTrustedDevices","LocalMachine")
972-
$store.open("MaxAllowed")
973-
$atLeastOneMismatch = $false
974-
$badCerts = @()
975-
foreach($rawCert in $rawCerts)
976-
{
977-
$rawCertBytes = [System.Convert]::FromBase64String($rawCert.RawData.'#text')
978-
$cert=New-Object System.Security.Cryptography.X509Certificates.X509Certificate2(,$rawCertBytes)
979-
$now = Get-Date
980-
if ( ($cert.NotBefore -lt $now) -and ($cert.NotAfter -gt $now))
981-
{
982-
$certThumbprint = $cert.Thumbprint
983-
$certSubject = $cert.Subject
984-
$ctlMatch = dir cert:\localmachine\ADFSTrustedDevices\$certThumbprint -ErrorAction SilentlyContinue
985-
if ($ctlMatch -eq $null)
986-
{
987-
$atLeastOneMismatch = $true
988-
Write-Warning "This cert is NOT in the CTL: $certThumbprint – $certSubject"
989-
if ($repair -eq $true)
990-
{
991-
write-Warning "Attempting to repair"
992-
$store.Add($cert)
993-
Write-Warning "Repair successful"
994-
}
995-
else
996-
{
997-
Write-Warning ("Please install KB.2964735 or re-run script with -syncproxytrustcerts switch to add missing Proxy Trust certs to AdfsTrustedDevices cert store")
998-
}
999-
}
1000-
}
1001-
}
1002-
$store.Close()
1003-
if ($atLeastOneMismatch -eq $false)
1004-
{
1005-
Write-Host("Check Passed: No mismatched certs found. CTL is in sync with DB content")
1006-
}
1007-
}
1008-
checkhttpsyscertbindings
1009-
checkadfstrusteddevicesstore
1010-
checkproxytrustcerts($syncproxytrustcerts)
1011-
Write-Host; Write-Host("All checks completed.")
1012-
```
1013-
1014885
### Problem 1: There is an IP specific binding
1015886

1016887
The binding may conflict with the AD FS certificate binding on port 443.
@@ -1051,23 +922,6 @@ If a CA issued certificate is in a certificate store where only self-signed cert
1051922

1052923
Therefore, delete any CA issued certificate from the AdfsTrustedDevices certificate store.
1053924

1054-
### Problem 4: Install KB2964735 or re-run the script with -syncproxytrustcerts
1055-
1056-
When a proxy trust relationship is established with an AD FS server, the client certificate is written to the AD FS configuration database and added to the AdfsTrustedDevices certificate store on the AD FS server. For an AD FS farm deployment, the client certificate is expected to be synced to the other AD FS servers. If the sync doesn't happen for some reason, a proxy trust relationship will only work against the AD FS server the trust was established with, but not against the other AD FS servers.
1057-
1058-
To solve this problem, use one of the following methods.
1059-
1060-
#### Method 1
1061-
1062-
Install the update documented in [KB 2964735](https://support.microsoft.com/topic/700e0502-c19a-54e4-9c5f-65c2844d9a9f) on all AD FS servers. After the update is installed, a sync of the client certificate is expected to happen automatically.
1063-
1064-
#### Method 2
1065-
1066-
Run the script with the – syncproxytrustcerts switch to manually sync the client certificates from the AD FS configuration database to the AdfsTrustedDevices certificate store. The script should be run on all the AD FS servers in the farm.
1067-
1068-
> [!NOTE]
1069-
> This is not a permanent solution because the client certificates will be renewed on a regular basis.
1070-
1071925
### Problem 5: All checks are passed. But the problem persists
1072926

1073927
Check if there is a time or time zone mismatch. If time matches but the time zone doesn't, proxy trust relationship will also fail to be established.
@@ -1223,6 +1077,6 @@ If all the claims are present, see if the values of the claims from the Dump Tok
12231077
For more informaiton, see the following articles:
12241078

12251079
- [Get-MgDomainFederationConfiguration](/powershell/module/microsoft.graph.identity.directorymanagement/get-mgdomainfederationconfiguration)
1226-
- [New-MgDomainFederationConfiguration](/powershell/module/microsoft.graph.identity.directorymanagement/new-mgdomainfederationconfiguration)
1080+
- [Update-MgDomainFederationConfiguration](/powershell/module/microsoft.graph.identity.directorymanagement/update-mgdomainfederationconfiguration)
12271081
- [Connect-MgGraph](/powershell/microsoftgraph/authentication-commands#use-connect-mggraph)
12281082
- [Get-MgUser](/powershell/module/microsoft.graph.users/get-mguser)

0 commit comments

Comments
 (0)