can't accces contacts from mailboxowner@example.com via mailbox delegation(ServiceCredentials)
Takalele opened this issue · 2 comments
Describe the bug
can't accces contacts from mailboxowner@example.com via mailbox delegation(ServiceCredentials)
To Reproduce
ServiceCredentials = Credentials(username='delegation_service_user', password='xyz')
ServiceConfig = Configuration(retry_policy=FaultTolerance(max_wait=600), server='owa.example.com', credentials=ServiceCredentials)
usrMbx = Account(primary_smtp_address='mailboxowner@example.com', config=ServiceConfig, autodiscover=False, access_type=DELEGATE)
a = usrMbx
folder = a.root / 'Top of Information Store' / 'Contacts'
for p in folder.people():
print(p)
output (the persona is not from the mailboxowner contacts)
Persona(_id=PersonaId(id='...REDUCTED...', changekey=None), persona_type='Person'....
Expected behavior
to view all the contacts from the mailboxowner via delegate access
Actuall behavior
contacts from delegation_service_user are shown.
the same is true for calandar items, but the strange thing is i can write and delete single calandar items via
write:
item = CalendarItem(folder=usrMbx.calendar, subject=itemSubject,
start=itemStart, end=itemStop, categories=[itemSubject,], legacy_free_busy_status="Free")
item.save()
delete:
item = usrMbx.calendar.get(subject=removeItem.subject, start=removeItem.start, end=removeItem.end)
item.delete()
Additional context
exchangelib 5.1.0
Python 3.10.12
UPDATE:
the calender write and delete into the mailboxowner@example.com via delegation only working with exchangelib 4.5.0
the same goes for the creating contacts
with exchangelib 5.1.0 the delegation is broken.
reading the contacts is broken in both version.
creating contacts:
contact = Contact(
account=a,
folder=a.contacts,
given_name="Test",
surname="Lockt",
display_name="Test Lockt",
phone_numbers=[
PhoneNumber(label="MobilePhone", phone_number="123456"),
PhoneNumber(label="BusinessPhone", phone_number="123456"),
PhoneNumber(label="OtherTelephone", phone_number="123456"),
],
email_addresses=[
EmailAddress(label="EmailAddress1", email="test@test.si"),
EmailAddress(label="EmailAddress2", email="test2@test.si"),
],
physical_addresses=[
PhysicalAddress(
label="Home",
street="Test 30",
city="TestCity",
country="TestCountry",
zipcode="8237",
)
],
company_name="Blue Anon Airlines",
)
contact.save()
BR
Takalele
This sounds a bit like #1222
@ecederstrand true thank you for the hint
the problem is solved i just have to use DistinguishedFolderId which was not necessary before version 5.1.0
from exchangelib import DELEGATE, Account, Credentials, \
Configuration, Mailbox, FaultTolerance, Contact
from exchangelib.folders import Calendar, Contacts, SingleFolderQuerySet
from exchangelib.properties import DistinguishedFolderId, Mailbox
from exchangelib.indexed_properties import PhoneNumber, EmailAddress, PhysicalAddress
ServiceCredentials = Credentials(username='delegation_service_user', password='xyz')
ServiceConfig = Configuration(retry_policy=FaultTolerance(max_wait=600), server='owa.example.com', credentials=ServiceCredentials)
usrMbx = Account(primary_smtp_address='mailboxowner@example.com', config=ServiceConfig, autodiscover=False, access_type=DELEGATE)
mailbox = Mailbox(email_address='mailboxowner@example.com')
folder = DistinguishedFolderId(id=Contacts.DISTINGUISHED_FOLDER_ID, mailbox=mailbox)
shared_contacts = SingleFolderQuerySet(account=usrMbx, folder=folder).resolve()
contacts = list(shared_contacts.all())
print(shared_contacts.root.tree())
print(contacts)
BR
Takalele