Projet

Général

Profil

0001-ldap-backend-always-get-the-last-connected-associati.patch

Jérôme Schneider, 31 octobre 2014 11:04

Télécharger (2,15 ko)

Voir les différences:

Subject: [PATCH 1/2] ldap backend: always get the last connected association

 mandaye/backends/ldap_back.py | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
mandaye/backends/ldap_back.py
106 106
            logger.info("New association %r with %r", sp_login, idp_unique_id)
107 107
            return unique_id
108 108
        else:
109
            dn = results[0][0]
109
            biggest = '0'
110
            biggest_pos = 0
111
            for i, result in enumerate(results):
112
                if result[1]['lastConnectionDate'][0] > biggest:
113
                    biggest = result[1]['lastConnectionDate'][0]
114
                    biggest_pos = i
115
            dn = results[biggest_pos][0]
110 116
            mod_list = [(ldap.MOD_REPLACE, 'spPostValues', json.dumps(sp_post_values))]
111 117
            storage_conn.modify_s(dn, mod_list)
112 118
            logger.info("Update post values for %r (%r)", sp_login, idp_unique_id)
113
        return results[0][1]['uniqueID'][0]
119
            return results[biggest_pos][1]['uniqueID'][0]
114 120

  
115 121
    @staticmethod
116 122
    def delete(asso_id):
......
127 133
        results = storage_conn.search_s(config.ldap_base_dn, ldap.SCOPE_ONELEVEL,
128 134
                filterstr='(&(objectClass=MandayeUser)(spName=%s)(idpUniqueID=%s)(idpName=%s))' % (sp_name, idp_unique_id, idp_name))
129 135
        if results:
130
            return Association.ldap2association(results[0][1])
136
            biggest = '0'
137
            biggest_pos = 0
138
            for i, result in enumerate(results):
139
                if result[1]['lastConnectionDate'][0] > biggest:
140
                    biggest = result[1]['lastConnectionDate'][0]
141
                    biggest_pos = i
142
            return Association.ldap2association(results[biggest_pos][1])
131 143
        return None
132 144

  
133 145
    @staticmethod
134
-