-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ErrorAccessDenied thrown if folder contains private items #342
Comments
I agree this is not ideal. The assumption has been that You could try to allow this error in the response instead of raising it. Try adding this at the top of your code: from exchangelib.services import GetItem
from exchangelib.errors import ErrorAccessDenied
GetItem.ERRORS_TO_CATCH_IN_RESPONSE += (ErrorAccessDenied,) This should result in the private items being returned as If this works for you, I'll add a permanent fix in the code. |
Yes, that solves my issue in case that I do the loop over
But this way I have at least a workaround and can go further. Thanks |
Ah, I think I know what's going on here. We first call Then we call You can test if this is indeed the case by changing your query to only fetch non-private fields: for item in items.all().only('start', 'end', 'sensitivity').order_by('start'):
print(item.start, item.end, item.sensitivity) Finally, you're getting the |
Oh yes, that did the final trick! |
Great, thanks for the clarification! I'm not sure how to make a more general fix where public_items = some_folder.exclude(sensitivity='Private')
private_items = some_folder.filter(sensitivity='Private').only(list_of_public_fields) But I have no idea which fields on a private item will throw |
I think I'm having the same issue when looping over public and private calendaritems when doing this:
Is it possible to skip the private items or use something like a filter/exclude with account.calendar.view? |
My previous comment in this thread describes how to filter private and public items. Unfortunately, you cannot combine view() with filter(), so you'll have to do this in two steps: private_items = []
public_items = []
for m in a.calendar.view(start=start, end=end).only('sensitivity'):
if m.sensitivity == 'Private':
private_items.append(m)
elif m.sensitivity == 'Normal':
public_items.append(m)
full_public_items = list(a.fetch(public_items))
# May need to select public-only fields to avoid errors
full_private_items = list(a.fetch(private_items, only_fields=[...])) |
We really need a list of private fields before we can work on this issue. I cannot reproduce locally. If you stumble across this issue, try running this on a shared calendar that contains private items: from exchangelib import Account
from exchangelib.errors import ErrorAccessDenied
a = Account(...)
for f in a.calendar.allowed_item_fields(version=a.version):
try:
a.calendar.filter(sensitivity='Private').only(f.name)[0]
except ErrorAccessDenied:
print(f.name, 'is a private field') |
Hi,
maybe I tried it the wrong way around, maybe I just stuck somewhere. However, I try to connect to an exchange server in order to extract several calendars.
In general this works, thanks to your great tool, but now I try the following:
I have a generic user, say "generic" which can access others calendars whenever they grant this user access within Outlook.
This works until a user sets an appointment to "private", which shouldn't be a huge problem but...
...
I tried to dive into the code but it looks as if exchangelib tries to inspect the elements in the queryset too much and fails while creating the iterator.
Thus I found no way to circumvent that problem but rewriting the services-module (didn't do that yet).
Is there anything I missed yet? Or a better way to handle this?
Thanks in advance
Thomas
The text was updated successfully, but these errors were encountered: