bugfixing
This commit is contained in:
parent
d12a09a98e
commit
5b7d67838b
4 changed files with 19 additions and 10 deletions
|
|
@ -43,7 +43,7 @@ def ldapservers():
|
|||
# returns the full dn
|
||||
def user_or_customer(uid):
|
||||
server = ldapservers()
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config['LDAP']['LDAPMANAGERPASSWORD'])
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config.get('LDAP','LDAPMANAGERPASSWORD', raw=True))
|
||||
conn.bind()
|
||||
search_customers = conn.search('ou=customers,dc=ungleich,dc=ch', '(%s)' % uid)
|
||||
if search_customers:
|
||||
|
|
@ -67,7 +67,7 @@ class UserLookUp(object):
|
|||
# Setup the search parameter and connect to LDAP
|
||||
LDAP_UID = 'uid=%s' % user
|
||||
server = ldapservers()
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config['LDAP']['LDAPMANAGERPASSWORD'])
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config.get('LDAP','LDAPMANAGERPASSWORD', raw=True))
|
||||
conn.bind()
|
||||
# Strange result. It keeps complaining LDAP_UID not set if I try to directly
|
||||
# substitute x and y to the if
|
||||
|
|
@ -96,7 +96,7 @@ class CreateUser(object):
|
|||
def create_user(self, user, password, firstname, lastname, email):
|
||||
# Creates a user with some basic data
|
||||
server = ldapservers()
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config['LDAP']['LDAPMANAGERPASSWORD'])
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config.get('LDAP','LDAPMANAGERPASSWORD', raw=True))
|
||||
if not conn.bind():
|
||||
self.dispatch('ldap', '%s [Error CreateUser] Could not connect to LDAPserver\n' % datetime.now() )
|
||||
return "Could not connect to LDAP Server."
|
||||
|
|
@ -132,8 +132,9 @@ class CreateUser(object):
|
|||
newuid = 0
|
||||
uidlist = []
|
||||
for c in conn.response:
|
||||
uidlist.append(c['attribute']['uidNumber'])
|
||||
newuid = sorted(uidlist)[len(uidlist)-1]
|
||||
uidlist.append(c['attributes']['uidNumber'])
|
||||
# New uid is highest old uidnumber plus one
|
||||
newuid = (sorted(uidlist)[len(uidlist)-1] + 1)
|
||||
return newuid
|
||||
|
||||
|
||||
|
|
@ -148,7 +149,7 @@ class GetUserData(object):
|
|||
# Setup the search parameter and connect to LDAP
|
||||
LDAP_UID = 'uid=%s' % user
|
||||
server = ldapservers()
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config['LDAP']['LDAPMANAGERPASSWORD'])
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config.get('LDAP', 'LDAPMANAGERPASSWORD', raw=True))
|
||||
conn.bind()
|
||||
if not conn.bound:
|
||||
self.dispatch('ldap', '%s [Error GetUserData] Could not connect to LDAP server.\n' % datetime.now() )
|
||||
|
|
@ -193,7 +194,7 @@ class ChangeUserData(object):
|
|||
LDAP_UID = 'uid=%s' % user
|
||||
server = ldapservers()
|
||||
# Establish connection with a user who can change the data
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config['LDAP']['LDAPMANAGERPASSWORD'])
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config.get('LDAP', 'LDAPMANAGERPASSWORD', raw=True))
|
||||
if not conn.bind():
|
||||
self.dispatch('ldap', '%s [Error ChangeUserData] Could not connect to LDAP server.\n' % datetime.now() )
|
||||
return "Could not connect to LDAP server."
|
||||
|
|
@ -241,7 +242,7 @@ class ChangePassword(object):
|
|||
def change_password(self, user, newpassword):
|
||||
LDAP_UID = 'uid=%s' % user
|
||||
server = ldapservers()
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config['LDAP']['LDAPMANAGERPASSWORD'])
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config.get('LDAP', 'LDAPMANAGERPASSWORD', raw=True))
|
||||
if not conn.bind():
|
||||
self.dispatch('ldap', '%s [Error ChangePassword] Could not connect to LDAP server.\n' % datetime.now() )
|
||||
return "Could not connect to LDAP server."
|
||||
|
|
@ -284,7 +285,7 @@ class DeleteUser(object):
|
|||
def delete_user(self, user):
|
||||
LDAP_UID = 'uid=%s' % user
|
||||
server = ldapservers()
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config['LDAP']['LDAPMANAGERPASSWORD'])
|
||||
conn = Connection(server, config['LDAP']['LDAPMANAGER'], config.get('LDAP', 'LDAPMANAGERPASSWORD', raw=True))
|
||||
conn.bind()
|
||||
if not conn.bound:
|
||||
self.dispatch('ldap', '%s [Error DeleteUser] Could not connect to LDAP server.\n' % datetime.now() )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue