|
|
|
@ -10345,14 +10345,17 @@ class servRepl(shareLdap):
|
|
|
|
|
|
|
|
|
|
@adminConnectLdap
|
|
|
|
|
def isExistsLogout(self, userName):
|
|
|
|
|
"""Проверяет существует ли в директории профиля пользователя
|
|
|
|
|
файл .logout"""
|
|
|
|
|
logoutFile = os.path.join(self.clVars.Get("sr_samba_linprof_path"),
|
|
|
|
|
userName,self.logOutFile)
|
|
|
|
|
if os.path.exists(logoutFile):
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
"""Проверяет существует ли в директорииях профиля пользователя .logout
|
|
|
|
|
|
|
|
|
|
в случае удачи выводит эти директории"""
|
|
|
|
|
profileDir = os.path.join(self.clVars.Get("sr_samba_linprof_path"),
|
|
|
|
|
userName)
|
|
|
|
|
return filter(lambda x:\
|
|
|
|
|
os.path.exists(os.path.join(x, self.logOutFile)),\
|
|
|
|
|
[profileDir] + map(lambda x: os.path.join(profileDir, x),\
|
|
|
|
|
filter(lambda x:\
|
|
|
|
|
os.path.isdir(os.path.join(profileDir, x)) ,\
|
|
|
|
|
os.listdir(profileDir))))
|
|
|
|
|
|
|
|
|
|
@adminConnectLdap
|
|
|
|
|
def deleteLogoutFile(self, userName, logoutFile):
|
|
|
|
@ -10784,8 +10787,9 @@ if %%errorlevel%%==0 NET USE T: \\\\%s\\ftp' %(netbios,netbios,netbios)
|
|
|
|
|
|
|
|
|
|
@adminConnectLdap
|
|
|
|
|
def addUserReplServer(self, options, logObj=False):
|
|
|
|
|
"""Добавление пользователя в Replication/Worked ветку"""
|
|
|
|
|
verboseMode = True
|
|
|
|
|
errMessage = ""
|
|
|
|
|
errMessages = []
|
|
|
|
|
errorFlag = False
|
|
|
|
|
# Опция выключает вывод cообщений на экран
|
|
|
|
|
if options.has_key('s'):
|
|
|
|
@ -10794,21 +10798,22 @@ if %%errorlevel%%==0 NET USE T: \\\\%s\\ftp' %(netbios,netbios,netbios)
|
|
|
|
|
# Если нет логина пользователя - ошибка
|
|
|
|
|
if not options.has_key('l'):
|
|
|
|
|
errorFlag = True
|
|
|
|
|
errMessage = _("command line option '-l, --login' is not set")
|
|
|
|
|
errMessages.append(\
|
|
|
|
|
_("command line option '-l, --login' is not set"))
|
|
|
|
|
else:
|
|
|
|
|
login = options['l']
|
|
|
|
|
# Проверка установку сервиса LDAP
|
|
|
|
|
if not errorFlag and self.clVars.Get("sr_ldap_set") != "on":
|
|
|
|
|
errorFlag = True
|
|
|
|
|
errMessage = _("LDAP service not setuped")
|
|
|
|
|
errMessages.append(_("LDAP service not setuped"))
|
|
|
|
|
# Проверка на установку samba
|
|
|
|
|
if not errorFlag and self.clVars.Get("sr_samba_set") != "on":
|
|
|
|
|
errorFlag = True
|
|
|
|
|
errMessage = _("Samba service not setuped")
|
|
|
|
|
errMessages.append(_("Samba service not setuped"))
|
|
|
|
|
# Проверка на включение репликации
|
|
|
|
|
if not errorFlag and self.clVars.Get("ld_repl_set") != "on":
|
|
|
|
|
errorFlag = True
|
|
|
|
|
errMessage = _("Replication off")
|
|
|
|
|
errMessages.append(_("Replication off"))
|
|
|
|
|
flagLogOut = False
|
|
|
|
|
retStr = ""
|
|
|
|
|
if not errorFlag:
|
|
|
|
@ -10816,34 +10821,46 @@ if %%errorlevel%%==0 NET USE T: \\\\%s\\ftp' %(netbios,netbios,netbios)
|
|
|
|
|
if self.isLoginUser(login):
|
|
|
|
|
if not self.createUserDirs(login):
|
|
|
|
|
errorFlag = True
|
|
|
|
|
errMessage = \
|
|
|
|
|
_("Can not create user %s directories")%str(login)
|
|
|
|
|
errMessages.append(\
|
|
|
|
|
_("Can not create user %s directories")%str(login))
|
|
|
|
|
else:
|
|
|
|
|
# Директория хранения профилей
|
|
|
|
|
profileDir = os.path.join(\
|
|
|
|
|
self.clVars.Get("sr_samba_linprof_path"), login)
|
|
|
|
|
# получаем директории с self.logOutFile в них
|
|
|
|
|
dirsLogOut= self.isExistsLogout(login)
|
|
|
|
|
flagLogOut = True
|
|
|
|
|
# Удаляем файл .logout
|
|
|
|
|
logoutFile =\
|
|
|
|
|
os.path.join(self.clVars.Get("sr_samba_linprof_path"),
|
|
|
|
|
login,self.logOutFile)
|
|
|
|
|
retStr = self.deleteLogoutFile(login, logoutFile)
|
|
|
|
|
if not retStr:
|
|
|
|
|
errorFlag = True
|
|
|
|
|
errMessage = \
|
|
|
|
|
_("No access to the file %s")%logoutFile
|
|
|
|
|
if retStr == "SUCCESS":
|
|
|
|
|
# Добавляем пользователя в ветку репликации
|
|
|
|
|
if not self.addReplWorkedUser(login):
|
|
|
|
|
# Удаляем файлы .logout
|
|
|
|
|
for dirLogOut in dirsLogOut:
|
|
|
|
|
logoutFile = os.path.join(dirLogOut, self.logOutFile)
|
|
|
|
|
retStr = self.deleteLogoutFile(login, logoutFile)
|
|
|
|
|
if not retStr:
|
|
|
|
|
errorFlag = True
|
|
|
|
|
errMessage = _("Can not add user %s in LDAP branch \
|
|
|
|
|
'Replication'")%str(login)
|
|
|
|
|
errMessages.append(\
|
|
|
|
|
_("No access to the file %s")%logoutFile)
|
|
|
|
|
if retStr == "SUCCESS":
|
|
|
|
|
if dirLogOut == profileDir:
|
|
|
|
|
userLogin = login
|
|
|
|
|
else:
|
|
|
|
|
clientOs = os.path.split(dirLogOut)[1].\
|
|
|
|
|
replace(".","")
|
|
|
|
|
userLogin = "%s@%s"%(login,clientOs)
|
|
|
|
|
# Добавляем пользователя в ветку репликации
|
|
|
|
|
if not self.addReplWorkedUser(userLogin):
|
|
|
|
|
errorFlag = True
|
|
|
|
|
errMessages.append(_("Can not add user %s in \
|
|
|
|
|
LDAP branch 'Replication'")%str(login))
|
|
|
|
|
else:
|
|
|
|
|
errorFlag = True
|
|
|
|
|
errMessage = _("Samba user %s is not found")%str(login)
|
|
|
|
|
errMessages.append(_("Samba user %s is not found")%str(login))
|
|
|
|
|
if errorFlag:
|
|
|
|
|
if errMessage:
|
|
|
|
|
if errMessages:
|
|
|
|
|
if verboseMode:
|
|
|
|
|
self.printERROR(errMessage)
|
|
|
|
|
for errMess in errMessages:
|
|
|
|
|
self.printERROR(errMess)
|
|
|
|
|
if logObj:
|
|
|
|
|
logObj.writeError(errMessage)
|
|
|
|
|
for errMess in errMessages:
|
|
|
|
|
logObj.writeError(errMess)
|
|
|
|
|
return False
|
|
|
|
|
messages = ""
|
|
|
|
|
if flagLogOut:
|
|
|
|
|