remove class ldapProfile

master
Самоукин Алексей 14 years ago
parent 4d0fea7f7a
commit 66adb5dc5e

@ -2178,64 +2178,6 @@ class utfBin:
resS = reVar.search(textProfileTmp)
return textProfileTmp
class ldapProfile():
"""Работа с LDAP сервером для профилей"""
# Соединение с LDAP сервером
conLdap = False
def getLDAPDataInConfig(self):
"""Получение имени LDAP сервера и DN пользователей под пользователем"""
fileName = "/etc/ldap.conf"
serverName = ""
usersDN = ""
bindDN = ""
bindPW = ""
strServer = ("host","HOST")
lenStrServer = len(strServer[0])
strDN = ("nss_base_passwd","NSS_BASE_PASSWD")
lenStrDN = len(strDN[0])
strBindDN = ("binddn", "BINDDN")
lenStrBindDN = len(strBindDN[0])
strBindPW = ("bindpw", "BINDPW")
lenStrBindPW = len(strBindPW[0])
splList = (" ", "\t")
try:
for i in open(fileName):
if not serverName and\
filter(lambda x: i.startswith(x),strServer) and\
len(i)>lenStrServer:
spl = i[lenStrServer]
if spl in splList:
serverName = i.rpartition(spl)[2].strip()
if not bindDN and\
filter(lambda x: i.startswith(x),strBindDN) and\
len(i)>lenStrBindDN:
spl = i[lenStrBindDN]
if spl in splList:
bindDN = i.rpartition(spl)[2].strip()
if not bindPW and\
filter(lambda x: i.startswith(x),strBindPW) and\
len(i)>lenStrBindPW:
spl = i[lenStrBindPW]
if spl in splList:
bindPW = i.rpartition(spl)[2].strip()
if not usersDN and filter(lambda x: i.startswith(x), strDN) and\
len(i)>lenStrDN:
spl = i[lenStrDN]
if spl in splList:
usersDN = i.rpartition(spl)[2].partition('?')[0].strip()
if serverName and usersDN and bindDN and bindPW:
break
except:
return ()
if serverName and usersDN and bindDN and bindPW:
return (serverName, usersDN, bindDN, bindPW)
else:
return ()
def getUserDataInLDAP(self, userName):
"""Получаем домашнюю директорию пользователя из LDAP"""
if not self.conLdap:
@ -2267,7 +2209,7 @@ class ldapProfile():
return ""
class profile(_file, _terms, xmlShare, ldapProfile):
class profile(_file, _terms, xmlShare):
"""Класс для работы с профилями
На вход 2 параметра: объект хранения переменных, имя сервиса - не
@ -2806,11 +2748,17 @@ class profile(_file, _terms, xmlShare, ldapProfile):
создает и заполняет переменные на основе этого файла
Используеться совместно c funcIni
"""
# Выходим если есть предыдущие ошибки
if self.getError():
return False
# получить объект ini файла
config = cl_base.iniParser(iniFileName)
# получаем все секции из конфигурационного файла
allsect = config.getAllSectionNames()
if not allsect:
if self.getError():
# Очистка ошибки
_error.error = []
isLoadVarsIni = False
return isLoadVarsIni
# Заполняем переменные для funcIni
@ -2842,7 +2790,6 @@ class profile(_file, _terms, xmlShare, ldapProfile):
print _("template variable 'ur_login' is empty")
cl_base.exit(1)
import pwd
flagFoundUser = False
try:
pwdObj = pwd.getpwnam(userName)
uid = pwdObj.pw_uid
@ -2850,17 +2797,10 @@ class profile(_file, _terms, xmlShare, ldapProfile):
homeDir = pwdObj.pw_dir
flagFoundUser = True
except:
data = self.getUserDataInLDAP(userName)
if data:
uid, gid, homeDir = data
flagFoundUser = True
else:
flagFoundUser = True
if not flagFoundUser:
print _("error in profile %s")%nameProfile
print _("error profile term %s")%str(funTxt)
print _("Can not found user %s")%str(userName)
cl_base.exit(1)
print _("error in profile %s")%nameProfile
print _("error profile term %s")%str(funTxt)
print _("Can not found user %s")%str(userName)
cl_base.exit(1)
pathConfig = os.path.join(homeDir, ".calculate")
fileConfig = os.path.join(pathConfig,"ini.env")
# Создаем директорию

Loading…
Cancel
Save