Hello,
I'm trying to run a powershell script after password reset in order to create a record of the new password in a mysql database. Here is the script I'm using:
## MYSQL Connection
## This requires mysql connector net
## All variables will need changing to suit your environment
$server= "password.domain.org"
$username= "Adaxes"
$password= "P@ssW0rd"
$database= "passworddb"
## The path will need to match the mysql connector you downloaded
[void][system.reflection.Assembly]::LoadFrom("C:\Program Files (x86)\MySQL\MySQL Connector Net 6.8.3\Assemblies\v2.0\MySQL.Data.dll")
$SqlConnection = New-Object Mysql.Data.MySqlClient.MySqlConnection
$SqlConnection.ConnectionString = "server=$server;uid=$username;password=$password;database=$database;pooling=false;Allow Zero Datetime=True;"
$Query = "INSERT INTO userpasswords(username,password,moddate,ip,modbyuser) VALUES('%username%','%unicodePwd%',%datetime%,'Adaxes','%initiator%') ON DUPLICATE KEY UPDATE password='%unicodePwd%',moddate='%datetime%',ip='Adaxes',modbyuser='%initiator%'"
$SqlConnection.Open()
$SqlCmd = New-Object MySql.Data.MySqlClient.MySqlCommand $Query, $SqlConnection
$SqlCmd.ExecuteNonQuery()
$SqlConnection.Close()
However Adaxes is not putting the new password into the script. Do I have to use something other than unicodePwd? Here is the query that the mySql database receives after Adaxes sends it:
INSERT INTO userpasswords(username,password,moddate,ip,modbyuser) VALUES('test_user','',2/26/2014 3:53:17 PM,'Adaxes','ryan_breneman@domain.org') ON DUPLICATE KEY UPDATE password='',moddate='2/26/2014 3:53:17 PM',ip='Adaxes',modbyuser='ryan_breneman@domain.org'
Thanks for your help!