Microsoft wil graag dat we Azure AD OpenID gaan gebruiken voor authenticatie. Vanaf Business Central 20 is dat ook mogelijk. Je kunt ook de oude manier gebruiken door in de webclient de regel "UseLegacyACSAuthentication": "true" toe te voegen, maar meer toekomstgericht is om het als volgt te doen. Ik ga ervan uit dat er al een Azure tenant beschikbaar is. 

  • log in op https://portal.azure.com ga naar Azure Active Directory, en kies dan voor App Registrations.
  • Klik op New Registration. Geef deze een naam, en kies voor "Accounts in this organizational directory only (single tenant)"
  • Kies bij Redirect URI (Optional) voor web, en voer daar het adres van de webclient in, gevolgd door SignIn - dus bijvoorbeeld https://bc.companyname.nl/BC210/SignIn
  • Klik op register
  • Klik op het volgende scherm bij Redirect URIs op 1 Web. Klik bij Web op Add URI, en voeg de URI https://bc.companyname.nl/BC210/OAuthlanding.htm toe. Verander bc.companyname.nl naar je eigen URL.
  • Kies onder implicit grant and Hybrid flows bij Select the tokens you would like to be issued by the authorization endpoint: voor ID Tokens (used for implicit and hybrid flows)
  • Klik vervolgens op Save.
  • Ga terug naar Overview en klik op Add an Application ID URl, of ga naar Expose an API. Klik naast Application ID URI op Set. Er wordt nu een Application ID URI getoond. Verander hier niets aan, en klik op Save.
  • Ga terug naar de overview. Je hebt de application (client) ID en de Directory (Tenant) ID nodig. Daarnaast heb je ook het domein nodig van de Azure Tenant, zoals companyname.onmicrosoft.com

 Je kunt met onderstaand script dan de service aanpassen. 

Vul het juiste Directory (Tenant) ID in bij de variabele $TenantID

Bij $ApplicationID voer je de Application (Client) ID in, 

Bij $AppID voer je de waarde van het domain in.

De $ServerInstance verander je in de juiste naam. Deze kun je leeg laten: dan krijg je een lijstje met services en kun je er een kiezen.  $Authenticationtype is AccessControlService, de $WebURLBase is het basisadres van de webclient (zoals bc.companyname.nl uit de redirect URIs). Als je het certificatethumbprint leeg laat, wordt de thumbprint die op poort 443 wordt gebruikt ingelezen.

Daarna kun je het script starten (elevated), en wordt de service aangepast zodat er gebruik kan worden gemaakt van EntraID OpenID

Ook wordt SSL aangezet op SOAP en ODATA en worden deze geactiveerd.  

$ServerInstance = "BC210"
$AuthenticationType="AccessControlService"

$TenantID = "12345678-90ab-cdef-0123-456789abcd"
$ApplicationID = "abcdef-0123-4567-89ab-cdef012345"
$AppID = "https://companyname.onmicrosoft.com/$ApplicationID"
$WebURLBase="bc.companyname.nl"
$CertificateThumbPrint="0123456789abcdef0123456789abcdef01234567"

$SOAPPort=7047
$OdataPort=7048

#--- no need to change anything below this line.------------

# Self-elevate the script if required
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')) {
    if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
        $CommandLine = "-File `"" + $MyInvocation.MyCommand.Path + "`" " + $MyInvocation.UnboundArguments
        Start-Process -FilePath PowerShell.exe -Verb Runas -ArgumentList $CommandLine
        Exit
    }
}

if ($ServerInstance -eq "") {
# Get Servicelist
$Services = Get-Service | where-object -Property Name -like "MicrosoftDynamicsNAVServer$*" | Where-object -Property Name -Notlike "*VSS*" | Where-object -Property StartType -ne "Disabled"
if ($services.count -eq 0) {
    write-host "No services found"
    read-host "Press enter to quit script"
    return
}
# Select which service to update
$menu = @{}
for ($i = 1; $i -le $services.count; $i++) {
    Write-Host "$i. $($services[$i-1].name.split('`$')[1])  ($($services[$i-1].status))"
    $menu.Add($i, ($services[$i - 1].name))
}

do {
    [int]$answer = Read-Host 'Select the service to update (choose 0 to quit)'
}
until ($answer -le $services.count -and $answer -gt -1)

if ($answer -eq 0) {
    write-host "No service selected"
    read-host "Press enter to quit script"
    return
}

$selection = $menu.Item($answer)
$Serverinstance = (Get-Service $selection).Name.split('$')[1]
}
write-host $ServerInstance

