Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-DbaDbMasterKey Does Not Use $SQLCredential if passed #5381

Closed
2 of 3 tasks
maddhatter opened this issue Apr 17, 2019 · 0 comments · Fixed by #5382
Closed
2 of 3 tasks

Get-DbaDbMasterKey Does Not Use $SQLCredential if passed #5381

maddhatter opened this issue Apr 17, 2019 · 0 comments · Fixed by #5382

Comments

@maddhatter
Copy link
Contributor

Before submitting a bug report:

Collect output of following command and paste below:

& {"### PowerShell version:`n$($PSVersionTable | Out-String)"; "`n### dbatools Module version:`n$(gmo dbatools -List | select name, path, version | fl -force | Out-String)"}
  • Running latest release of dbatools
  • Verified errors are not related to permissions
  • Is this bug with Copy-DbaDatabase? You can replicate it using Backup-DbaDatabase ... | Restore-DbaDatabase ...

NOTE: Copy-DbaDatabase will not work in every environment and every situation. Instead, we try to ensure Backup & Restore work in your environment.

Environmental data

### PowerShell version:

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      5.1.17134.590                                                                           
PSEdition                      Desktop                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
BuildVersion                   10.0.17134.590                                                                          
CLRVersion                     4.0.30319.42000                                                                         
WSManStackVersion              3.0                                                                                     
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1                                                                                 




### dbatools Module version:


Name    : dbatools
Path    : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.807\dbatools.psd1
Version : 0.9.807

Name    : dbatools
Path    : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.754\dbatools.psd1
Version : 0.9.754

Name    : dbatools
Path    : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.753\dbatools.psd1
Version : 0.9.753

Name    : dbatools
Path    : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.752\dbatools.psd1
Version : 0.9.752

Name    : dbatools
Path    : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.718\dbatools.psd1
Version : 0.9.718

Name    : dbatools
Path    : C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.519\dbatools.psd1
Version : 0.9.519

SQL Server:

Microsoft SQL Server 2017 (RTM-CU13) (KB4466404) - 14.0.3048.4 (X64)   Nov 30 2018 12:57:58   Copyright (C) 2017 Microsoft Corporation  Developer Edition (64-bit) on Windows Server 2016 Datacenter 10.0 <X64> (Build 14393: ) (Hypervisor) 

Errors Received

writeErrorStream      : True
PSMessageDetails      : 
Exception             : System.Exception: Login failed. The login is from an untrusted domain and cannot be used with Integrated 
                        authentication. ---> System.Data.SqlClient.SqlException: Login failed. The login is from an untrusted domain 
                        and cannot be used with Integrated authentication.
                           at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, 
                        SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, 
                        SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, 
                        SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean 
                        applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
                           at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, 
                        DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection 
                        owningConnection, DbConnectionOptions userOptions)
                           at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, 
                        DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions 
                        userOptions)
                           at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions 
                        userOptions, DbConnectionInternal oldConnection)
                           at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, 
                        DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
                           at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 
                        waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions 
                        userOptions, DbConnectionInternal& connection)
                           at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, 
                        TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
                           at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, 
                        TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, 
                        DbConnectionInternal& connection)
                           at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, 
                        DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
                           at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
                           at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
                           at System.Data.SqlClient.SqlConnection.Open()
                           at CallSite.Target(Closure , CallSite , Object )
                           --- End of inner exception stack trace ---
TargetObject          : AZ-EA-VM-SQL-01
CategoryInfo          : ConnectionError: (AZ-EA-VM-SQL-01:PSObject) [Write-Error], Exception
FullyQualifiedErrorId : dbatools_Get-DbaDatabase,Stop-Function
ErrorDetails          : Login failed. The login is from an untrusted domain and cannot be used with Integrated authentication.
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Stop-Function, C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.754\allcommands.ps1: line 104625
                        at Get-DbaDatabase<Process>, C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.754\allcommands.ps1: 
                        line 30007
                        at Get-DbaDbMasterKey<Process>, C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.754\allcommands.ps1: 
                        line 33766
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}

Steps to Reproduce

/*
    Any T-SQL commands involved or used to produce test objects/data.
*/
<#
    Provide exact (or sanitized) code to reproduce the error
#>
$SqlCredential = Get-Credential
Get-DbaDbMasterKey -SqlInstance $Instance -SqlCredential $SqlCredential -Database master

Expected Behavior

Connects to SQL Instance using the provided credentials.

Actual Behavior

Attempts to use integrated security.

Notes

I'll send a PR to fix this shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant