diff options
-rw-r--r-- | accounts/urls.py | 1 | ||||
-rw-r--r-- | accounts/views.py | 19 | ||||
-rw-r--r-- | templates/account/all.html | 7 |
3 files changed, 27 insertions, 0 deletions
diff --git a/accounts/urls.py b/accounts/urls.py index 1ecdd1c..4df0e67 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -4,6 +4,7 @@ from django.views.generic.simple import redirect_to urlpatterns = patterns('okupy.accounts.views', # (r'^$', redirect_to, {'url': '/account/%(username)s/'}), <--- doesn't work (r'^(?P<username>\w+)/$', 'account'), + (r'^all/$', 'account_all'), (r'^(?P<username>\w+)/edit/$', 'account_edit'), (r'^(?P<username>\w+)/edit/password/$', 'account_edit_password'), (r'^(?P<username>\w+)/edit/email/$', 'account_edit_email'), diff --git a/accounts/views.py b/accounts/views.py index 64f2115..83d1e71 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -183,3 +183,22 @@ def account_edit_password(request, username): 'account/password.html', {'form': form, 'msg': msg}, context_instance = RequestContext(request)) + +@login_required +def account_all(request): + l = ldap_anon_user_bind() + accounts = {'uid': [], 'cn': []} + user = '' + for ldap_base_dn in settings.LDAP_BASE_DN: + try: + for user in l.search_s(ldap_base_dn, + ldap.SCOPE_SUBTREE, + '(%s=%s)' % (settings.LDAP_BASE_ATTR, '*'), + ['uid', 'cn']) + accounts['uid'].append(user[1]['uid'][0]) + accounts['cn'].append(user[1]['cn'][0]) + except Exception as error: + logger.error(error, extra = log_extra_data()) + raise OkupyException('Error with the LDAP server') + l.unbind_s() + return render_to_response('account/all.html', accounts, context_instance = RequestContext(request)) diff --git a/templates/account/all.html b/templates/account/all.html new file mode 100644 index 0000000..4e57605 --- /dev/null +++ b/templates/account/all.html @@ -0,0 +1,7 @@ +<ul> +{% for user in users %} + {% for attr in user %} + <li>attr</li> + {% endfor %} +{% endfor %} +</ul> |