You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
configuration = get_configuration()
for user in list_users_from_graph_api():
user_account = Account(
primary_smtp_address=user.get("attributes", {}).get("mail"),
config=configuration,
access_type=IMPERSONATION,
)
When trying to create an Account object for users pulled from the MS Graph API, we're getting a stack trace like:
File "/workspaces/elastic_connectors/connectors/sources/outlook.py", line 451, in get_user_accounts
user_account = Account(
File "/workspaces/elastic_connectors/lib/python3.10/site-packages/exchangelib/account.py", line 205, in __init__
self.version = self.protocol.version.copy()
File "/workspaces/elastic_connectors/lib/python3.10/site-packages/exchangelib/protocol.py", line 480, in version
self.config.version = Version.guess(self, api_version_hint=self.api_version_hint)
File "/workspaces/elastic_connectors/lib/python3.10/site-packages/exchangelib/version.py", line 206, in guess
raise TransportError(f"No valid version headers found in response ({e!r})")
exchangelib.errors.TransportError: No valid version headers found in response (ErrorNonExistentMailbox('The SMTP address has no mailbox associated with it.'))
Upon further investigation, it seems that this is happening because the graph API returns all users, active and disabled. But if a user has "accountEnabled": false, attempts to retrieve their mailbox raises errors.
To Reproduce
create a User in your azure portal
take note of the user's email address
un-check the box for the user's "Account Enabled" setting
wait a few minutes
create an Account() object with exchangelib, using the disabled user's email address
get a TransportError
Expected behavior
If only enabled users are supported for an Account object, I'd expect to see that in the docstring, or a note that this type of error might be raised for a disabled user.
Otherwise, I'd expect the Account object to initialize successfully, and just represent a disabled account.
Additional context
Python 3.11
exchangelib 5.4.0
The text was updated successfully, but these errors were encountered:
Thanks for the report. It's been this way for many years, and I think at this point too much code depends on Account() throwing ErrorNonExistentMailbox if the server does not know the email address.
It's not possible to know whether the reason for the exception is that the account is disabled, but feel free to suggest a better wording for the docsting.
Describe the bug
Reported in elastic/connectors#2931
Psudocode:
When trying to create an
Account
object for users pulled from the MS Graph API, we're getting a stack trace like:Upon further investigation, it seems that this is happening because the graph API returns all users, active and disabled. But if a user has
"accountEnabled": false
, attempts to retrieve their mailbox raises errors.To Reproduce
Account()
object with exchangelib, using the disabled user's email addressTransportError
Expected behavior
If only enabled users are supported for an Account object, I'd expect to see that in the docstring, or a note that this type of error might be raised for a disabled user.
Otherwise, I'd expect the Account object to initialize successfully, and just represent a disabled account.
Additional context
Python 3.11
exchangelib 5.4.0
The text was updated successfully, but these errors were encountered: