使用 Microsoft AAD 库通过 SSH 获取用户令牌

问题描述

我正在尝试通过 SSH 从 Windows 机器运行 exe/dll 到 Windows 机器。

当我在本地运行 exe 时,它​​要么提示登录(或者我认为在后台使用 NTLM 获取令牌?我不确定具体情况,是在您将 Prompt.Never 传递给 Acquiretoken 方法时) .

在这不起作用,我想知道是否有办法让它跨 SSH 工作,或者我是否可以以某种方式破解它,将令牌保存在盒子上以便我可以使用该应用程序。

Error: DBuild Setup encountered an exception:
Microsoft.VisualStudio.Services.Content.Common.Authentication.AadAcquiretokenException: Failed to authenticate via AAD due to an Acquiretoken exception. Log of AdalTracing and retries:
2021-02-26T17:12:51.5254850-08:00,3,Authenticating with new AAD token
2021-02-26T17:12:51.5254850-08:00,Using AAD Authority: https://login.windows.net/xxx
2021-02-26T17:12:51.5254850-08:00,ADAL: information,2021-02-27T01:12:51.5254850Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: ADAL PCL.Desktop with assembly version '5.2.6.0',file version '5.2.6.0' and informational version '5.2.6' is running...
2021-02-26T17:12:51.5254850-08:00,2021-02-27T01:12:51.5254850Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: === Token Acquisition started:
        CacheType: Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache (0 items)
        Authentication Target: User,Authority Host: login.windows.net
2021-02-26T17:12:51.7555320-08:00,2021-02-27T01:12:51.7555320Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Logged in user detected
2021-02-26T17:12:51.7555320-08:00,ADAL: Verbose,2021-02-27T01:12:51.7555320Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Loading from cache.
2021-02-26T17:12:51.7555320-08:00,2021-02-27T01:12:51.7555320Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Looking up cache for a token...
2021-02-26T17:12:51.7555320-08:00,2021-02-27T01:12:51.7555320Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: No matching token was found in the cache
2021-02-26T17:12:51.7555320-08:00,2021-02-27T01:12:51.7555320Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Checking MSAL cache for user token cache
2021-02-26T17:12:51.7555320-08:00,2021-02-27T01:12:51.7555320Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: A match was found in the MSAL cache ? False
2021-02-26T17:12:51.7555320-08:00,2021-02-27T01:12:51.7555320Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Either a token was not found or an exception was thrown.
2021-02-26T17:12:51.7555320-08:00,2021-02-27T01:12:51.7555320Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Cannot invoke the broker directly,may require install ...
2021-02-26T17:12:51.7555320-08:00,2021-02-27T01:12:51.7555320Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Sending request to userrealm endpoint.
2021-02-26T17:12:53.2141411-08:00,9,2021-02-27T01:12:53.2141411Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Fetched and parsed MEX
2021-02-26T17:12:53.2141411-08:00,2021-02-27T01:12:53.2141411Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Fetched and parsed MEX
2021-02-26T17:12:54.7411856-08:00,2021-02-27T01:12:54.7411856Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Token of type 'urn:oasis:names:tc:SAML:1.0:assertion' acquired from WS-Trust endpoint
2021-02-26T17:12:54.7411856-08:00,2021-02-27T01:12:54.7411856Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Check and Acquiretoken using broker
2021-02-26T17:12:54.7411856-08:00,2021-02-27T01:12:54.7411856Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: broker invocation is NOT required
2021-02-26T17:12:56.2803162-08:00,10,2021-02-27T01:12:56.2803162Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Response status code does not indicate success: 401 (Unauthorized).
2021-02-26T17:12:56.2803162-08:00,ADAL: Warning,2021-02-27T01:12:56.2803162Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: A service exception occurred
2021-02-26T17:12:56.2803162-08:00,2021-02-27T01:12:56.2803162Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: IsDeviceCode? True
2021-02-26T17:12:57.8402450-08:00,2021-02-27T01:12:57.8402450Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Response status code does not indicate success: 400 (BadRequest).
2021-02-26T17:12:57.8556945-08:00,2021-02-27T01:12:57.8556945Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: A service exception occurred
2021-02-26T17:12:57.8556945-08:00,2021-02-27T01:12:57.8556945Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: IsDeviceCode? False
2021-02-26T17:12:57.8556945-08:00,2021-02-27T01:12:57.8556945Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: TokenResponse ? True
2021-02-26T17:12:57.8556945-08:00,ADAL: Error,2021-02-27T01:12:57.8556945Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Exception type: Microsoft.IdentityModel.Clients.ActiveDirectory.AdalClaimChallengeException,ErrorCode: interaction_required,StatusCode: 0
---> Inner Exception Details
Exception type: Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException,ErrorCode: BadRequest,StatusCode: 400

   at Microsoft.Identity.Core.OAuth2.OAuthClient.<GetResponseAsync>d__18`1.MoveNext()

=== End of inner exception stack trace ===

   at Microsoft.Identity.Core.OAuth2.OAuthClient.<GetResponseAsync>d__18`1.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Core.OAuth2.OAuthClient.<HandleDeviceAuthChallengeAsync>d__21`1.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Core.OAuth2.OAuthClient.<GetResponseAsync>d__18`1.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Core.OAuth2.OAuthClient.<GetResponseAsync>d__17`1.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquiretokenHandlerBase.<SendHttpMessageAsync>d__75.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquiretokenHandlerBase.<SendTokenRequestAsync>d__72.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquiretokenHandlerBase.<CheckAndAcquiretokenUsingbrokerAsync>d__62.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquiretokenHandlerBase.<RunAsync>d__60.MoveNext()

2021-02-26T17:12:57.8556945-08:00,Authentication Failed. ADalexception.ErrorCode=interaction_required AdalServiceException.StatusCode=0 Microsoft.IdentityModel.Clients.ActiveDirectory.AdalClaimChallengeException: AADSTS50076: Due to a configuration change made by your administrator,or because you moved to a new location,you must use multi-factor authentication to access '499b84ac-1321-427f-aa17-267ca6975798'.
Trace ID: 1b1d1d0a-d72f-4069-aa81-2812b2d02e00
Correlation ID: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214
Timestamp: 2021-02-27 01:12:57Z ---> Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: Response status code does not indicate success: 400 (BadRequest).
   at Microsoft.Identity.Core.OAuth2.OAuthClient.<GetResponseAsync>d__18`1.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.Identity.Core.OAuth2.OAuthClient.<GetResponseAsync>d__18`1.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Core.OAuth2.OAuthClient.<HandleDeviceAuthChallengeAsync>d__21`1.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Core.OAuth2.OAuthClient.<GetResponseAsync>d__18`1.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Core.OAuth2.OAuthClient.<GetResponseAsync>d__17`1.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquiretokenHandlerBase.<SendHttpMessageAsync>d__75.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquiretokenHandlerBase.<SendTokenRequestAsync>d__72.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquiretokenHandlerBase.<CheckAndAcquiretokenUsingbrokerAsync>d__62.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquiretokenHandlerBase.<RunAsync>d__60.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquiretokenCommonAsync>d__40.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContextIntegratedAuthExtensions.<AcquiretokenAsync>d__0.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at Microsoft.VisualStudio.Services.Content.Common.Authentication.VsoCredentialHelper.<AcquiretokenWithRetryAsync>d__35.MoveNext()
        ErrorCode: interaction_required
        StatusCode: 0
