in ees_network_drive/permission_sync_command.py [0:0]
def execute(self):
""" Runs the permission indexing logic.
This method when invoked, checks the permission of Network Drives users and update those user
permissions in the Workplace Search.
"""
self.logger.info("Starting the permission indexing..")
if not self.enable_document_permission:
self.logger.warning('Exiting as the enable permission flag is set to False')
raise PermissionSyncDisabledException
if (self.user_mapping and os.path.exists(self.user_mapping) and os.path.getsize(self.user_mapping) > 0):
mappings = {}
with open(self.user_mapping, encoding='utf-8') as mapping_file:
try:
csvreader = csv.reader(mapping_file)
for row in csvreader:
network_drive_sid = row[0]
enterprise_search_user = row[1]
if mappings.get(enterprise_search_user):
mappings[enterprise_search_user].append(network_drive_sid)
else:
mappings[enterprise_search_user] = [network_drive_sid]
except csv.Error as e:
self.logger.exception(f"Error while reading user mapping file at the location: \
{self.user_mapping}. Error: {e}")
self.remove_all_permissions()
for key, val in mappings.items():
self.workplace_search_custom_client.add_permissions(key, val)
else:
self.logger.error(f'Could not find the users mapping file at the location: {self.user_mapping} or the file is empty. \
Please add the sid->user mappings to sync the permissions in the Enterprise Search')
raise EmptyMappingException