in ees_microsoft_outlook/permission_sync_command.py [0:0]
def execute(self):
"""Runs the permission indexing logic.
This method when invoked, checks the permission of the Microsoft Outlook users and update those user
permissions in the Workplace Search.
"""
self.logger.info("Starting the permission sync..")
if not self.enable_document_permission:
self.logger.warning("Exiting as the enable permission flag is set to False")
raise PermissionSyncDisabledException
# Logic to fetch users from Microsoft Exchange or Office365
if constant.CONNECTOR_TYPE_OFFICE365 in self.product_type:
office365_connection = Office365User(self.config)
users = office365_connection.get_users()
users_accounts = office365_connection.get_users_accounts(users)
elif constant.CONNECTOR_TYPE_MICROSOFT_EXCHANGE in self.product_type:
microsoft_exchange_server_connection = MicrosoftExchangeServerUser(
self.config
)
users = microsoft_exchange_server_connection.get_users()
users_accounts = microsoft_exchange_server_connection.get_users_accounts(
users
)
if len(users_accounts) >= 0:
self.logger.info(
f"Successfully fetched users accounts from the {self.product_type}"
)
else:
self.logger.info("Error while fetching users from the Active Directory")
exit()
self.remove_all_permissions(users_accounts)
for user_account in users_accounts:
self.set_permissions_to_users(user_account)