2021-02-26T17:12:57.8556945-08:00,Ignoring PromptBehavior.Auto because Environment.UserInteractive is false.
2021-02-26T17:12:57.8556945-08:00,AcquiretokenAsync with UserCredential for IntegratedAuth Failed. Calling AcquiretokenAsync with PromptBehavior.Never.
2021-02-26T17:12:57.8556945-08:00,2021-02-27T01:12:57.8556945Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: ADAL PCL.Desktop with assembly version '5.2.6.0',file version '5.2.6.0' and informational version '5.2.6' is running...
2021-02-26T17:12:57.8556945-08:00,2021-02-27T01:12:57.8556945Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: === Token Acquisition started:
        CacheType: Microsoft.IdentityModel.Clients.ActiveDirectory.TokenCache (0 items)
        Authentication Target: User,Authority Host: login.windows.net
2021-02-26T17:12:57.8712936-08:00,2021-02-27T01:12:57.8712936Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Loading from cache.
2021-02-26T17:12:57.8712936-08:00,2021-02-27T01:12:57.8712936Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Looking up cache for a token...
2021-02-26T17:12:57.8712936-08:00,2021-02-27T01:12:57.8712936Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: No matching token was found in the cache
2021-02-26T17:12:57.8712936-08:00,2021-02-27T01:12:57.8712936Z: 27b0c9f2-f7b4-4f63-a298-b37fda6c9214 - AdalLoggerBase.cs: Checking MSAL cache for user token cache
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.Internal.Flows.AcquiretokenHandlerBase.<RunAsync>d__60.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquiretokenCommonAsync>d__42.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquiretokenAsync>d__32.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at Microsoft.VisualStudio.Services.Content.Common.Authentication.VsoCredentialHelper.<AcquiretokenWithRetryAsync>d__35.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Services.Content.Common.Authentication.VsoCredentialHelper.<AcquiretokenWithRetryAsync>d__35.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.Content.Common.Authentication.VsoCredentialHelper.<AcquiretokenInternalAsync>d__31.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.Content.Common.Authentication.VsoCredentialHelper.<GetAADCredentialsAsync>d__17.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.Content.Common.Authentication.VsoCredentialHelper.SyncResultOnThreadPool[T](Func`1 taskFunc)
   at Microsoft.VisualStudio.Services.Content.Common.Authentication.VsoCredentialHelper.GetCachedPATCredentials(Uri serviceUri,PromptBehavior promptBehavior,LocalTokenCacheArgs localTokenCacheArgs)
   at Microsoft.VisualStudio.Services.Content.Common.Authentication.VsoCredentialHelper.<GetCredentialsAsync>d__13.MoveNext()
--- End of stack trace from prevIoUs location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)