Force Reset and the SOAP API

This error/quirk was originally found by Ben, but I thought it was worth posting about just for future reference.

When interacting with account objects using SOAP, you may want to set the Force Password Change boolean on those accounts. This cannot be done in the same SOAP client update cycle as a password reset [Example 1]. You must first reset the password and then create a separate client session in order to set the Force Password Change boolean (i.e., run through all the accounts you just reset the password on and set the Force Password Change boolean and then update the client)[Example 2].

You were probably tempted to try something like this first (Example 1):


for (int i = 0; i < accountList.Count; i++)
{
Account account = new Account();
ID accountID = new ID();
accountID.id = Convert.ToInt32(accountList[i].id);
accountID.idSpecified = true;
account.ID = accountID;
account.NewPassword = newPassword;
AccountOptions ao = new AccountOptions();
ao.ForcePasswordChange = true;
ao.ForcePasswordChangeSpecified = true;
rnObjectsArray[i] = account;
}
updateClient(client, rnObjectsArray);

This is an example of code that works (Example 2):


for (int i = 0; i < accountList.Count; i++)
{
Account account = new Account();
ID accountID = new ID();
accountID.id = Convert.ToInt32(accountList[i].id);
accountID.idSpecified = true;
account.ID = accountID;
account.NewPassword = newPassword;
rnObjectsArray[i] = account;
}
updateClient(client, rnObjectsArray);

if (forceResetChecked)
{
for (int i = 0; i < accountList.Count; i++)
{
Account account = new Account();
ID accountID = new ID();
accountID.id = Convert.ToInt32(accountList[i].id);
accountID.idSpecified = true;
account.ID = accountID;
AccountOptions ao = new AccountOptions();
ao.ForcePasswordChange = true;
ao.ForcePasswordChangeSpecified = true;
account.Attributes = ao;
rnObjectsArray[i] = account;
}
updateClient(client, rnObjectsArray);
}


-Sam

Comments

Thanks, Sam. The same is true for Connect PHP calls. Here's a snippet:

$account->NewPassword = $newPassword;
$account->save();

$account->Attributes = new \RightNow\Connect\v1_2\AccountOptions();
$account->Attributes->ForcePasswordChange = 1;
$account->save();

Zircon - This is a contributing Drupal Theme
Design by WeebPal.