zimbra-api php delegateAuth!!!

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Jhonmicky
Posts: 31
Joined: Tue Aug 06, 2019 7:38 pm

zimbra-api php delegateAuth!!!

Postby Jhonmicky » Sat Nov 02, 2019 10:37 pm

Trying to build a web app to create an appoint as any user.whatsapp web 192.168.0.1 routerlogin


The following works great in a single user scenario if i have the users password. However I would like to auth as admin and then create the appointment as if the user I pick created it. I was reading about delegateAuth but can't find any examples on how to successfully implement. Can someone help or post an example

Code: Select all

use Zimbra\Enum\AccountBy;
use Zimbra\Enum\AddressType;
use Zimbra\Enum\AlarmAction;
use Zimbra\Enum\FreeBusyStatus;
use Zimbra\Enum\InviteStatus;
use Zimbra\Enum\InviteClass;
use Zimbra\Enum\ParticipationStatus;
use Zimbra\Enum\Transparency;

use Zimbra\Mail\MailFactory;
use Zimbra\Mail\Struct\AlarmInfo;
use Zimbra\Mail\Struct\AlarmTriggerInfo;
use Zimbra\Mail\Struct\CalendarAttendee;
use Zimbra\Mail\Struct\CalOrganizer;
use Zimbra\Mail\Struct\DtTimeInfo;
use Zimbra\Mail\Struct\DurationInfo;
use Zimbra\Mail\Struct\EmailAddrInfo;
use Zimbra\Mail\Struct\InvitationInfo;
use Zimbra\Mail\Struct\InviteComponent;
use Zimbra\Mail\Struct\MimePartInfo;
use Zimbra\Mail\Struct\Msg;

use Zimbra\Struct\AccountSelector;

$api = MailFactory::instance('https://zimbraserver/service/soap');
try {
    $account = new AccountSelector(AccountBy::NAME(), 'test@mailserver.com');
    $api->auth($account, 'xxxx');

    $trigger = new AlarmTriggerInfo();
    $trigger->setRelative(new DurationInfo(true, null, null, null, 5, null, 'START'));
    $alarm = new AlarmInfo(AlarmAction::DISPLAY(), $trigger);

    $comp = new InviteComponent();
    $comp->setName('Meet celebrities for free')
        ->setLocation('My home')
        ->setFreeBusy(FreeBusyStatus::FREE())
        ->setStatus(InviteStatus::COMPLETED())
        ->setCalClass(InviteClass::PUB())
        ->setTransparency(Transparency::OPAQUE())
        ->setIsAllDay(false)
        ->setIsDraft(false)
        ->addAttendee(new CalendarAttendee('test@mailserver.com', null, 'User1'))
        ->setDtStart(new DtTimeInfo('20180130T160000', 'America/New_York'))
        ->setDtEnd(new DtTimeInfo('20180130T170000', 'America/New_York'))
        ->addAlarm($alarm);

    $inv = new InvitationInfo();
    $inv->setInviteComponent($comp);

    $mp = new MimePartInfo(null, 'multipart/alternative');
    $mp->addMimePart(new MimePartInfo(null, 'text/plain', 'Meet celebrities for free'));

    $msg = new Msg();
    $msg->setSubject('Meet celebrities for free')
        ->setFolderId('10')
        ->addEmail(new EmailAddrInfo('test@mailserver.com', AddressType::TO(), 'User1'))
        ->setInvite($inv)
        ->setMimePart($mp);
    $result = $api->createAppointment($msg);
    var_dump($result);
}
catch(Exception $ex) {
    $client = $api->getClient();
    echo $client->lastResponse();


Return to “Developers”

Who is online

Users browsing this forum: No registered users and 1 guest