Change MSSQL expired password (ODBC) with PHP
Posted on 2009-04-06
Situation is that the web server is not the database server (different machine, different admins). Using IIS and MSSQL database. The admins have set the username that my PHP app logs in with to expire every 30 days. This ALWAYS happens on a weekend for some reason!
So, I thought it would be cool if my PHP app could just automatically change the password when it expires.
Well, the problem is that when I odbc_connect($myDsn, $myUser, $myPass) I get a message saying that the password for this login has expired, SQL state 37000 and to change the password.
Now, I can use the Microsoft SQL Server Manager to log in, and it pops up a window asking for a new password...
But how do I get the PHP app to do it, when it fails at odbc_connect()? Is there an odbc_change_password() or something?
(Not possible for me to change the password before it expires. Military, go figure.)