-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
New-DbaConnectionString Multiple Errors/Issues #9411
Comments
seems a mismatch here
first, can a switch be validated as a set ? don't think so, but don't take me from granted. If it "remains" a switch, when newer versions are targeted , our "encrypt yes/no" should be declined into the "Mandatory/Optional" new costraint. Supporting "Strict" should go in yet another parameter. @andreasjordan : do you concur ? |
Give me around 24 hours and I will have a look at it. |
I got to spend a little bit more time looking into this and found that setting the following to false results in no error being thrown.
I still couldn't figure out why setting some parameters, like
|
I changed the parameter in this pull request: #9143 We had a discussion about the best way, and maybe my proposed way was not the best option. See also my comments here: #9113 The problem is that:
I still think we should use a bool in Connect-DbaInstance to have a simple yes/no for encryption that is the same for all supported versions of sql server (as we only know the version after we connected to it). And I think we don't have a problem with the current implementation in Connect-DbaInstance. So we should change New-DbaConnectionString. The current parameter EncryptConnection should be the same as in Connect-DbaInstance, so we have to remove the validate set. If you think this is the right direction, I can code that and open a pull request. |
in my mind, at veeeery high level, the point stems from the fact that a switch cannot accomodate the newer library options. As for adapting to the "newer standard" in other dbatools places, assumed the new sql server library allows for more values now, it seems that our "bool" preference is falling short (on top of, if I understood the referenced comments, being able to use both "new" and "old" library, or different libraries alltogether). |
Keep in mind that the parameter has a configuration item connected to it. This was a string with "Mandatory" as the default. I think that caused problems so I changed that to bool here: If that was not the best way, we can revert that. But what value to use as a default for new installations? |
IMHO we need to reconvene on that point (with the usual suspects, maybe in slack, too). |
This is basically the code we run inside of Connect-DbaInstance:
We use What if we add this parameter also to Connect-DbaInstance and New-DbaConnectionString? In Connect-DbaInstance we just pass the two bools to the properties. In New-DbaConnectionString we build a ruleset to convert the two bools into a string ('Mandatory', 'Optional', 'Strict', 'True', 'False'). I think if StrictEncryption is $false, then we just convert the bool value from EncryptConnection into the string 'True' or 'False'. If StrictEncryption is $true, then it should be 'Strict' I think, but not sure. In case we need a real quick fix with minimal change, I can just change |
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
Main Error
Even though it's throwing an error it's still creating the connection string.
Any attempt to set values for TrustServerCertificate and EncryptConnection then force the use of a credential.
Adding a value for SQLCredential causes another issue requiring ApplicationIntent to be required
Once all that is supplied we are back to the first error, but now the connection string exposes the username and password of the credential, since Integrated Security is no longer a valid option
Steps to Reproduce
New-DbaConnectionString -SqlInstance
Please confirm that you are running the most recent version of dbatools
2.1.18
Other details or mentions
No response
What PowerShell host was used when producing this error
PowerShell Core (pwsh.exe), Windows PowerShell (powershell.exe), VS Code (terminal)
PowerShell Host Version
Name Value
PSVersion 7.4.3
PSEdition Core
GitCommitId 7.4.3
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
SQL Server Edition and Build number
Microsoft SQL Server 2022 (RTM-CU13) (KB5036432) - 16.0.4125.3 (X64) May 1 2024 15:05:56 Copyright (C) 2022 Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2019 Standard 10.0 (Build 17763: ) (Hypervisor)
.NET Framework Version
.NET 8.0.6
The text was updated successfully, but these errors were encountered: