/// <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)));
     }
 });
예제 #2
0
 /// <summary>
 /// Get a token.
 /// </summary>
 public abstract Task <SqlAuthenticationToken> AcquireTokenAsync(SqlAuthenticationParameters parameters);