develop
Самоукин Алексей 14年前
コミット b43f8ca03b

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

読み込み中…
キャンセル
保存