-
Notifications
You must be signed in to change notification settings - Fork 214
AcquireTokenSilentAsync using Integrated authentication on Windows (Kerberos)
If your desktop or mobile application runs on Windows, and on a machine connected to a Windows domain - AD or AAD joined - it is possible to use the Integrated Windows Authentication (IWA) to acquire a token silently. No UI is required when using the application.
- IWA is for apps written for .NET Framework and UWP platforms
- IWA does NOT bypass MFA (multi factor authentication). If MFA is configured, IWA might fail if an MFA challenge is required, because MFA requires user interaction.
This method relies on an a protocol exposed by Active Directory (AD). If a user was created in Azure Active Directory without AD backing ("managed" user), this method will fail. Users created in AD and backed by AAD ("federated" users) can benefit from this non-interactive method of authentication.
The code is really simple. You need to instantiate a UserCredential
, and use the corresponding override of AcquireTokenAsync
:
result = await context.AcquireTokenAsync(resource, clientId, new UserCredential());
Note that, sometimes, policies set by the administrators on machines do not enable the logged-in user to be looked-up. In that case you should use the constructor of ``UserCredential` passing the upn of the user as a parameter, instead of the default, parameterless constructor. This is also the case of users that are "Work And School" joined.
result = await context.AcquireTokenAsync(resource, clientId,
new UserCredential("[email protected]"));
Note that this method is not available as part of the
AuthenticationContext
class, but as anAcquireTokenAsync
extension method of theAuthenticationContextIntegratedAuthExtensions
class. This extension method takes as a parameter, in addition to the resource and clientId of the public client application, an instance ofUserCredential
.
Sample | Description |
---|---|
active-directory-dotnet-native-headless | A windows desktop program that demonstrates non-interactive authentication to Azure AD using a username & password and optionaly windows integrated authentication. |
- Home
- Why use ADAL.NET?
- Register your app with AAD
- AuthenticationContext
- Acquiring Tokens
- Calling a protected API
- Acquiring a token interactively
- Acquiring tokens silently
- Using Device Code Flow
- Using Embedded Webview and System Browser in ADAL.NET and MSAL.NET
- With no user
- In the name of a user
- on behalf of (Service to service calls)
- by authorization code (Web Apps)
- Use async controller actions
- Exception types
- using Broker on iOS and Android
- Logging
- Token Cache serialization
- User management
- Using ADAL with a proxy
- Authentication context in multi-tenant scenarios
- Troubleshooting MFA in a WebApp or Web API
- Provide your own HttpClient
- iOS Keychain Access