From 1e779610628631d150a852ae847a856d9db0354a Mon Sep 17 00:00:00 2001 From: Erik Cederstrand Date: Mon, 13 May 2024 20:00:04 +0200 Subject: [PATCH] Only allow values on the DistinguishedFolderId field if we recognize the ID. Refs #1301 --- exchangelib/services/common.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exchangelib/services/common.py b/exchangelib/services/common.py index 40684d96..08d3fabf 100644 --- a/exchangelib/services/common.py +++ b/exchangelib/services/common.py @@ -979,4 +979,8 @@ def parse_folder_elem(elem, folder): # Not all servers support fetching the DistinguishedFolderId field. Add it back here. if folder._distinguished_id and not res._distinguished_id: res._distinguished_id = folder._distinguished_id + # Some servers return folders in a FindFolder result that have a DistinguishedFolderId element that the same server + # cannot handle in a GetFolder request. Only set the DistinguishedFolderId field if we recognize the ID. + elif res._distinguished_id and not folder.DISTINGUISHED_FOLDER_ID: + res._distinguished_id = None return res