|
|
|
@ -1343,11 +1343,9 @@ class servUnix(shareLdap):
|
|
|
|
|
comment = options['c']
|
|
|
|
|
if res[0][0][1].has_key('displayName'):
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'displayName', comment),
|
|
|
|
|
(ldap.MOD_REPLACE, 'gecos', comment),
|
|
|
|
|
(ldap.MOD_REPLACE, 'cn', comment)]
|
|
|
|
|
else:
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'gecos', comment),
|
|
|
|
|
(ldap.MOD_REPLACE, 'cn', comment)]
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'cn', comment)]
|
|
|
|
|
# Изменяем оболочку пользователя
|
|
|
|
|
if options.has_key('s'):
|
|
|
|
|
shell = options['s']
|
|
|
|
@ -1666,6 +1664,57 @@ class servMail(shareLdap):
|
|
|
|
|
# создаем объект сервиса Unix
|
|
|
|
|
self.servUnixObj = servUnix()
|
|
|
|
|
|
|
|
|
|
@adminConnectLdap
|
|
|
|
|
def addGroupMailServer(self, groupName, options):
|
|
|
|
|
"""Добавляет группу пользователей Mail"""
|
|
|
|
|
pass
|
|
|
|
|
#resGroup = self.searchGroupToMail(groupName)
|
|
|
|
|
#resUser =
|
|
|
|
|
|
|
|
|
|
def modUserMailPasswd(self, userName, options):
|
|
|
|
|
"""Устанавливает пароль Mail пользователя и меняет его опции"""
|
|
|
|
|
res = self.searchMailUser(userName)
|
|
|
|
|
if not res:
|
|
|
|
|
self.printERROR(_("User") + " " + str(userName) + " " +\
|
|
|
|
|
_("not found in Mail service") + " ...")
|
|
|
|
|
return False
|
|
|
|
|
# Изменяемые аттрибуты пользователя
|
|
|
|
|
modAttrs = []
|
|
|
|
|
# Включаем пользователя
|
|
|
|
|
if options.has_key('u'):
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'accountStatus', "active")]
|
|
|
|
|
# Выключаем пользователя
|
|
|
|
|
elif options.has_key('l'):
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'accountStatus', "passive")]
|
|
|
|
|
if not options:
|
|
|
|
|
optPasswd = {"p":""}
|
|
|
|
|
userPwd = self.getUserPassword(optPasswd, "p", False)
|
|
|
|
|
if userPwd == False:
|
|
|
|
|
return False
|
|
|
|
|
userPwdHash =\
|
|
|
|
|
self.execProg("slappasswd -s %s -h %s"\
|
|
|
|
|
%(userPwd, self.userCrypt))
|
|
|
|
|
if res[0][0][1].has_key('userPassword'):
|
|
|
|
|
modAttrs.append((ldap.MOD_REPLACE, 'userPassword',
|
|
|
|
|
userPwdHash))
|
|
|
|
|
else:
|
|
|
|
|
modAttrs.append((ldap.MOD_ADD, 'userPassword',
|
|
|
|
|
userPwdHash))
|
|
|
|
|
if modAttrs:
|
|
|
|
|
DN = self.addDN("uid="+userName, self.relUsersDN)
|
|
|
|
|
if not self.modAttrsDN(DN, modAttrs):
|
|
|
|
|
return False
|
|
|
|
|
if options.has_key('l'):
|
|
|
|
|
self.printSUCCESS(_("Lock Mail user") + " " + str(userName) +\
|
|
|
|
|
" ...")
|
|
|
|
|
if options.has_key('u'):
|
|
|
|
|
self.printSUCCESS(_("Unlock Mail user") + " " +\
|
|
|
|
|
str(userName) + " ...")
|
|
|
|
|
if not options:
|
|
|
|
|
self.printSUCCESS(_("Change Mail user password") + " ...")
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def createMailDir(self, userName, uid, gid):
|
|
|
|
|
"""Создание пользовательской директории для почты"""
|
|
|
|
|
mailDir = os.path.join(self.mailLocation,userName)
|
|
|
|
@ -1676,15 +1725,52 @@ class servMail(shareLdap):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def searchMailUser(self, userName):
|
|
|
|
|
"""Находит пользователя сервиса Unix"""
|
|
|
|
|
"""Находит пользователя сервиса Mail по имени"""
|
|
|
|
|
resSearch = self.searchLdapDN(userName, self.relUsersDN, "uid")
|
|
|
|
|
return resSearch
|
|
|
|
|
|
|
|
|
|
def searchUserToMail(self, mail):
|
|
|
|
|
"""Находит пользователя по почтовому адресу в сервисе Mail"""
|
|
|
|
|
resSearch = self.searchLdapDN(mail, self.relUsersDN, "mail")
|
|
|
|
|
if not resSearch:
|
|
|
|
|
resSearch = self.searchLdapDN(mail, self.relUsersDN,
|
|
|
|
|
"mailAlternateAddress")
|
|
|
|
|
return resSearch
|
|
|
|
|
|
|
|
|
|
def searchGroupToMail(self, mail):
|
|
|
|
|
"""Находит группу по ее почтовому адресу"""
|
|
|
|
|
resSearch = self.searchLdapDN(mail, self.relGroupsDN, "mail")
|
|
|
|
|
if not resSearch:
|
|
|
|
|
resSearch = self.searchLdapDN(mail, self.relGroupsDN,
|
|
|
|
|
"mailAlternateAddress")
|
|
|
|
|
return resSearch
|
|
|
|
|
|
|
|
|
|
@adminConnectLdap
|
|
|
|
|
def addUserMailServer(self, userName, options):
|
|
|
|
|
"""Добавляет почтового пользователя в LDAP-сервер"""
|
|
|
|
|
#Проверяем альтернативные почтовые адреса
|
|
|
|
|
modAttrs = []
|
|
|
|
|
if options.has_key('a'):
|
|
|
|
|
altMails = options['a'].split(",")
|
|
|
|
|
for altMail in altMails:
|
|
|
|
|
if "@" in altMail:
|
|
|
|
|
mail = altMail
|
|
|
|
|
else:
|
|
|
|
|
mail = "%s@%s.%s" %(altMail,
|
|
|
|
|
self.clVars.Get("net_host"),
|
|
|
|
|
self.clVars.Get("sys_domain"))
|
|
|
|
|
if self.searchUserToMail(mail) or\
|
|
|
|
|
self.searchGroupToMail(mail):
|
|
|
|
|
self.printERROR(_("Alternate email address") + ": " +\
|
|
|
|
|
str(mail) + " " + _("found in Mail service") + " ...")
|
|
|
|
|
return False
|
|
|
|
|
modAttrs.append((ldap.MOD_ADD, 'mailAlternateAddress', mail))
|
|
|
|
|
resUnix = self.servUnixObj.searchUnixUser(userName)
|
|
|
|
|
resPwd = self.servUnixObj.searchPasswdUser(userName)
|
|
|
|
|
# Пароль пользователя почты
|
|
|
|
|
userPwd = self.getUserPassword(options, "p", "P")
|
|
|
|
|
if userPwd == False:
|
|
|
|
|
return False
|
|
|
|
|
if not (resUnix or resPwd):
|
|
|
|
|
if options.has_key('f'):
|
|
|
|
|
# Добавим пользователя LDAP
|
|
|
|
@ -1694,15 +1780,21 @@ class servMail(shareLdap):
|
|
|
|
|
optUnix['g'] = options['g']
|
|
|
|
|
# Полное имя пользователя
|
|
|
|
|
if options.has_key('c'):
|
|
|
|
|
optUnix['с'] = options['c']
|
|
|
|
|
optUnix['c'] = options['c']
|
|
|
|
|
if not self.servUnixObj.addUserUnixServer(userName, optUnix):
|
|
|
|
|
return False
|
|
|
|
|
resUnix = self.servUnixObj.searchUnixUser(userName)
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(_("Not found user") + " " + str(userName) +\
|
|
|
|
|
" " + _("in unix service" + " ..."))
|
|
|
|
|
" " + _("in Unix service" + " ..."))
|
|
|
|
|
return False
|
|
|
|
|
if self.searchMailUser(userName):
|
|
|
|
|
self.printERROR(_("User exists in LDAP"))
|
|
|
|
|
self.printERROR(_("User exists in Mail service"))
|
|
|
|
|
return False
|
|
|
|
|
elif self.searchUserToMail(userName) or\
|
|
|
|
|
self.searchGroupToMail(userName):
|
|
|
|
|
self.printERROR(_("User name") + ": " + str(userName) + " " +\
|
|
|
|
|
_("is found in Mail service") + " ...")
|
|
|
|
|
return False
|
|
|
|
|
self.clVars.Set("soft_ldap_user_login", userName)
|
|
|
|
|
#Полное имя пользователя
|
|
|
|
@ -1710,13 +1802,9 @@ class servMail(shareLdap):
|
|
|
|
|
if options.has_key('c'):
|
|
|
|
|
fullNameUser = options['c']
|
|
|
|
|
else:
|
|
|
|
|
resUnix = self.servUnixObj.searchUnixUser(userName)
|
|
|
|
|
if resUnix and resUnix[0][0][1].has_key('gecos'):
|
|
|
|
|
fullNameUser = resUnix[0][0][1]['gecos'][0]
|
|
|
|
|
if resUnix and resUnix[0][0][1].has_key('cn'):
|
|
|
|
|
fullNameUser = resUnix[0][0][1]['cn'][0]
|
|
|
|
|
self.clVars.Set("soft_ldap_user_full_name",fullNameUser)
|
|
|
|
|
userPwd = self.getUserPassword(options, "p", "P")
|
|
|
|
|
if userPwd == False:
|
|
|
|
|
return False
|
|
|
|
|
if not userPwd:
|
|
|
|
|
userPwdHash = "crypt{xxx}"
|
|
|
|
|
else:
|
|
|
|
@ -1747,10 +1835,14 @@ class servMail(shareLdap):
|
|
|
|
|
self.printERROR(_("Not found uid and gid user"))
|
|
|
|
|
return False
|
|
|
|
|
self.createMailDir(userName, uid, gid)
|
|
|
|
|
print "OK"
|
|
|
|
|
#Добавляем альтернативные почтовые адреса
|
|
|
|
|
if options.has_key('a') and modAttrs:
|
|
|
|
|
DN = self.addDN("uid="+userName, self.relUsersDN)
|
|
|
|
|
if not self.modAttrsDN(DN, modAttrs):
|
|
|
|
|
return False
|
|
|
|
|
self.printSUCCESS(_("Add user in mail service") + " ...")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def setupMailServer(self, options):
|
|
|
|
|
"""Начальная настройка Mail сервиса"""
|
|
|
|
|
# Принудительная установка
|
|
|
|
@ -1958,7 +2050,7 @@ class servSamba(shareLdap):
|
|
|
|
|
optUnix['g'] = options['g']
|
|
|
|
|
# Полное имя пользователя
|
|
|
|
|
if options.has_key('c'):
|
|
|
|
|
optUnix['с'] = options['c']
|
|
|
|
|
optUnix['c'] = options['c']
|
|
|
|
|
if not self.servUnixObj.addUserUnixServer(userName, optUnix):
|
|
|
|
|
return False
|
|
|
|
|
if userPwd:
|
|
|
|
@ -2266,6 +2358,10 @@ class servLdap(shareLdap):
|
|
|
|
|
serv = "samba"
|
|
|
|
|
servicePaths.append(os.path.join(profilePath,serv))
|
|
|
|
|
servInstalled.append(serv)
|
|
|
|
|
if self.clVars.Get("soft_mail_setup") == "yes":
|
|
|
|
|
serv = "mail"
|
|
|
|
|
servicePaths.append(os.path.join(profilePath,serv))
|
|
|
|
|
servInstalled.append(serv)
|
|
|
|
|
return (servicePaths, servInstalled)
|
|
|
|
|
|
|
|
|
|
@adminConnectLdap
|
|
|
|
@ -2786,21 +2882,28 @@ group already exists")
|
|
|
|
|
'longOption':"comment",
|
|
|
|
|
'optVal':"COMMENT",
|
|
|
|
|
'helpChapter':_("Service Unix options"),
|
|
|
|
|
'help':_("set the GECOS field for the new user account")
|
|
|
|
|
'help':_("set the COMMENT field for the new user account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"c",
|
|
|
|
|
'longOption':"comment",
|
|
|
|
|
'optVal':"COMMENT",
|
|
|
|
|
'helpChapter':_("Service Samba options"),
|
|
|
|
|
'help':_("set the GECOS field for the new unix account")
|
|
|
|
|
'help':_("set the COMMENT field for the new unix account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"a",
|
|
|
|
|
'longOption':"alt-emails",
|
|
|
|
|
'optVal':"ALT_EMAILS",
|
|
|
|
|
'helpChapter':_("Service Mail options"),
|
|
|
|
|
'help':_("set alternate email addresses for the new mail account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"c",
|
|
|
|
|
'longOption':"comment",
|
|
|
|
|
'optVal':"COMMENT",
|
|
|
|
|
'helpChapter':_("Service Mail options"),
|
|
|
|
|
'help':_("set the GECOS field for the new unix account")
|
|
|
|
|
'help':_("set the COMMENT field for the new unix account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"d",
|
|
|
|
@ -2925,7 +3028,14 @@ group already exists")
|
|
|
|
|
'longOption':"comment",
|
|
|
|
|
'optVal':"COMMENT",
|
|
|
|
|
'helpChapter':_("Service Unix options"),
|
|
|
|
|
'help':_("new value of the GECOS field")
|
|
|
|
|
'help':_("new value of the COMMENT field")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(5,),
|
|
|
|
|
'shortOption':"c",
|
|
|
|
|
'longOption':"comment",
|
|
|
|
|
'optVal':"COMMENT",
|
|
|
|
|
'helpChapter':_("Service Mail options"),
|
|
|
|
|
'help':_("new value of the COMMENT field")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(5,),
|
|
|
|
|
'shortOption':"d",
|
|
|
|
@ -3069,7 +3179,7 @@ group already exists")
|
|
|
|
|
'help':pcs(" samba", self.column_width,
|
|
|
|
|
"samba " + servName, self.consolewidth-self.column_width)
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,6,),
|
|
|
|
|
{'progAccess':(0,3,5,6,7,),
|
|
|
|
|
'helpChapter':_("Services"),
|
|
|
|
|
'help':pcs(" mail", self.column_width,
|
|
|
|
|
"mail " + servName, self.consolewidth-self.column_width)
|
|
|
|
|