浏览代码

HUE-1078 [useradmin] LDAP debug logging

Michalis Kongtongk 10 年之前
父节点
当前提交
101be27f8e

+ 4 - 1
apps/useradmin/src/useradmin/ldap_access.py

@@ -111,7 +111,10 @@ class LdapConnection(object):
     else:
       ldap.set_option(ldap.OPT_REFERRALS, 0)
 
-    self.ldap_handle = ldap.initialize(ldap_url)
+    if ldap_config.DEBUG.get():
+      ldap.set_option(ldap.OPT_DEBUG_LEVEL, ldap_config.DEBUG_LEVEL.get())
+
+    self.ldap_handle = ldap.initialize(uri=ldap_url, trace_level=ldap_config.TRACE_LEVEL.get())
 
     if bind_user is not None:
       try:

+ 10 - 0
desktop/conf.dist/hue.ini

@@ -269,6 +269,16 @@
     # Whether or not to follow referrals
     ## follow_referrals=false
 
+    # Enable python-ldap debugging.
+    ## debug=false
+
+    # Sets the debug level within the underlying LDAP C lib.
+    ## debug_level=255
+
+    # Possible values for trace_level are 0 for no logging, 1 for only logging the method calls with arguments,
+    # 2 for logging the method calls with arguments and the complete results and 9 for also logging the traceback of method calls.
+    ## trace_level=0
+
     [[[users]]]
 
       # Base filter for searching for users

+ 10 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -278,6 +278,16 @@
     # Whether or not to follow referrals
     ## follow_referrals=false
 
+    # Enable python-ldap debugging.
+    ## debug=false
+
+    # Sets the debug level within the underlying LDAP C lib.
+    ## debug_level=255
+
+    # Possible values for trace_level are 0 for no logging, 1 for only logging the method calls with arguments,
+    # 2 for logging the method calls with arguments and the complete results and 9 for also logging the traceback of method calls.
+    ## trace_level=0
+
     [[[users]]]
 
       # Base filter for searching for users

+ 13 - 0
desktop/core/src/desktop/conf.py

@@ -501,6 +501,19 @@ LDAP = ConfigSection(
       type=coerce_bool,
       default=False),
 
+    DEBUG = Config("debug",
+      type=coerce_bool,
+      default=False,
+      help=_("Set to a value to enable python-ldap debugging.")),
+    DEBUG_LEVEL = Config("debug_level",
+      default=255,
+      type=int,
+      help=_("Sets the debug level within the underlying LDAP C lib.")),
+    TRACE_LEVEL = Config("trace_level",
+      default=0,
+      type=int,
+      help=_("Possible values for trace_level are 0 for no logging, 1 for only logging the method calls with arguments,"
+             "2 for logging the method calls with arguments and the complete results and 9 for also logging the traceback of method calls.")),
 
     LDAP_SERVERS = UnspecifiedConfigSection(
       key="ldap_servers",