Any way to change password of user through SOAP API without old password info

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Post Reply
User avatar
talha06
Posts: 25
Joined: Sat Sep 13, 2014 3:02 am

Any way to change password of user through SOAP API without old password info

Post by talha06 »

Hi all,
I would like to learn are there any ways to change user passwords through SOAP API without old password information as existing ChangeAccount request demands. Because of I use admin credentials, I think I should be able to complete this operation without old password information.
Your helps will be appreciated a lot.
Thanks in advance.

From API Reference:
ChangePasswordRequest
    <ChangePasswordRequest> ## ChangePasswordRequest
        <account by="{acct-selector-by} (adminName|appAdminName|id|foreignPrincipal|name|krb5Principal)">{key}</account> ## AccountSelector
        <oldPassword>{oldPassword} (String)</oldPassword>
        <password>{password} (String)</password>
        <virtualHost>{virtualHost} (String)</virtualHost>
    </ChangePasswordRequest>
User avatar
Gren Elliot
Advanced member
Advanced member
Posts: 183
Joined: Tue Jun 10, 2014 4:45 am

Any way to change password of user through SOAP API without old password info

Post by Gren Elliot »

You can use the ZimbraAdmin SetPasswordRequest SOAP API. See http://wiki.zimbra.com/wiki/SOAP_API_Re ... th_ZCS_8.0 which leads to https://files.zimbra.com/docs/soap_api/ ... index.html if your version is 8.5.0.
User avatar
talha06
Posts: 25
Joined: Sat Sep 13, 2014 3:02 am

Any way to change password of user through SOAP API without old password info

Post by talha06 »

Hi @Gren,



I have already looked over the API reference but could not find a service addresses my problem.

I'll be glad if you can tell me the name of service I can use for.



Thanks in advance.

-Talha
User avatar
Gren Elliot
Advanced member
Advanced member
Posts: 183
Joined: Tue Jun 10, 2014 4:45 am

Any way to change password of user through SOAP API without old password info

Post by Gren Elliot »

SetPasswordRequest is the API request that allows an Admin to change a user's password without knowing the original. That is documented at the URLs in my previous reply. Do a search in the bottom left frame of the API reference for "SetPassword"
User avatar
talha06
Posts: 25
Joined: Sat Sep 13, 2014 3:02 am

Any way to change password of user through SOAP API without old password info

Post by talha06 »

thanks a lot Gren for your care. This is what I am looking for except I do not have ZimbraID information - I need to change user's password through his/her email username. Is this possible too?
User avatar
talha06
Posts: 25
Joined: Sat Sep 13, 2014 3:02 am

Any way to change password of user through SOAP API without old password info

Post by talha06 »

Any other ideas will be appreciated a lot! Thanks in advance.
User avatar
Gren Elliot
Advanced member
Advanced member
Posts: 183
Joined: Tue Jun 10, 2014 4:45 am

Any way to change password of user through SOAP API without old password info

Post by Gren Elliot »

You can use GetAccountRequest e.g.:

<GetAccountRequest attrs="zimbraId" xmlns="urn:zimbraAdmin">

<account by="name">for@pan.local</account>

</GetAccountRequest>



<GetAccountResponse xmlns="urn:zimbraAdmin">

<account name="for@pan.local" id="101a7428-0409-4adc-acb0-ac84eafe89f8">

<a n="zimbraId">101a7428-0409-4adc-acb0-ac84eafe89f8</a>

</account>

</GetAccountResponse>
User avatar
talha06
Posts: 25
Joined: Sat Sep 13, 2014 3:02 am

Any way to change password of user through SOAP API without old password info

Post by talha06 »

thank you so much [mention:f2a614af661743dba278e99988cfb764:e9ed411860ed4f2ba0265705b8793d05] for your help; really appreciated a lot!

All the best.
User avatar
Gren Elliot
Advanced member
Advanced member
Posts: 183
Joined: Tue Jun 10, 2014 4:45 am

Any way to change password of user through SOAP API without old password info

Post by Gren Elliot »

Thanks for the recognition :)
rojoblandino
Advanced member
Advanced member
Posts: 52
Joined: Sat Sep 13, 2014 1:36 am

Re: Any way to change password of user through SOAP API without old password info

Post by rojoblandino »

I am knew in this world of the SOAP and XML world, i look and look but no so much functional examples could be found there for many task with this api.

So reading the fork i used the api found in this link https://github.com/zimbra-api/zimbra-api/ and I could make it work for resetting the password of the user as follow:

Code: Select all

<?php

// This file is generated by Composer
require_once 'vendor/autoload.php';

$api = \Zimbra\Admin\AdminFactory::instance('https://10.0.10.40:7071/service/admin/soap');
$api->auth('admin', admin.zimbra.password');
$account = new \Zimbra\Struct\AccountSelector(\Zimbra\Enum\AccountBy::NAME(), 'mailbox@example.com');
$id = ((array)$api->getAccountInfo($account)->a[0])["_"];
echo $id."\n";
$passwordInfo = $api->setPassword($id,"MyNewPassword.2341");
If any is looking a functional example, i leave it here.
Post Reply