From: Luca Falavigna Date: Wed, 29 Aug 2012 16:17:42 +0000 (+0000) Subject: Implement get_login_from_ldap function X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20fb8bcccb9c79bd5317856c3d8e6237021613de;p=dak Implement get_login_from_ldap function Signed-off-by: Luca Falavigna --- diff --git a/daklib/utils.py b/daklib/utils.py index be3c6516..f702db3f 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'.