SqlConnection.ConnectionString losing password after Open

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a SqlConnection object that in turn has a ConnectionString property
set that includes a "pwd=password" in it. When I make the call
SqlConnection.Open() and I later try to get the
SqlConnection.ConnectionString, the pwd portion of the string is no longer
there. I'm assuming this is some sort of security issue, but I found it as
odd. What's going on?

Thanks,
 
Hi,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that when you're trying to get the
ConnectionString from a SqlConnection after Open method is called, the
Password portion is missing. If there is any misunderstanding, please feel
free to let me know.

In this case, I assume that Persist Security Info part is set to false or
using the default value 'false' in your connection string. According to
MSDN document, when it is set to false or no (strongly recommended),
security-sensitive information, such as the password, is not returned as
part of the connection if the connection is open or has ever been in an
open state. This behavior is for security reason.

You can check the following link for more information:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemdatasqlclientsqlconnectionclassconnectionstringtopic.asp

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top