コード例 #1
0
class CancelLDAPLogin(AbstractPlugin):
    def __init__(self, data, context):
        super(AbstractPlugin, self).__init__()
        self.data = data
        self.context = context
        self.logger = self.get_logger()
        self.message_code = self.get_message_code()
        self.ldap_login = ExecuteCancelLDAPLogin()
        self.sssd_authentication = ExecuteCancelSSSDAuthentication()
        self.ad_authentication = ExecuteCancelSSSDAdAuthentication()
        self.registration = Registration()
        self.config = configparser.ConfigParser()
        self.ahenk_conf_path = "/etc/ahenk/ahenk.conf"

    def handle_task(self):
        directory_type = "LDAP"
        try:
            if self.is_exist("/etc/ahenk/ad_info"):
                directory_type = "AD"
            if directory_type == "LDAP":
                self.sssd_authentication.cancel()
            else:
                self.ad_authentication.cancel()

            self.config.read(self.ahenk_conf_path)
            if self.config.has_section('MACHINE'):
                user_disabled = self.config.get("MACHINE", "user_disabled")
                self.logger.info('User disabled value:' + str(user_disabled))
                if user_disabled != 'false':
                    self.logger.info('Enable Users')

                    self.registration.enable_local_users()
                    self.config.set('MACHINE', 'user_disabled', 'false')

                    with open(self.ahenk_conf_path, 'w') as configfile:
                        self.logger.info('Opening config file ')
                        self.config.write(configfile)
                        self.logger.info('User disabled value FALSE')
                    configfile.close()
                else:
                    self.logger.info('Local users already enabled')

            self.context.create_response(
                code=self.message_code.TASK_PROCESSED.value,
                message=
                '{0} kullanıcısı ile oturum açabilme başarıyla iptal edildi.'.
                format(directory_type),
                content_type=self.get_content_type().APPLICATION_JSON.value)
        except Exception as e:
            self.logger.error(str(e))
            self.context.create_response(
                code=self.message_code.TASK_ERROR.value,
                message=
                '{0} kullanıcısı ile oturum açabilme iptal edilirken hata oluştu.: {1}'
                .format(directory_type, str(e)))
コード例 #2
0
 def __init__(self, data, context):
     super(AbstractPlugin, self).__init__()
     self.data = data
     self.context = context
     self.logger = self.get_logger()
     self.message_code = self.get_message_code()
     self.ldap_login = ExecuteCancelLDAPLogin()
     self.sssd_authentication = ExecuteCancelSSSDAuthentication()
     self.ad_authentication = ExecuteCancelSSSDAdAuthentication()
     self.registration = Registration()
     self.config = configparser.ConfigParser()
     self.ahenk_conf_path = "/etc/ahenk/ahenk.conf"
コード例 #3
0
ファイル: ahenkd.py プロジェクト: tncyclk/ahenk
 def init_registration():
     """ docstring"""
     registration = Registration()
     Scope.get_instance().set_registration(registration)
     return registration