コード例 #1
0
    def sync_users(self, users):
        if users:
            total = len(users)
            successful = 0
            failed = 0

            self.stdout.write(
                "Attempting to synchronize {} accounts to LDAP".format(total))
            for user in users:
                self.stdout.write("Synchronizing '{}({})'...".format(
                    user, user.id),
                                  ending='')
                update_ldap_account(user, create=True)
                ldap_account = get_ldap_account_safely(user)

                if ldap_account.synchronized:
                    self.stdout.write(self.style.SUCCESS(' Success!'))
                    successful = successful + 1
                else:
                    self.stdout.write(self.style.ERROR(' Error'))
                    self.stdout.write(
                        self.style.NOTICE(ldap_account.ldap_error_message))
                    failed = failed + 1
            self.stdout.write(
                "{}/{} accounts synchronized to LDAP, {} failures".format(
                    successful, total, failed))

        else:
            self.stdout.write(
                "No accounts synchronized, to force synchronization use the 'force' argument"
            )
コード例 #2
0
def user_pre_delete(**kwargs):
    """
    Delete users's LDAP account.
    """
    user = kwargs['instance']
    ldap_account = get_ldap_account_safely(user)
    if ldap_account:
        delete_ldap_account(ldap_account)
コード例 #3
0
ファイル: signals.py プロジェクト: nadineproject/nadine
def user_pre_delete(**kwargs):
    """
    Delete users's LDAP account.
    """
    user = kwargs['instance']
    ldap_account = get_ldap_account_safely(user)
    if ldap_account:
        delete_ldap_account(ldap_account)
コード例 #4
0
ファイル: syncldapusers.py プロジェクト: nadineproject/nadine
    def sync_users(self, users):
        if users:
            total = len(users)
            successful = 0
            failed = 0

            self.stdout.write("Attempting to synchronize {} accounts to LDAP".format(total))
            for user in users:
                self.stdout.write("Synchronizing '{}({})'...".format(user, user.id), ending='')
                update_ldap_account(user, create=True)
                ldap_account = get_ldap_account_safely(user)

                if ldap_account.synchronized:
                    self.stdout.write(self.style.SUCCESS(' Success!'))
                    successful = successful + 1
                else:
                    self.stdout.write(self.style.ERROR(' Error'))
                    self.stdout.write(self.style.NOTICE(ldap_account.ldap_error_message))
                    failed = failed + 1
            self.stdout.write("{}/{} accounts synchronized to LDAP, {} failures".format(successful, total, failed))

        else:
            self.stdout.write("No accounts synchronized, to force synchronization use the 'force' argument")