$OdataBaseURL="https://${WebUrlBase}:$OdataPort/$ServerInstance/"
$SoapBaseURL="https://${WebUrlBase}:$SOAPPort/$ServerInstance/"
$WSFederationEndPoint="https://login.microsoftonline.com/$TenantID/wsfed?wa=wsignin1.0%26wtrealm=$appid%26wreply=https://$WebURLBase/$ServerInstance/SignIn"
$ServiceLocation = (get-itemproperty -path HKLM:\SYSTEM\CurrentControlSet\Services\MicrosoftDynamicsNAVServer`$$serverinstance).ImagePath
if ($Servicelocation.indexof('"') -ge 0) {
  $ServiceLocation = $ServiceLocation.split('"')[1]
}
$ServiceLocation = Split-path -path $ServiceLocation
if ([string]::IsNullOrWhitespace($ServiceLocation)) {
  write-host "Could not locate $ServerInstance"
  $ServerInstance = ""
  read-host "Press enter to quit script"
  return
}

if ([string]::IsNullOrEmpty($CertificateThumbprint)) {
    Import-Module WebAdministration

    $CertificateThumbprint = (Get-ChildItem IIS:SSLBindings | where-object port -eq $IISPort).thumbprint
    Write-Host "Thumbprint found in IIS on port ${IISPort}:${CertificateThumbPrint}"
    if ([string]::IsNullOrWhitespace($CertificateThumbprint)) {
            "No certificate found on port $IISPort"
    return
    }
}

get-childitem "$servicelocation\Microsoft.Dynamics.Nav.Management.dll" -recurse | Import-Module -verbose
get-childitem "$servicelocation\Microsoft.Dynamics.Nav.apps.Management.dll" -recurse | Import-Module -verbose
Get-Childitem "$ServiceLocation\NAVWebClientManagement.psm1" -recurse | Import-Module

$Version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$ServiceLocation\Microsoft.Dynamics.Nav.Server.exe").FileVersion
$CurrentVersion = ($Version).split("\.")[0] + "0"

Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName ValidAudiences -KeyValue "$ApplicationID; https://api.businesscentral.dynamics.com"
if ($CurrentVersion -lt "220") {
  Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName ClientServicesFederationMetadataLocation -KeyValue "https://login.microsoftonline.com/$TenantID/FederationMetadata/2007-06/FederationMetadata.xml" # BC20, BC21
  } else {
  Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName ADOpenIDMetadataLocation -KeyValue "https://login.microsoftonline.com/$TenantID/.well-known/openid-configuration" # BC22
  }
Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName AppIdUri -KeyValue $AppID
Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName ClientServicesCredentialType -KeyValue $AuthenticationType
Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName WSFederationLoginEndpoint -keyvalue $WSFederationEndpoint
Set-NavServerConfiguration -ServerInstance $ServerInstance -KeyName AzureActiveDirectoryClientId -KeyValue "00000000-0000-0000-0000-000000000000"
Set-NavServerConfiguration -ServerInstance $ServerInstance -KeyName ServicesCertificateThumbprint -KeyValue $CertificateThumbPrint
Set-NavServerConfiguration -ServerInstance $ServerInstance -KeyName PublicWebBaseURL -KeyValue "https://$WebURLBase/$ServerInstance/"

Set-NavServerConfiguration -ServerInstance $ServerInstance -keyname SOAPServicesEnabled -KeyValue False
Set-NavServerConfiguration -ServerInstance $ServerInstance -keyname SOAPServicesPort -keyvalue $SOAPPort
Set-NavServerConfiguration -ServerInstance $ServerInstance -keyname SOAPServicesSSLEnabled -KeyValue True
Set-NavServerConfiguration -ServerInstance $ServerInstance -keyname SOAPServicesEnabled -KeyValue True
Set-NavServerConfiguration -ServerInstance $ServerInstance -KeyName PublicSOAPBaseURL -KeyValue $SoapBaseURL

Set-NavServerConfiguration -ServerInstance $ServerInstance -keyname ODataServicesEnabled -KeyValue False
Set-NavServerConfiguration -ServerInstance $ServerInstance -keyname ODataServicesPort -keyvalue $OdataPort
Set-NavServerConfiguration -ServerInstance $ServerInstance -keyname ODataServicesSSLEnabled -KeyValue True
Set-NavServerConfiguration -ServerInstance $ServerInstance -keyname ODataServicesEnabled -KeyValue True
Set-NavServerConfiguration -ServerInstance $ServerInstance -keyName PublicOdataBaseURL -KeyValue $OdataBaseURL

Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName DeveloperServicesEnabled -KeyValue False
Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName DeveloperServicesPort -KeyValue 7149
Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName DeveloperServicesSSLEnabled -KeyValue True
Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName DeveloperServicesEnabled -KeyValue True

Set-NAVServerConfiguration -ServerInstance $ServerInstance -KeyName ApiServicesEnabled -KeyValue true

$ClientServicesPort=Get-NavServerConfiguration -ServerInstance $ServerInstance -keyName ClientServicesPort

$NAVWebServerInstance = (Get-NAVWebServerInstance | Where-Object ServerInstance -eq $ServerInstance).WebServerInstance
Set-NAVWebServerInstanceConfiguration -WebServerInstance $NAVWebServerInstance -KeyName ClientServicesCredentialType -KeyValue $AuthenticationType
Set-NAVWebServerInstanceConfiguration -WebServerInstance $NAVWebServerInstance -KeyName AadApplicationId -KeyValue $ApplicationID
Set-NAVWebServerInstanceConfiguration -WebServerInstance $NAVWebServerInstance -KeyName AadAuthorityUri -KeyValue "https://login.microsoftonline.com/$TenantID"
Set-NAVWebServerInstanceConfiguration -WebServerInstance $NAVWebServerInstance -KeyName ClientServicesPort -KeyValue $ClientServicesPort

Restart-NAVServerInstance -ServerInstance $ServerInstance
 

bron: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/authenticating-users-with-azure-ad-openid-connect?tabs=singletenant%2Cadmintool