question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WindowsAuthenticationAzureServiceTokenProvider.GetTokenAsync thows when using Microsoft.IdentityModel.Clients.ActiveDirectory 4+

See original GitHub issue

Original Issue: https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/1283

All our machines are domain joined and corpnet user/group identities are replicated to Azure AD under onmicrosoft.com directory.

We’ve been using this code:

var azureServiceTokenProvider = new AzureServiceTokenProvider();
var authenticationCallback = new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback);
var keyVaultClient = new KeyVaultClient(authenticationCallback);
keyVaultClient.GetSecretsAsync(<url>).Dump(); //this throws

to access KeyVault no problem with these packages:

  <package id="Microsoft.Azure.KeyVault" version="3.0.0" targetFramework="net461" />
  <package id="Microsoft.Azure.KeyVault.WebKey" version="3.0.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Services.AppAuthentication" version="1.0.3" targetFramework="net461" />
  <package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.19.8" targetFramework="net461" />

However we recently had to update to “Microsoft.IdentityModel.Clients.ActiveDirectory” version=“4.0.0-preview” and the authentication workflow we have been using stopped working (ActiveDirectory 4.1-preview also fails). se we have to reference Microsoft.IdentityModel.Clients.ActiveDirectory version 4+ in most of our solutions. However Microsoft.Azure.Services.AppAuthetnication references Microsoft.IdentityModel.Clients.ActiveDirectory 3.14.2 which still had the ActiveDirectory.Platforms.dll.

This is the failure:

Parameters: Connectionstring: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47. Exception Message: Tried to get token using Active Directory Integrated Authentication. Access token could not be acquired. Could not load file or assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.14.2.11, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Even with a binding redirect this fails because the Platforms namespace is now merged into ActiveDirectory.

The simple fix would be to update the Microsoft.IdentityModel.Clients.ActiveDirectory in Azure.Services.AppAuthentication.

PR to fix this issue: https://github.com/Azure/azure-sdk-for-net/pull/5007

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nonik0commented, Jul 24, 2019

@Ofekw @Zenuka Wanted to let you know that we just released the newest version 1.3.0 of AppAuth, where the ADAL dependency has been updated to 4.3.

2reactions
Zenukacommented, Apr 10, 2019

Whats the status on this? Would like to update the ActiveDirectory package to the latest version instead of keeping it at 3.19.8.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrate confidential client applications to MSAL.NET
In this how-to guide you'll migrate a confidential client application from Azure Active Directory Authentication Library for .NET (ADAL.
Read more >
Differences between ADAL.NET and MSAL.NET apps
Migrating your applications from using ADAL to using MSAL comes with security and resiliency benefits. This article outlines differences ...
Read more >
Re: Get an authentication access token
I have registered an app with Azure AD and now have an Application ID (Register an Azure AD application to use with Power...
Read more >
Unable to create the syncronization service account for ...
I am try reinstall and configure Azure AD Connect on Windows Server 2019 Activey Directory, I used 'Express Mode', inserted a user 'Global...
Read more >
Lesson Learned #49: Does Azure SQL Database support ...
First published on MSDN on May 10, 2018 The answer is Yes! ... Database support Azure Active Directory connections using Service Principals?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found