[Da-tools-commits] ./da-tools/userdir-ldap-cgi-python r5: adding simple user search
Martin Zobel-Helas
zobel at debian.org
Sun Jan 11 21:30:10 UTC 2009
------------------------------------------------------------
revno: 5
committer: Martin Zobel-Helas <zobel at debian.org>
branch nick: userdir-ldap-cgi-python
timestamp: Sun 2009-01-11 22:30:10 +0100
message:
adding simple user search
modified:
ud_ldap_ng/controllers/udldapng.py
ud_ldap_ng/lib/ud_ldap_ng.py
-------------- next part --------------
=== modified file 'ud_ldap_ng/controllers/udldapng.py'
--- a/ud_ldap_ng/controllers/udldapng.py 2009-01-10 22:27:36 +0000
+++ b/ud_ldap_ng/controllers/udldapng.py 2009-01-11 21:30:10 +0000
@@ -9,7 +9,7 @@
log = logging.getLogger(__name__)
import re
-from ud_ldap_ng.lib.ud_ldap_ng import connectLDAP, bindLDAP, searchHosts
+from ud_ldap_ng.lib.ud_ldap_ng import connectLDAP, bindLDAP, searchHosts, searchUser
class UdldapngController(BaseController):
@@ -37,8 +37,17 @@
return render('/machines.html')
def lala(self):
- return "hello world"
- #return repr(searchHosts(con))
+ con = connectLDAP('db.debian.org')
+ bindLDAP(con)
+ user = request.params['uid']
+ results = searchUser(con, user)
+ result_set = []
+ result_type, result_data = con.result(results, 0)
+ if result_type == ldap.RES_SEARCH_ENTRY:
+ result_set.append(result_data)
+ return render('/developer.html')
+# return "hello world"
+# #return repr(searchHosts(con))
# return 'Hello World'
# ((la), {})
=== modified file 'ud_ldap_ng/lib/ud_ldap_ng.py'
--- a/ud_ldap_ng/lib/ud_ldap_ng.py 2009-01-10 19:29:32 +0000
+++ b/ud_ldap_ng/lib/ud_ldap_ng.py 2009-01-11 21:30:10 +0000
@@ -22,5 +22,12 @@
scope = ldap.SCOPE_SUBTREE
return con.search_s(dn, scope)
+def searchUser(con, user):
+ dn = "ou=users,dc=debian,dc=org"
+ scope = ldap.SCOPE_SUBTREE
+ searchFilter = "(uid=%s)" % (user)
+ return con.search_s(dn,scope,searchFilter)
+
+
if __name__ == '__main__':
pass
More information about the Da-tools-commits
mailing list