From 39f68f22831976e113d9c4d44ce793c24aa519e4 Mon Sep 17 00:00:00 2001 From: agahhulusi Date: Tue, 16 Mar 2021 12:25:20 +0300 Subject: [PATCH] Active Directort domain bug fixed --- src/base/logger/ahenk_logger.py | 2 +- .../execute_sssd_ad_authentication.py | 30 +++++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/base/logger/ahenk_logger.py b/src/base/logger/ahenk_logger.py index 165f440..647d3e5 100644 --- a/src/base/logger/ahenk_logger.py +++ b/src/base/logger/ahenk_logger.py @@ -53,7 +53,7 @@ class Logger(object): try: exc_type, exc_value, exc_trace_back = sys.exc_info() caller = getframeinfo(stack()[1][0]) - + message = message.decode("utf-8") if exc_type is None and exc_value is None and exc_trace_back is None: self.logger.error('[{0} {1}]\t {2}'.format(self.get_log_header(caller.filename), caller.lineno, message)) else: diff --git a/src/base/registration/execute_sssd_ad_authentication.py b/src/base/registration/execute_sssd_ad_authentication.py index 65138b8..fb4e447 100644 --- a/src/base/registration/execute_sssd_ad_authentication.py +++ b/src/base/registration/execute_sssd_ad_authentication.py @@ -139,11 +139,29 @@ class ExecuteSSSDAdAuthentication: file_default_pam.close() # Execute the commands that require for join Domain - (result_code, p_out, p_err) = self.util.execute("realm discover {}".format(domain_name.upper())) - if (result_code == 0): - self.logger.info("Realm Discover komutu başarılı") - else: - self.logger.error("Realm Discover komutu başarısız : " + str(p_err)) + # (result_code, p_out, p_err) = self.util.execute("realm discover {}".format(domain_name.upper())) + # if (result_code == 0): + # self.logger.info("Realm Discover komutu başarılı") + # else: + # self.logger.error("Realm Discover komutu başarısız : " + str(p_err)) + + self.domain_try_counter2 = 0 + try: + while (True): + self.domain_try_counter2 = self.domain_try_counter2 + 1 + if (self.domain_try_counter2 == 10): + break + else: + (result_code, p_out, p_err) = self.util.execute("realm discover {}".format(domain_name.upper())) + if (result_code == 0): + self.logger.info("Realm Discover komutu başarılı") + break + else: + self.logger.error("Realm Discover komutu başarısız : ") + time.sleep(2) + except Exception as e: + self.logger.error(e) + self.logger.info("AD DİSCOVER Login işlemi esnasında hata oluştu.") self.domain_try_counter = 0 @@ -157,7 +175,7 @@ class ExecuteSSSDAdAuthentication: self.logger.info("Realm Join komutu başarılı") break else: - self.logger.error("Realm Join komutu başarısız : " + str(p_err)) + self.logger.error("Realm Join komutu başarısız : ") time.sleep(2) # Configure sssd template