Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
lostonweb
Starting Member
2 Posts |
Posted - 2005-05-31 : 19:22:04
|
| I am new to vbscript and sql. I am try to change the sa password through vbscript but I have no clue on how to do it. This is being called from an msi package. If sa password is blank I want to change it instead of setting a property for the install.Sub SetSQLPassword() Dim sSQLServer, sAuthType, sUserName, sPassword, sSQLDB Dim sConString, sCn Dim sql, rsDB On Error Resume Next sSQLServer = Session.Property("IS_SQLSERVER_SERVER") sSQLDB = Session.Property("IS_SQLSERVER_DATABASE") sConString = "Provider = SQLOLEDB;" &_ "Data Source = " & sSQLServer & ";" &_ "Initial Catalog = master;" ' 0 integrated, 1 standard sAuthType = Session.Property("IS_SQLSERVER_AUTHENTICATION") If sAuthType = 1 Then sUserName = Session.Property("IS_SQLSERVER_USERNAME") sPassword = Session.Property("IS_SQLSERVER_PASSWORD") sConString = sConString & "User Id = " & sUserName & ";" &_ "Password = ;" Else sConString = sConString & "Integrated Security=SSPI;" End If Set sCn = CreateObject("ADODB.Connection") sCn.ConnectionString = sConString sCn.Open If Err.Number <> 0 Then Dim DBLogin 'As SQLDMO.Login SET DBLogin = Nothing Else Session.Property("IS_SQLSERVER_PASSWORD") = "" End If 'Cleanup sCn.CloseEnd Sub |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-05-31 : 21:46:43
|
| sql login passwords can be changed using sp_password--------------------keeping it simple... |
 |
|
|
lostonweb
Starting Member
2 Posts |
Posted - 2005-05-31 : 23:48:11
|
| How do I call it in vbscript |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-06-01 : 00:18:34
|
quote: Originally posted by lostonweb How do I call it in vbscript
it's an SP with 3 parameters, sp_password @old,@new,@loginamestrSQL="execute sp_password 'oldpassword','newpassword','loginame'"scn.execute strSQL--------------------keeping it simple... |
 |
|
|
tomy74
Starting Member
32 Posts |
Posted - 2005-06-01 : 05:24:06
|
| Hi,For SqlServer 2000 sp3You can use also SQL-DMO library.Set sServer = CreateObject ("SQLDMO.SQLServer")sServer.LoginSecure = FalsesServer.Connect "Servername", "Login", "OldPassword"sServer.Logins("Login").SetPassword "OldPassword", "NewPassword"Thx,Tarek Ghazali |
 |
|
|
|
|
|
|
|