Our company policy is (foolishly) to expire Oracle passwords every 2 months. I have set up some code to allow them to change the password but I'm hitting a snag. Their password is expired so if I use that to open the connection it fails. Their new password isn't valid yet so if I use that it fails. How do I open a connection so I can run the ALTER USER command?
My code currently looks like this:
Public Function ChangeUserPassword(ByVal UserID As String, ByVal sPassword As String, ByVal OldPassword As String)
Dim foo As Boolean = False
cn2 = New OracleConnection("Data Source=" & sDataBase & "; User Id=" & UserID & "; Password=" & OldPassword & "; Pooling=False;")
Try
cn2.Open()
Dim cmd As New OracleCommand("ALTER USER " & UserID & " identified by " & sPassword & " replace " & OldPassword, cn2)
cmd.ExecuteNonQuery()
Catch ex As Exception
foo = TestNewPassword(UserID, sPassword, OldPassword)
Return foo
End Try
Return True
End Function