问题
I'm working with the php-ews library to integrate with exchange. I was wondering if there was any way to access the global address book, I've searched the documentation and nothing comes up. I would like to access it so I can view room resources.
Thanks
回答1:
I don't think that the GetRooms
method was ever added to php-ews. It seems they just quit development.
see.. https://github.com/jamesiarmes/php-ews/issues/91
As a workaround, if your rooms exist in Active Directory, you could do an LDAP query to get the rooms and then loop through each room using the email address of the room to get it's calendar with php-ews. Otherwise, you could possibly maintain a db list of the rooms with their email addresses and pull them that way before looping.
Once you have the rooms' email addresses, you'd use Exchange impersonation, impersonating the email of the room to check it's calendar.
Something like this...
// Configure impersonation using the conference OwnerEmailAddress
$ei = new EWSType_ExchangeImpersonationType();
$sid = new EWSType_ConnectingSIDType();
$sid->PrimarySmtpAddress = $email;
$ei->ConnectingSID = $sid;
$ews->setImpersonation($ei);
// Set the search for calendar item types
$request = new EWSType_FindItemType();
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$request->CalendarView = new EWSType_CalendarViewType();
// Set the instance start and end times
$request->CalendarView->StartDate = $start->format('Y-m-d\TH:i:s');
$request->CalendarView->EndDate = $end->format('Y-m-d\TH:i:s');
// Set the search location as the calendars folder of the impersonated user
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
$request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = $email;
// Execute the search
$response = $ews->FindItem($request);
where you supply the $email
and $start
and $end
. NOTE: the account you access the EWS API with will require impersonation privileges.
Good luck.
回答2:
@Souljacker - EWS does not expose the Global Address Book. If you want to find room resources, you can use the GetRoomLists operation and GetRooms operation. The only places that EWS exposes info from the Global Address Book is through the ResolveNames operation and the FindPeople operation with the Directory option.
来源:https://stackoverflow.com/questions/23407963/php-ews-access-global-address-book