Пример #1
0
    def query(self, filter=None, params=None, skip_ad=False):
        filter = filter or []
        params = params or {}
        single = params.pop('single', False)

        # Optimize filtering on directory name and domain name
        origin_directory = pop_filter(filter, 'origin.directory')
        origin_domain = pop_filter(filter, 'origin.domain')
        exclude_from_filter(filter, 'origin')

        for d in self.context.get_searched_directories():
            if skip_ad and d.plugin_type == 'winbind':
                continue

            if not test_filter(origin_directory, d.name) or not test_filter(
                    origin_domain, d.domain_name):
                continue

            try:
                result = d.instance.getgrent(filter, params)
                for group in result:
                    if not group:
                        continue

                    yield annotate(group, d, 'name')
                    if single:
                        return
            except GeneratorExit:
                return
            except:
                self.context.logger.error(
                    'Directory {0} exception during group iteration'.format(
                        d.name),
                    exc_info=True)
                continue
Пример #2
0
    def query(self, filter=None, params=None, skip_ad=False):
        filter = filter or []
        params = params or {}
        single = params.pop('single', False)

        # Optimize filtering on directory name and domain name
        origin_directory = pop_filter(filter, 'origin.directory')
        origin_domain = pop_filter(filter, 'origin.domain')
        exclude_from_filter(filter, 'origin')

        for d in self.context.get_searched_directories():
            if skip_ad and d.plugin_type == 'winbind':
                continue

            if not test_filter(origin_directory, d.name) or not test_filter(origin_domain, d.domain_name):
                continue

            try:
                result = d.instance.getgrent(filter, params)
                for group in result:
                    if not group:
                        continue

                    yield annotate(group, d, 'name')
                    if single:
                        return
            except GeneratorExit:
                return
            except:
                self.context.logger.error('Directory {0} exception during group iteration'.format(d.name), exc_info=True)
                continue
Пример #3
0
    def query(self, filter=None, params=None):
        filter = filter or []
        params = params or {}
        params.pop('select', None)
        single = params.pop('single', False)

        # Optimize filtering on directory name and domain name
        origin_directory = pop_filter(filter, 'origin.directory')
        origin_domain = pop_filter(filter, 'origin.domain')
        exclude_from_filter(filter, 'origin')

        for d in self.context.get_searched_directories():
            if not test_filter(origin_directory, d.name) or not test_filter(origin_domain, d.domain_name):
                continue

            try:
                result = d.instance.getpwent(filter, params)
                for user in result:
                    resolve_primary_group(self.context, user)
                    yield fix_passwords(annotate(user, d, 'username'))
                    if single:
                        return
            except GeneratorExit:
                return
            except:
                self.context.logger.error('Directory {0} exception during account iteration'.format(d.name), exc_info=True)
                continue
Пример #4
0
    def query(self, filter=None, params=None, skip_ad=False):
        filter = filter or []
        params = params or {}
        params.pop('select', None)
        single = params.pop('single', False)

        # Optimize filtering on directory name and domain name
        origin_directory = pop_filter(filter, 'origin.directory')
        origin_domain = pop_filter(filter, 'origin.domain')
        exclude_from_filter(filter, 'origin')

        for d in self.context.get_searched_directories():
            if skip_ad and d.plugin_type == 'winbind':
                continue

            if not test_filter(origin_directory, d.name) or not test_filter(origin_domain, d.domain_name):
                continue

            try:
                result = d.instance.getpwent(filter, params)
                for user in result:
                    if not user:
                        continue

                    resolve_primary_group(self.context, user)
                    yield fix_passwords(annotate(user, d, 'username'))
                    if single:
                        return
            except GeneratorExit:
                return
            except:
                self.context.logger.error('Directory {0} exception during account iteration'.format(d.name), exc_info=True)
                continue