Commit 940f6296 authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

LDAPExportExtension: fixed extension name

parent 39f0ef71
......@@ -8,3 +8,4 @@ extensions/*
!extensions/terminal
!extensions/codeeditor
!extensions/file2
!extensions/ldap_export
......@@ -29,7 +29,7 @@ class LDAPExport(object):
self.private_group = vispa.config("ldap-export", "private_group", True)
self.gid_offset = vispa.config("ldap-export", "gid_offset", 100000)
set_library_log_detail_level(BASIC)
def connect(self):
url = vispa.config("ldap-export", "url")
user = vispa.config("ldap-export", "user")
......@@ -37,11 +37,11 @@ class LDAPExport(object):
if not url:
return
self.connection = ldap3.Connection(url, user, password, auto_bind=True, raise_exceptions=True)
return self.connection != None
def delete_unknown(self, db):
try:
active_users = [unicode(u.name) for u in db.query(User, User.name).filter_by(status=User.ACTIVE)]
......@@ -60,7 +60,7 @@ class LDAPExport(object):
if not private_group and not public_group:
logger.info("Deleting unknown ldap group: %s", ldap_group.entry_get_dn())
self.connection.delete(ldap_group.entry_get_dn())
except:
logger.exception("remove_invalid_ldap_entries")
finally:
......@@ -93,7 +93,7 @@ class LDAPExport(object):
logger.exception("sync_all_groups")
finally:
db.remove()
def user_delete(self, name):
dn = 'cn=%s,%s' % (name, self.user_base)
logger.info("Delete user: %s", dn)
......@@ -131,7 +131,7 @@ class LDAPExport(object):
'homeDirectory': _r('/home/%s/' % username)
}
self.connection.modify(dn, changes)
if self.private_group:
self.group_add(username, uid + self.uid_offset)
self.group_add_member(username, username)
......@@ -154,7 +154,7 @@ class LDAPExport(object):
'gidNumber': _r(gid),
}
self.connection.modify(dn, changes)
def group_add_member(self, groupname, username):
dn = 'cn=%s,%s' % (groupname, self.group_base)
change = {
......@@ -163,7 +163,7 @@ class LDAPExport(object):
try:
self.connection.modify(dn, change)
except LDAPAttributeOrValueExistsResult:
pass
pass
def user_set_password(self, name, password):
dn = 'cn=%s,%s' % (name, self.user_base)
......@@ -174,11 +174,11 @@ class LDAPExport(object):
self.connection.modify(dn, changes)
class LDAPExportExtension(AbstractExtension):
def name(self):
return "ldap-export"
return "ldap_export"
def dependencies(self):
return []
......@@ -194,7 +194,7 @@ class LDAPExportExtension(AbstractExtension):
self.delete_unknown(session)
self.sync_all_users(session)
self.sync_all_groups(session)
vispa.register_callback("user.activate", self.on_activate)
vispa.register_callback("user.set_password", self.on_set_password)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment