[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] Implement get_login_from_ldap function



Signed-off-by: Luca Falavigna <dktrkranz@debian.org>
---
 daklib/utils.py |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/daklib/utils.py b/daklib/utils.py
index be3c651..f702db3 100644
--- a/daklib/utils.py
+++ b/daklib/utils.py
@@ -40,6 +40,7 @@ import time
 import re
 import email as modemail
 import subprocess
+import ldap
 
 from dbconn import DBConn, get_architecture, get_component, get_suite, \
                    get_override_type, Keyring, session_wrapper, \
@@ -1410,6 +1411,19 @@ def gpg_get_key_addresses(fingerprint):
 
 ################################################################################
 
+def get_login_from_ldap(fingerprint):
+    """retrieve login from LDAP linked to a given fingerprint"""
+
+    LDAPDn = Cnf['Import-LDAP-Fingerprints::LDAPDn']
+    LDAPServer = Cnf['Import-LDAP-Fingerprints::LDAPServer']
+    l = ldap.open(LDAPServer)
+    l.simple_bind_s('','')
+    Attrs = l.search_s(LDAPDn, ldap.SCOPE_ONELEVEL,
+                       '(keyfingerprint=%s)' % fingerprint, ['uid'])
+    return Attrs[0][1]['uid'][0]
+
+################################################################################
+
 def clean_symlink (src, dest, root):
     """
     Relativize an absolute symlink from 'src' -> 'dest' relative to 'root'.
-- 
1.7.2.5



Reply to: