Browse Source

Bugfix

tags/2.2.0.0
Самоукин Алексей 11 years ago
parent
commit
b43f8ca03b
2 changed files with 32 additions and 9 deletions
  1. +0
    -0
      LICENSE
  2. +32
    -9
      pym/cl_ldap.py

LICENCE → LICENSE View File


+ 32
- 9
pym/cl_ldap.py View File

@@ -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


Loading…
Cancel
Save