Password TAdoConnection goes to AWOL

Using TAdoConnection in D5 to connect to a local Sql server on a 64-bit Windows 7 machine using a sa account with a password, I get the error message โ€œlogin failed for user saโ€ even though I created a TAdoConnection ConnectionString to enable the password . By the time the BeforeConnect ConnectionString event occurs, it no longer contains a password. I can set a password in the WillConnect event, and then the connection will work fine.

My question is, what is removing the password from ConnectionString? Maybe some security features were added in W7 - I donโ€™t remember how this problem arose in XP.

Btw: this problem still occurs even if I set Persist Security Info to true in ConnectionString - the password is not even saved in DFM.

+6
source share
1 answer

In your ConnectionString, you must include "Persist Security Info = True" in the previous section. I use two constants, one for SQL authentication, and the other for Active Directory authentication, and just fill in the blanks.

const csCONNECTION = 'Provider=%s;Password=%s;Persist Security Info=True;User ID=%s;Initial Catalog=%s;Data Source=%s'; csADCONNECTION = 'Provider=%s;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=%s;Data Source=%s'; 
+7
source

Source: https://habr.com/ru/post/951305/


All Articles