modify sudo conn timeout bug

pull/12/head
ibuler 2015-07-03 21:09:17 +08:00
parent ce8e1e0ae3
commit f7e70e56e3
3 changed files with 12 additions and 5 deletions

View File

@ -264,8 +264,10 @@ def unicode2str(unicode_list):
def sudo_ldap_add(user_group, user_runas, asset_groups_select,
cmd_groups_select):
if not LDAP_ENABLE:
return True
if LDAP_ENABLE:
ldap_conn = LDAPMgmt(LDAP_HOST_URL, LDAP_BASE_DN, LDAP_ROOT_DN, LDAP_ROOT_PW)
else:
return
assets = []
cmds = []

View File

@ -101,9 +101,6 @@ if LDAP_ENABLE:
LDAP_BASE_DN = CONF.get('ldap', 'base_dn')
LDAP_ROOT_DN = CONF.get('ldap', 'root_dn')
LDAP_ROOT_PW = CONF.get('ldap', 'root_pw')
ldap_conn = LDAPMgmt(LDAP_HOST_URL, LDAP_BASE_DN, LDAP_ROOT_DN, LDAP_ROOT_PW)
else:
ldap_conn = None
def md5_crypt(string):

View File

@ -123,6 +123,10 @@ def server_del_user(username):
def ldap_add_user(username, ldap_pwd):
if LDAP_ENABLE:
ldap_conn = LDAPMgmt(LDAP_HOST_URL, LDAP_BASE_DN, LDAP_ROOT_DN, LDAP_ROOT_PW)
else:
return
user_dn = "uid=%s,ou=People,%s" % (username, LDAP_BASE_DN)
password_sha512 = gen_sha512(gen_rand_pwd(6), ldap_pwd)
user = User.objects.filter(username=username)
@ -155,6 +159,10 @@ def ldap_add_user(username, ldap_pwd):
def ldap_del_user(username):
if LDAP_ENABLE:
ldap_conn = LDAPMgmt(LDAP_HOST_URL, LDAP_BASE_DN, LDAP_ROOT_DN, LDAP_ROOT_PW)
else:
return
user_dn = "uid=%s,ou=People,%s" % (username, LDAP_BASE_DN)
group_dn = "cn=%s,ou=Group,%s" % (username, LDAP_BASE_DN)
sudo_dn = 'cn=%s,ou=Sudoers,%s' % (username, LDAP_BASE_DN)