ldap backend: always get the last connected association
This commit is contained in:
parent
58c6209c8f
commit
1802dc433a
|
@ -106,11 +106,17 @@ class Association(object):
|
|||
logger.info("New association %r with %r", sp_login, idp_unique_id)
|
||||
return unique_id
|
||||
else:
|
||||
dn = results[0][0]
|
||||
biggest = '0'
|
||||
biggest_pos = 0
|
||||
for i, result in enumerate(results):
|
||||
if result[1]['lastConnectionDate'][0] > biggest:
|
||||
biggest = result[1]['lastConnectionDate'][0]
|
||||
biggest_pos = i
|
||||
dn = results[biggest_pos][0]
|
||||
mod_list = [(ldap.MOD_REPLACE, 'spPostValues', json.dumps(sp_post_values))]
|
||||
storage_conn.modify_s(dn, mod_list)
|
||||
logger.info("Update post values for %r (%r)", sp_login, idp_unique_id)
|
||||
return results[0][1]['uniqueID'][0]
|
||||
return results[biggest_pos][1]['uniqueID'][0]
|
||||
|
||||
@staticmethod
|
||||
def delete(asso_id):
|
||||
|
@ -127,7 +133,13 @@ class Association(object):
|
|||
results = storage_conn.search_s(config.ldap_base_dn, ldap.SCOPE_ONELEVEL,
|
||||
filterstr='(&(objectClass=MandayeUser)(spName=%s)(idpUniqueID=%s)(idpName=%s))' % (sp_name, idp_unique_id, idp_name))
|
||||
if results:
|
||||
return Association.ldap2association(results[0][1])
|
||||
biggest = '0'
|
||||
biggest_pos = 0
|
||||
for i, result in enumerate(results):
|
||||
if result[1]['lastConnectionDate'][0] > biggest:
|
||||
biggest = result[1]['lastConnectionDate'][0]
|
||||
biggest_pos = i
|
||||
return Association.ldap2association(results[biggest_pos][1])
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
|
|
Reference in New Issue