fix(usermanager): create User and Group OUs if necessary
This commit is contained in:
parent
0ed0a3f981
commit
519cd26e13
@ -54,6 +54,4 @@ def create_app(test_config=None):
|
|||||||
api.add_resource(webapi.GroupMemberResource, '/api/group/<string:groupname>/member/<string:username>')
|
api.add_resource(webapi.GroupMemberResource, '/api/group/<string:groupname>/member/<string:username>')
|
||||||
api.init_app(app)
|
api.init_app(app)
|
||||||
|
|
||||||
# TODO create OUs
|
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
@ -33,6 +33,18 @@ def _init_static_images():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@bp.before_app_first_request
|
||||||
|
def _initialize_ldap_dit():
|
||||||
|
"""Creates the OUs for users and groups if they do not exist yet."""
|
||||||
|
|
||||||
|
conn = ldap.get_connection()
|
||||||
|
if not ldap.ou_exists(conn, current_app.config['LDAP_USERS_OU']):
|
||||||
|
ldap.create_ou(conn, current_app.config['LDAP_USERS_OU'])
|
||||||
|
if not ldap.ou_exists(conn, current_app.config['LDAP_GROUPS_OU']):
|
||||||
|
ldap.create_ou(conn, current_app.config['LDAP_GROUPS_OU'])
|
||||||
|
conn.unbind()
|
||||||
|
|
||||||
|
|
||||||
@bp.route('/')
|
@bp.route('/')
|
||||||
def index():
|
def index():
|
||||||
"""Home page view."""
|
"""Home page view."""
|
||||||
|
Loading…
Reference in New Issue
Block a user