From 6800be954317c465f4a73ec025a90fa95e24b707 Mon Sep 17 00:00:00 2001 From: Kloadut Date: Sat, 6 Oct 2012 17:57:08 +0200 Subject: [PATCH] LDAP file init --- lib/yunohost_ldap.py | 6 ++++++ lib/yunohost_user.py | 9 +++++++-- yunohost | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 lib/yunohost_ldap.py diff --git a/lib/yunohost_ldap.py b/lib/yunohost_ldap.py new file mode 100644 index 00000000..9582d3e3 --- /dev/null +++ b/lib/yunohost_ldap.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- + +import ldap + +conn = ldap.initialize('ldap://localhost:389') +conn.simple_bind_s("cn=admin,dc=yunohost,dc=org","secret") diff --git a/lib/yunohost_user.py b/lib/yunohost_user.py index f4b13221..5a4aa43a 100644 --- a/lib/yunohost_user.py +++ b/lib/yunohost_user.py @@ -1,5 +1,10 @@ -#!/usr/bin/env python2.7 # -*- coding: utf-8 -*- +import ldap +import ldap.modlist as modlist +import yunohost_ldap as yldap + def user_list(args): - print args + result = yldap.conn.search_s('ou=users,dc=gavoty,dc=org',ldap.SCOPE_SUBTREE,'(cn=*)',['cn','mail']) + for dn,entry in result: + print entry['mail'][0] diff --git a/yunohost b/yunohost index 37fc68d6..ef160a73 100755 --- a/yunohost +++ b/yunohost @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python # -*- coding: utf-8 -*- import sys