April 10, 2002 at 1:40 am
I must first congratulate Andy Warren on the excellent articles on DMO. It was because of his articles, that I decided to use DMO and to learn more about it. Which brings me to my current problem.
In my app, I want to change an exsisting user's password. I now the method I need to use is .setpassword. The problem comes after that. What do I do to add the new password. Creating a new user and setting the password is no problem, but for an existing user I cannot use SQLInstance.Logins.Add. I would appreciate any help you can give me.
Regards
Gert de Swardt
April 10, 2002 at 5:41 am
SQLInstance.Login.SetPassword(OldPassword As String, NewPassword As String)
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
April 10, 2002 at 6:10 am
Thanx for the reply Antares686, but it still don't work.
Here is the code as it is at the moment:
Private Sub ChangePsw(ByVal CurrUser As String, ByVal NewPassword As String)
On Error GoTo ErrorHandler
Dim CurrLogin As SQLDMO.Login
Set SQLInstance = New SQLDMO.SQLServer
Set SQLInstance = SQL.SQLServers.ItemByID(GSQLServerID)
Set CurrLogin = CreateObject("SQLDMO.Login")
CurrLogin.Name = CurrUser
CurrLogin.SetPassword "", NewPassword
'SQLInstance.Logins.Add CurrLogin
Set CurrLogin = Nothing
Exit Sub
ErrorHandler:
If Screen.MousePointer = vbHourglass Then
Screen.MousePointer = vbDefault
End If
MsgBox Err.Description, vbCritical
End Sub
Maybe the with the code you could get a better idea.
Regards
Gert
April 10, 2002 at 6:43 am
Glad you found the articles helpful. You need to set the login object to an existing user. As it is your login object doesnt exist in the db. You need something like this:
Set CurrLogin = database.logins("SA")
CurrLogin.SetPassword "", NewPassword
Andy
April 10, 2002 at 8:14 am
Hi Andy
You're a genius. Thanx for the advice. It works like a charm.
Regards
Gert
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply