Пример #1
0
    def check_user(self, **kwargs):
        """
            Checks existence and password of a user on the users folder of the branch specified by <branch-name>
        """

        branch_name = getOptionFrom(kwargs, 'branch-name', None)
        username = getOptionFrom(kwargs, 'ldap-username')
        password = getOptionFrom(kwargs, 'password', mask=True)

        run_recipe_without_confirmation(
            self.Server.check_user,
            branch_name, username, password)
Пример #2
0
    def list_users(self, **kwargs):
        """
            Prints a list of all the users of the branch specified by <branch-name>, sorted by username
            You can filter the results (case insensitive) with the --filter=<text> option
        """

        branch_name = getOptionFrom(kwargs, 'branch-name', None)
        u_filter = getOptionFrom(kwargs, 'filter', default=None)

        users = run_recipe_without_confirmation(
            self.Server.list_users,
            branch_name,
            filter=u_filter
        )

        table = GUMTable(hrules='FRAME')
        table.from_dict_list(
            users,
            formatters={
                'name': highlighter(default='bold_yellow')
            },
            titles={
                'name': 'Username',
                'sn': 'SN'
            })
        print table.sorted('name')
Пример #3
0
    def test(self, **kwargs):
        """
            Tests that oauth instance is working as expected.

            An username and a password of an existing user has to be provided.
        """
        instance_name = getOptionFrom(kwargs, 'instance-name', default='all')
        username = getOptionFrom(kwargs, 'username')
        password = getOptionFrom(kwargs, 'password')
        oauth = self.Server

        run_recipe_without_confirmation(
            oauth.test,
            instance_name, username, password,
            stop_on_errors=False
        )
Пример #4
0
    def list_branches(self, **kwargs):
        """
            Prints a list of all the branches on the ldap server
            For each branch, a count of users and groups is displayed
        """
        branches = run_recipe_without_confirmation(
            self.Server.list_branches
        )

        table = GUMTable()
        table.from_dict_list(
            branches,
            formatters={
                'groups': get_length,
                'users': get_length
            },
            titles={
                'name': 'Name',
                'groups': 'Groups',
                'users': 'Users'
            })
        print table.sorted('name')