Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking last 6 passwords

Status
Not open for further replies.

sanctified

Programmer
Mar 9, 2006
65
GB
Hi Group,
I'm using the built-in sp_password SP and was wondering if I could get at the last 6 passwords the user has used and prevent them from using them again. I'm using ASP.NET as my front-end.

Here is a snippet of code:
Private Sub btnSaveChanges_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveChanges.Click
Dim strMsg As String

strMsg = ""

'Check that the new password confirmation matches
If txtNew.Text <> txtConfirmNew.Text Then
strMsg = "The new passwords do not match"
End If
'Check to see if a password has been entered
If txtNew.Text = "" Then
strMsg = "The new password cannot be blank"
End If
'test width of text string
If Len(txtNew.Text) < 6 Then
strMsg = "The password must be at least 6 characters"
End If



'Return error string
If strMsg <> "" Then
Dim strScript As String = "<script language=Javascript>"
strScript += "alert(""" & strMsg & """);"
strScript += "</script>"
If (Not Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript", strScript)
End If

Exit Sub
End If

'Connect to the database
Dim strCmd As String
strCmd = "sp_password"

Try
connDBConnect.ConnectionString = Session("ConnectionString")
cmdDBCommand.Connection = connDBConnect
cmdDBCommand.CommandText = strCmd
cmdDBCommand.CommandType = CommandType.StoredProcedure
cmdDBCommand.Parameters.Add(New SqlParameter("@old", Data.SqlDbType.VarChar, 20))
cmdDBCommand.Parameters.Add(New SqlParameter("@new", Data.SqlDbType.VarChar, 20))

cmdDBCommand.Parameters("@old").Value = txtCurrent.Text
cmdDBCommand.Parameters("@new").Value = txtNew.Text

connDBConnect.Open()
cmdDBCommand.ExecuteNonQuery()

lblMessage.Text = "Password successfully changed"
.......
End sub
 
You would have to store them yourself in a table and check against that table to see if it's been used.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Hi Denny,
Yes I thought this was the case. Just wanted to be certain.
Thanks!!
 
No problem.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top