Search code examples
c++parametersconnection-stringsybase-asa

Encrypting ODBC DSN login password programmatically


I am using file DSN for connecting to Sybase database. Login password is encrypted and is stored with EncryptedPassword keyword in the .dsn file. I have the requirement to change the database password and update the DSN accordingly.

I am using SQLDriverConnect to connect to the database and SQLWriteFileDSN to modify the .dsn file.

Is there any way to encrypt the new given password same way Sybase does(keyword or special tag or some thing?).?

Some limitation:

  1. I know its not recommended to store password/encrypted bassword in DSN, but I can not provide the password on the run to connect call. I have to use DSN(System/User/File DSN). File DSN over others is just because it doesn't show password in a .dsn file if not encrypted.

  2. Driver using is Adaptive Server Anywhere 9.0 from iAnywhere Solutions, inc. DBODBC9.DLL. I guess its the pretty old version.


Solution

  • Take a look at the dbdsn utility that is shipped with SQL Anywhere. If you use the -pe switch, the password you specify will be encrypted when the DSN is saved.