Search code examples
powershellencryptionpasswordsodbcdatasource

How to store encrypted-dp{encrypted-password} using Windows odbcconf CONFIGSYSDSN or Set-OdbcDsn in PowerShell


When I edit a password in ODBC Data Source through a Windows "ODBC Data Source Administrator" dialog window, the password is stored in an encrypted manner like encrypted-dp{encrypted-password} in Windows registry.

When I edit the password using odbcconf CONFIGSYSDSN, it is stored as plain text in the registry.

Is there a way to store a data source password using programmatic way/script in the same way as the Windows ODBC dialog window does?


Solution

  • In this case, it was an external library, which was editing data source properties, encryption wasn't made as a part of the Windows process.

    This lib was encrypting the password when changing the properties over the Data Source edit window - which was already a proprietary 3rd party window, coming from the lib.

    We got an exposed "encrypt" method from the vendor, so we can also encrypt the password ourselves when using PowerShell.