Groups | Blog | Home
all groups > sql server programming > december 2004 >

sql server programming : Getting the sa password with SQLDMO


Otis
12/26/2004 10:47:31 PM
Hi,

I have a failsafe routine that checks the sa password to make sure that it
has not been changed. I can reset it like this:

If objLogin.Name = "sa" Then objLogin.SetPassword vbNullString,
"Somepassword"

But it seems a little sloppy to be setting this password again and again
when it never changes. Is there a way to discover the password with SQLDMO
so I can see if it has changed before I go setting it again?

Thanks.

Steve

Dan Guzman
12/26/2004 11:09:47 PM
SQL Server stores passwords using a one-way hash so you can't read the
existing password into a clear text string. You could accomplish the
conditional password change by attempting a connection using the expected sa
password and, if it fails, connect using a different sysadmin role member
login to change the password as desired.

However, the need for such a script strikes me as odd. Only sysadmin role
member can change the sa password. I would hope that your sysadmin role
members don't change the sa password indiscriminately.

--
Happy Holidays

Dan Guzman
SQL Server MVP

[quoted text, click to view]

Otis
12/27/2004 9:35:38 AM
Dan,

Users do not have access to the sa password. It is set at program
installation and kept that way. I wrote that code to guard against a hack.
But it does seem odd. I don't know how someone could hack into SQL Server to
do that.

Thanks for the comments.

Steve

AddThis Social Bookmark Button