microsoft / microsoft/sqlmanagementobjects
ConnectionFailureException when user running the command does not match the ConnectAsUserName
オープン
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 143
- フォーク
- 28
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
$Credential = Get-Credential -Message "Enter your login name"
Import-Module -Name SqlServer
$ServerInstance = "SERVERNAME"
$Server = New-Object Microsoft.SqlServer.Management.Smo.Server $ServerInstance
$Server.ConnectionContext.LoginSecure = $true
$Server.ConnectionContext.ConnectAsUser = $true
$Server.ConnectionContext.ConnectAsUserName = $Credential.GetNetworkCredential().UserName
$Server.ConnectionContext.ConnectAsUserPassword = $Credential.GetNetworkCredential().Password
try {$Server.ConnectionContext.Connect()} catch {$_.Exception | Format-List -Force}
Throws the following error, when the user running the command does not match the ConnectAsUserName
ErrorRecord : Exception calling "Connect" with "0" argument(s): "Failed to connect to server SERVERNAME."
WasThrownFromThrowStatement : False
TargetSite : Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, System.Exception)
Message : Exception calling "Connect" with "0" argument(s): "Failed to connect to server SERVERNAME."
Data : {[System.Management.Automation.Interpreter.InterpretedFrameInfo, System.Management.Automation.Interpreter.InterpretedFrameInfo[]]}
InnerException : Microsoft.SqlServer.Management.Common.ConnectionFailureException: Failed to connect to server SERVERNAME.
---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Diagnostics.StackTrace, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The
system cannot find the file specified.
File name: 'System.Diagnostics.StackTrace, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Data.SqlClient.SqlConfigurableRetryLogicManager.get_ConnectionProvider()
at Microsoft.Data.SqlClient.SqlConnection.get_RetryLogicProvider()
at Microsoft.Data.SqlClient.SqlConnection.get_IsProviderRetriable()
at Microsoft.Data.SqlClient.SqlConnection.Open(SqlConnectionOverrides overrides)
at Microsoft.Data.SqlClient.SqlConnection.Open()
at Microsoft.SqlServer.Management.Common.ConnectionManager.InternalConnectImpl()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Security.Principal.WindowsIdentity.RunImpersonatedInternal(SafeAccessTokenHandle token, Action action)
at Microsoft.SqlServer.Management.Common.ConnectionManager.InternalConnect()
at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()
--- End of inner exception stack trace ---
at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect()
at CallSite.Target(Closure, CallSite, Object)
HelpLink :
Source : System.Management.Automation
HResult : -2146233087
StackTrace : at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Running Windows 11,
Name Version Source ProviderName
---- ------- ------ ------------
SqlServer 22.3.0 https://www.powershellgallery.c… PowerShellGet
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供されている PowerShell の再現手順と、スタックトレースにある ConnectionManager.InternalConnect および SqlConnection.Open のパスから始めます。ConnectAsUser が呼び出し元と異なる場合に SqlServer 22.3.0 の依存関係セットがどのように読み込まれるか、特に不足している System.Diagnostics.StackTrace アセンブリを確認します。同じスクリプトで正常に接続できるか、基盤となる依存関係の問題を明確に特定できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp, powershell, sql
- 領域
- databases
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100