Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 3rd, 2009, 06:40 AM
Authorized User
 
Join Date: Jan 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reset SQL Logon Password thru Access Front End

Scratching head with this one, I want to be able to reset a Users Password (use the sp_password Stored Procedure), without having to go into the SQL Backend.

However the Old Password Parameter I wish to pass is NULL, however when executing the command it says the Parameter is incorrect.

Any Ideas

[quote]
[Private Sub cmdOk_Click()
Dim strPassword1 As String, strPassword2 As String
Dim strLogonName As String
Dim strFirstName As String
Dim strLastName As String
Dim strFormName As String
Dim strCnn As String
Dim i As Integer
Dim cmd As ADODB.Command
On Error GoTo Err_error
i = 0
strCnn = "Provider = Microsoft.Access.OLEDB.10.0;"
strCnn = strCnn & "Persist Security Info=False;Data Source=" & gbl_serverName & ";"
strCnn = strCnn & "User ID=wsrs_admin;Password=ch414fd;Initial Catalog=" & gbl_dbName & ";Data Provider=SQLOLEDB.1"
strPassword1 = Me.txtPassword1
strPassword2 = Me.txtPassword2
strFirstName = Left(Form_frmInsertOfficer.txtFirstName, 1)
strFirstName = LCase(strFirstName)
strLastName = LCase(Form_frmInsertOfficer.txtLastName)
strLogonName = strLastName & strFirstName

If strPassword1 = strPassword2 Then
If Len(strPassword1) < 6 Then

MsgBox "Password Required to be more than 6 Characters", vbCritical, "Password Requirement"

Resume Err_exit

Else
Set cmd = New ADODB.Command
cmd.ActiveConnection = strCnn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "sp_Password"
cmd.Parameters.Append cmd.CreateParameter("Old", adEmpty, adParamInput, 1, Null)
cmd.Parameters.Append cmd.CreateParameter("New", adVarChar, adParamInput, 10, strPassword1)
cmd.Parameters.Append cmd.CreateParameter("LoginName", adVarChar, adParamInput, 10, strUserName)
cmd.Execute

End If

Else

MsgBox "Password does not match. Please reenter.", vbCritical, "Password Error"

Me.txtPassword1.SetFocus
Me.txtPassword1.Text = ""
Me.txtPassword2.SetFocus
Me.txtPassword2.Text = ""

Resume Err_exit

End If
strFormName = "frmResetPassword"
DoCmd.Close acForm, strFormName, acSaveNo
Err_exit:
Exit Sub
Err_error:
MsgBox Err.Number & ", " & Err.Description, vbCritical, "Error"
Resume Err_exit
End Sub
/QUOTE]
 
Old March 9th, 2009, 08:35 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

How did you arrive at this connection object?

Code:
strCnn = "Provider = Microsoft.Access.OLEDB.10.0;"
strCnn = strCnn & "Persist Security Info=False;Data Source=" & gbl_serverName & ";"
strCnn = strCnn & "User ID=wsrs_admin;Password=ch414fd;Initial Catalog=" & gbl_dbName & ";Data Provider=SQLOLEDB.1"
This is connecting to Access, not SQL Server, it appears. Is the connection working?

Also, is it possible to set the SQL Server database to Windows NT authenitcation? This will eliminate the need to do this at all.
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old March 11th, 2009, 05:53 AM
Authorized User
 
Join Date: Jan 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The Connection works fine, so I'm not concerned about that. Although I do admit looking at it now it does look a little odd. I haven't worked on this application for about six months so am having to educate myself again.

The issue with using Windows Authentication, is that I felt it removed a layer of security, and I really wanted the User to have to login.
 
Old March 11th, 2009, 07:45 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I am not sure the reasoning there. Windows NT authentication will add a layer of security, assuming that the person logged into the computer is actually the person who has access. How often do your users hijack or spoof other user's Windows sessions? Anyway, if they can crack the Windows session, they can crack the SQL Server session.

Why are you passing a NULL for the old password? Shouldn't there be some value there?
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old March 11th, 2009, 07:47 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I am finding that you send the old password as NULL when you want to change the SA password, not other users.

How about using ALTER LOGIN instead?
__________________
mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old March 11th, 2009, 09:22 AM
Authorized User
 
Join Date: Jan 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If I go into the SQL Backend I can run the stored procedure with the NULL for any SQL login I have created. The reason for using NULL is because the old password can not be retrieved.

Am I right in thinking ALTER LOGIN doesn't work with SQL 2000

Last edited by feets; March 11th, 2009 at 09:55 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple SQL Databases for Same Access Front End darrenb Access 0 May 27th, 2008 12:07 AM
Ms Access front End with Oracle 10g Back End rahul123 Oracle 1 July 9th, 2007 01:03 AM
Oracle back-end MS-Access 2003 client front-end Corey Access 2 February 16th, 2007 08:31 AM
Oracle Back End - MS Access Front End - Multi User ckaliveas Oracle 1 February 1st, 2007 06:00 AM
poor perfomance using Access front end to SQL tanjuakio Access 24 April 19th, 2005 07:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.