I am having a problem that occurred in a specific circumstances in my Delphi 7 application.
I have ADOConnection that goes to my MS SQL server with some username and pass - SQL authentication. The problem is that MS SQL login was created with "User must change pass at next login" flag that makes ADO Connection impossible to connect with error message "18488 - Login failed for user '%.*ls'. Reason: The password of the account must be changed."
Normally, in MS SQL Management Studio a change password prompt is shown, and user is able to enter new password. The question is what should I do to force password change on this user in my application? I am able to catch error number and prompt for login change, but what then? There is no flag in a connection string that I could use to change pass/reset to new (like Old Password and New Password). What should I do then?
Can anyone help?
When you trap the 18488 error, You need to show your own "change password" dialog, and use connection string properties
"Old Password"
/"Password"
viaSQL Native Client
as your provider (i.e.Provider=SQLNCLI10
orSQLNCLI.1
).Here is a small code I used to test this:
My answer is based on these readings:
This is the official way of changing passwords from the client side when you enforce password expiration and use "User must change password at next login" option on the SQL server.
If installing the SQL Server Native Client on the users machine is an issue, I can think of few more options:
sa
), and alter the user's/login password. meaning you will need to hold that username/password on the client machine (bad idea IMHO from security point of view but might be workable). - not tested