|
|
|
@ -1340,7 +1340,7 @@ class servUnix(shareLdap):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
@adminConnectLdap
|
|
|
|
|
def addUserUnixServer(self,userName,options, printSuccess=True):
|
|
|
|
|
def addUserUnixServer(self,userName,options,printSuccess=True,pwd=False):
|
|
|
|
|
"""Добавляет Unix пользователя в LDAP-сервер"""
|
|
|
|
|
if self.searchUnixUser(userName):
|
|
|
|
|
self.printERROR(_("User exists in Unix service"))
|
|
|
|
@ -1437,8 +1437,10 @@ class servUnix(shareLdap):
|
|
|
|
|
_("Group name %s is found in Unix serivce")%str(userName)+\
|
|
|
|
|
" ...")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
userPwd = self.getUserPassword(options, "p", "P")
|
|
|
|
|
if pwd:
|
|
|
|
|
userPwd = pwd
|
|
|
|
|
else:
|
|
|
|
|
userPwd = self.getUserPassword(options, "p", "P")
|
|
|
|
|
if userPwd == False:
|
|
|
|
|
return False
|
|
|
|
|
if not userPwd:
|
|
|
|
@ -1983,7 +1985,7 @@ service"))
|
|
|
|
|
" ...")
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def modUserUnixPasswd(self, userName, options):
|
|
|
|
|
def modUserUnixPasswd(self, userName, options, pwd=False):
|
|
|
|
|
"""Устанавливает пароль LDAP пользователя и меняет его опции"""
|
|
|
|
|
res = self.searchUnixUser(userName)
|
|
|
|
|
if not res:
|
|
|
|
@ -2009,7 +2011,10 @@ service"))
|
|
|
|
|
modAttrs += [(ldap.MOD_REPLACE, 'shadowExpire', "1")]
|
|
|
|
|
if not options:
|
|
|
|
|
optPasswd = {"p":""}
|
|
|
|
|
userPwd = self.getUserPassword(optPasswd, "p", False)
|
|
|
|
|
if pwd:
|
|
|
|
|
userPwd = pwd
|
|
|
|
|
else:
|
|
|
|
|
userPwd = self.getUserPassword(optPasswd, "p", False)
|
|
|
|
|
if userPwd == False:
|
|
|
|
|
return False
|
|
|
|
|
userPwdHash =\
|
|
|
|
@ -2978,27 +2983,23 @@ in Unix service ...") %str(primaryMail))
|
|
|
|
|
return False
|
|
|
|
|
flagCreateUnixUser = False
|
|
|
|
|
if not (resUnix or resPwd):
|
|
|
|
|
if options.has_key('f'):
|
|
|
|
|
flagCreateUnixUser = True
|
|
|
|
|
# Добавим пользователя LDAP
|
|
|
|
|
optUnix = {}
|
|
|
|
|
# Группа пользователя
|
|
|
|
|
if options.has_key('g'):
|
|
|
|
|
optUnix['g'] = options['g']
|
|
|
|
|
# Полное имя пользователя
|
|
|
|
|
if options.has_key('c'):
|
|
|
|
|
optUnix['c'] = options['c']
|
|
|
|
|
# Cделаем пользователя видимым
|
|
|
|
|
optUnix['v'] = ""
|
|
|
|
|
if not self.servUnixObj.addUserUnixServer(userName, optUnix,
|
|
|
|
|
False):
|
|
|
|
|
return False
|
|
|
|
|
resUnix = self.servUnixObj.searchUnixUser(userName)
|
|
|
|
|
else:
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("User %s is not found in Unix service") % str(userName)+\
|
|
|
|
|
" ...")
|
|
|
|
|
flagCreateUnixUser = True
|
|
|
|
|
# Добавим пользователя LDAP
|
|
|
|
|
optUnix = {}
|
|
|
|
|
# Группа пользователя
|
|
|
|
|
if options.has_key('g'):
|
|
|
|
|
optUnix['g'] = options['g']
|
|
|
|
|
# Полное имя пользователя
|
|
|
|
|
if options.has_key('c'):
|
|
|
|
|
optUnix['c'] = options['c']
|
|
|
|
|
# Cделаем пользователя видимым
|
|
|
|
|
optUnix['v'] = ""
|
|
|
|
|
if not self.servUnixObj.addUserUnixServer(userName, optUnix,
|
|
|
|
|
False):
|
|
|
|
|
self.printERROR (_("Can not added user")+ " " +\
|
|
|
|
|
str(userName) + _(" in Unix service"))
|
|
|
|
|
return False
|
|
|
|
|
resUnix = self.servUnixObj.searchUnixUser(userName)
|
|
|
|
|
self.clVars.Set("ur_name", userName)
|
|
|
|
|
#Полное имя пользователя
|
|
|
|
|
fullNameUser = self.servUnixObj.fullNameUser
|
|
|
|
@ -3959,12 +3960,12 @@ class servSamba(shareLdap):
|
|
|
|
|
resSearch = self.servUnixObj.searchUnixUser(userName)
|
|
|
|
|
if not resSearch:
|
|
|
|
|
resSearch = self.servUnixObj.searchPasswdUser(userName)
|
|
|
|
|
# создание пользователя Unix опция f
|
|
|
|
|
if not resSearch and not options.has_key('f'):
|
|
|
|
|
self.printERROR(
|
|
|
|
|
_("User %s is not found in Unix service")%\
|
|
|
|
|
str(userName) + " ...")
|
|
|
|
|
return False
|
|
|
|
|
## создание пользователя Unix опция f
|
|
|
|
|
#if not resSearch and not options.has_key('f'):
|
|
|
|
|
#self.printERROR(
|
|
|
|
|
#_("User %s is not found in Unix service")%\
|
|
|
|
|
#str(userName) + " ...")
|
|
|
|
|
#return False
|
|
|
|
|
if self.searchSambaUser(userName):
|
|
|
|
|
self.printERROR(_("Samba user exists"))
|
|
|
|
|
return False
|
|
|
|
@ -3993,9 +3994,14 @@ class servSamba(shareLdap):
|
|
|
|
|
# Cделаем пользователя видимым
|
|
|
|
|
optUnix['v'] = ""
|
|
|
|
|
if not self.servUnixObj.addUserUnixServer(userName, optUnix,
|
|
|
|
|
False):
|
|
|
|
|
False,userPwd):
|
|
|
|
|
self.printERROR (_("Can not added user")+ " " +\
|
|
|
|
|
str(userName) + _(" in Unix service"))
|
|
|
|
|
return False
|
|
|
|
|
flagCreateUnixUser = True
|
|
|
|
|
elif userPwd:
|
|
|
|
|
if not self.servUnixObj.modUserUnixPasswd(userName, {}, userPwd):
|
|
|
|
|
return False
|
|
|
|
|
if userPwd:
|
|
|
|
|
textLine = self.execProg("smbpasswd -a -s %s" %(userName),
|
|
|
|
|
"%s\n%s\n" %(userPwd,userPwd))
|
|
|
|
@ -4367,6 +4373,8 @@ class servSamba(shareLdap):
|
|
|
|
|
if userPwd == False:
|
|
|
|
|
return False
|
|
|
|
|
if userPwd:
|
|
|
|
|
if not self.servUnixObj.modUserUnixPasswd(userName,{},userPwd):
|
|
|
|
|
return False
|
|
|
|
|
textLine = self.execProg("smbpasswd -a -s %s" %(userName),
|
|
|
|
|
"%s\n%s\n" %(userPwd,userPwd))
|
|
|
|
|
if not (textLine == None):
|
|
|
|
@ -5228,18 +5236,18 @@ class cl_ldap(shareLdap):
|
|
|
|
|
'help':_("use password for the user account") +\
|
|
|
|
|
" (" + _("from standard input") + ")"
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"f",
|
|
|
|
|
'longOption':"force",
|
|
|
|
|
'helpChapter':_("Samba service options"),
|
|
|
|
|
'help':_("create unix user account and Samba user account")
|
|
|
|
|
},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"f",
|
|
|
|
|
'longOption':"force",
|
|
|
|
|
'helpChapter':_("Mail service options"),
|
|
|
|
|
'help':_("create unix user account and mail user account")
|
|
|
|
|
},
|
|
|
|
|
#{'progAccess':(3,),
|
|
|
|
|
#'shortOption':"f",
|
|
|
|
|
#'longOption':"force",
|
|
|
|
|
#'helpChapter':_("Samba service options"),
|
|
|
|
|
#'help':_("create unix user account and Samba user account")
|
|
|
|
|
#},
|
|
|
|
|
#{'progAccess':(3,),
|
|
|
|
|
#'shortOption':"f",
|
|
|
|
|
#'longOption':"force",
|
|
|
|
|
#'helpChapter':_("Mail service options"),
|
|
|
|
|
#'help':_("create unix user account and mail user account")
|
|
|
|
|
#},
|
|
|
|
|
{'progAccess':(3,),
|
|
|
|
|
'shortOption':"n",
|
|
|
|
|
'longOption':"create-profile",
|
|
|
|
|