how to update mail password using api - soap

Discussion in 'Installation/Configuration' started by rob_morin, Aug 9, 2015.

  1. rob_morin

    rob_morin Member

    I am using the mail_user_update.php
    as an example to change passwords.
    This updates the password but it does not encrypt it so we can't access the mailbox via roundcube or a mail client. I am thinking there needs to be an encrypt function?
    can anyone help?


    require 'soap_config.php';

    $client = new SoapClient(null, array('location' => $soap_location,
    'uri' => $soap_uri,
    'trace' => 1,
    'exceptions' => 1));

    try {
    if($session_id = $client->login($username, $password)) {
    echo 'Logged successfull. Session ID:'.$session_id.'<br />';

    //* Parameters
    $mailuser_id = 794;
    //$client_id = 15;

    //* Get the email user record
    $mail_user_record = $client->mail_user_get($session_id, $mailuser_id);

    //* Change the status to inactive
    $mail_user_record['password'] = crypt_password('gilbert');

    $affected_rows = $client->mail_user_update($session_id, $client_id, $mailuser_id, $mail_user_record);

    echo "Number of records that have been changed in the database: ".$affected_rows."<br>";

    if($client->logout($session_id)) {
    echo 'Logged out.<br />';

    } catch (SoapFault $e) {
    echo $client->__getLastResponse();
    die('SOAP Error: '.$e->getMessage());

  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The password has to be passed unencrypted to the function, so the line:

    $mail_user_record['password'] = crypt_password('gilbert');

    has to be:

    $mail_user_record['password'] = 'gilbert';

    If you use the function crypt_password then ispconfig detects that you try to pass a password in a unknown encryption and will ignore it.

Share This Page