/// <summary> /// Get token. /// </summary> public override Task <SqlAuthenticationToken> AcquireTokenAsync(SqlAuthenticationParameters parameters) => Task.Run(() => { long expiresOnFileTime = 0; byte[] token; if (parameters.AuthenticationMethod == SqlAuthenticationMethod.ActiveDirectoryIntegrated) { token = ADALNativeWrapper.ADALGetAccessTokenForWindowsIntegrated(parameters.Authority, parameters.Resource, parameters.ConnectionId, ActiveDirectoryAuthentication.AdoClientId, ref expiresOnFileTime); return(new SqlAuthenticationToken(token, DateTimeOffset.FromFileTime(expiresOnFileTime))); } else { token = ADALNativeWrapper.ADALGetAccessToken(parameters.UserId, parameters.Password, parameters.Authority, parameters.Resource, parameters.ConnectionId, ActiveDirectoryAuthentication.AdoClientId, ref expiresOnFileTime); return(new SqlAuthenticationToken(token, DateTimeOffset.FromFileTime(expiresOnFileTime))); } });
/// <summary> /// Get a token. /// </summary> public abstract Task <SqlAuthenticationToken> AcquireTokenAsync(SqlAuthenticationParameters parameters);