From b43f8ca03b8b912011705d5c1ec043048fc51810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D0=BC=D0=BE=D1=83=D0=BA=D0=B8=D0=BD=20=D0=90?= =?UTF-8?q?=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?= Date: Fri, 21 May 2010 15:19:27 +0400 Subject: [PATCH] Bugfix --- LICENCE => LICENSE | 0 pym/cl_ldap.py | 41 ++++++++++++++++++++++++++++++++--------- 2 files changed, 32 insertions(+), 9 deletions(-) rename LICENCE => LICENSE (100%) diff --git a/LICENCE b/LICENSE similarity index 100% rename from LICENCE rename to LICENSE diff --git a/pym/cl_ldap.py b/pym/cl_ldap.py index 03d9b0b..11c7851 100644 --- a/pym/cl_ldap.py +++ b/pym/cl_ldap.py @@ -65,7 +65,7 @@ class ldapUser(_error): # Подключение к LDAP conLdap = False - def getDataInLdapConf(self, bindData=False, cache=True): + def getDataInLdapConf(self, bindData=True, cache=True): """Получение данных из /etc/ldap.conf""" data = [("host",'host'), ("usersDN",'nss_base_passwd'), @@ -110,17 +110,40 @@ class ldapUser(_error): else: return {} + def getBindConnectData(self): + """Получение данных для соединения с LDAP bind пользователем""" + configdata = self.getDataInLdapConf() + if configdata: + bindDn = configdata["bindDn"][0] + bindPw = configdata["bindPw"][0] + host = configdata["host"][0] + return bindDn, bindPw, host + return False + + def getUsersDN(self): + """Получение DN пользователей""" + configdata = self.getDataInLdapConf(bindData=False) + if configdata: + usersDN = self._dictData["usersDN"][0] + return usersDN + return False + + def getGroupsDN(self): + """Получение списка DN групп""" + configdata = self.getDataInLdapConf(bindData=False) + if configdata: + groupsDNs = self._dictData["groupsDN"] + return groupsDNs + return False + def getUserLdapInfo(self, userName): """Выдаем информацию о пользователе из LDAP""" - # Получаем информацию из /etc/ldap.conf - retData = self.getDataInLdapConf(bindData=True, cache=True) - if not retData: + connectData = self.getBindConnectData() + if not connectData: return {} - bindDn = self._dictData["bindDn"][0] - bindPw = self._dictData["bindPw"][0] - host = self._dictData["host"][0] - usersDN = self._dictData["usersDN"][0] - groupsDNs = self._dictData["groupsDN"] + bindDn, bindPw, host = connectData + usersDN = self.getUsersDN() + groupsDNs = self.getGroupsDN() # Соединяемся с LDAP if not self.ldapConnect(bindDn, bindPw, host): return False