def retrieve_permission()

in ees_network_drive/files.py [0:0]


    def retrieve_permission(self, smb_connection, service_name, file_path):
        """This method is used to retrieve permission from Network Drives.
            :param smb_connection: SMB connection object
            :param service_name: name of the drive
            :param file_path: Path of the Network Drives
            :returns: hash of allow and deny permissions lists
        """
        try:
            security_info = smb_connection.getSecurity(service_name, rf'{file_path}')
        except Exception as exception:
            self.logger.exception(f"Unknown error while fetching permission details for file {file_path}.\
            Error {exception}")
            return [], []
        allow_users = []
        deny_users = []
        if security_info.dacl:
            aces = security_info.dacl.aces
            for ace in (aces or []):
                sid = str(ace.sid)
                if ace.type == ACCESS_ALLOWED_TYPE or ace.mask == ACCESS_MASK_DENIED_WRITE_PERMISSION:
                    allow_users.append(sid)
                if (ace.type == ACCESS_DENIED_TYPE and ace.mask != ACCESS_MASK_DENIED_WRITE_PERMISSION) or \
                        ace.mask == ACCESS_MASK_ALLOWED_WRITE_PERMISSION:
                    deny_users.append(sid)
                if not fetch_users_from_csv_file(self.user_mapping, self.logger).get(sid):
                    self.logger.warning(f"No mapping found for sid:{sid} in csv file. \
                        Please add the sid->user mapping for the {sid} and rerun the \
                        permission_sync_command to sync the user mappings.")
        return {'allow': allow_users, 'deny': deny_users}