Posted in : ADFS, NetScaler By Simon Gottschlag Translate with Google ⟶

3 years ago

How do you configure Citrix NetScaler OpenID Connect Service Provider with Microsoft ADFS as OpenID Connect Identity Provider? I’ve tried making it easy to understand and how you do it using CLI (NetScaler CLI and powershell).
Read this post for doing this with SAML.

Before we begin, let us look at what we need to establish the federation:

  • NetScaler (with at least Enterprise license)
  • Active Directory domain and ADFS (read this post if you want to load balance and use NetScaler as ADFS Proxy)
  • Website (lb vserver) we want to protect with AAA (will be referred to as the service provider)
  • AAA vserver to bind OpenID Connect (OAuth) Service Provider policy

In my case, the following FQDNs are used:

  • LB vserver: / LB-WEBAPP-TEST
  • AAA vserver: / AAA-SP-DOMAIN.COM (note: it will actually not be access by the web browser)
  • ADFS:

Compared to SAML, we need to create the IDP policy on ADFS before configuring NetScaler:

$SPName = "Webapp-test"
$SPIdentifier = ""
$SPRedirectUri = ""
$SPClientID = "<random uuid>"
$SPScopeName = "openid"
$SPIssuanceTransform = '@RuleTemplate = "LdapClaims"
@RuleName = "AD Claims"
c:[Type ==
Issuer == "AD AUTHORITY"]
 => issue(store = "Active Directory", types =
(""), query =
";userPrincipalName;{0}", param = c.Value);'
New-AdfsApplicationGroup -ApplicationGroupIdentifier $SPName -Name $SPName
Add-AdfsWebApiApplication -Name "$($SPName) - Web API" -Identifier $SPIdentifier -AccessControlPolicyName "Permit everyone" -ApplicationGroupIdentifier $SPName -IssuanceTransformRules $SPIssuanceTransform
Grant-AdfsApplicationPermission -AllowAllRegisteredClients -ServerRoleIdentifier $SPIdentifier -ScopeNames $SPScopeName
$ADFSApp = Add-AdfsServerApplication -Name "$($SPName) - Native application" -ApplicationGroupIdentifier $SPName -RedirectUri $SPRedirectUri -Identifier $SPClientID -GenerateClientSecret
Write-Output "`r`nPlease write down and save the following Client Secret: $($ADFSApp.ClientSecret)`r`n"

Note: Generate the random UUID for the client secret using any way you want, It doesn’t have to be a UUID but is common. This site can be used.
Now we need to create the OIDC Service Provider action and profile, as well as bind it to the AAA vserver:

add authentication OAuthAction OIDC-SP-WEBAPP-TEST.DOMAIN.COM -authorizationEndpoint "<Client ID>" -tokenEndpoint "" -clientID <Client ID> -clientSecret <Client Secret> -CertEndpoint "" -audience <Client ID> -userNameField upn -issuer ""
bind authentication vserver AAA-SP-DOMAIN.COM -policy OIDC-SP-POL-WEBAPP-TEST.DOMAIN.COM -priority 100 -gotoPriorityExpression NEXT

(Note: As I stated before, this policy is bound to the AAA vserver but the expression is matching the hostname of the LB vserver – since the web browser actually never is redirected to the AAA vserver in this scenario)
As a last step, create (if it isn’t already) an authentication profile and bind it to the LB vserver:

add authentication authnProfile -authnVsName AAA-SP-DOMAIN.COM -AuthenticationHost
add lb vserver LB-WEBAPP-TEST HTTP 0 -persistenceType NONE -cltTimeout 180 -Authentication ON -authnProfile

Remember that the NetScaler does query the IDP for the keys periodically as well as sending the code to the token endpoint to receive the access_token, refresh_token and id_token (which it uses to extract the UPN). Just the same as with SAML, the browser will never hit the AAA vServer. See below for a screenshot of a capture where the NetScaler (SNIP) sends a request to ADFS (behind the scenes):

For troubleshooting, remember to enable Enhanced Authentication Feedback and to look at both ns.log and the ADFS servers eventviewer for information:

set aaa parameter -enableEnhancedAuthFeedback YES

Tags : AAA, ADFS, NetScaler, OAuth, OIDC, OpenID Connect

Personlig rådgivning

Vi erbjuder personlig rådgivning med författaren för 1400 SEK per timme. Anmäl ditt intresse i här så återkommer vi så snart vi kan.

Add comment

Your comment will be revised by the site if needed.