+ return str(max_uidnumber)
+
+ #TODO ; Get ssh public key from sfa record
+ #To be filled by N. Turro
+ def get_ssh_pkey(self, record):
+ return
+
+
+ #TODO Handle OR filtering in the ldap query when
+ #dealing with a list of records instead of doing a for loop in GetPersons
+ def make_ldap_filters_from_record(self, record=None):
+ """
+ Helper function to make LDAP filter requests out of SFA records.
+ """
+ req_ldapdict = {}
+ if record :
+ if 'first_name' in record and 'last_name' in record:
+ req_ldapdict['cn'] = str(record['first_name'])+" "\
+ + str(record['last_name'])
+ if 'email' in record :
+ req_ldapdict['mail'] = record['email']
+ if 'mail' in record:
+ req_ldapdict['mail'] = record['mail']
+
+ if 'hrn' in record :
+ splited_hrn = record['hrn'].split(".")
+ if splited_hrn[0] != self.authname :
+ logger.warning(" \r\n LDAP.PY \
+ make_ldap_filters_from_record I know nothing \
+ about %s my authname is %s not %s" \
+ %(record['hrn'], self.authname, splited_hrn[0]) )
+
+ login=splited_hrn[1]
+ req_ldapdict['uid'] = login
+
+ req_ldap=''
+ logger.debug("\r\n \t LDAP.PY make_ldap_filters_from_record \
+ record %s req_ldapdict %s" \
+ %(record, req_ldapdict))
+
+ for k in req_ldapdict:
+ req_ldap += '('+str(k)+'='+str(req_ldapdict[k])+')'
+ if len(req_ldapdict.keys()) >1 :
+ req_ldap = req_ldap[:0]+"(&"+req_ldap[0:]
+ size = len(req_ldap)
+ req_ldap= req_ldap[:(size-1)] +')'+ req_ldap[(size-1):]
+ else:
+ req_ldap = "(cn=*)"
+
+ return req_ldap