iotlab driver: wip fixing Timur's bug when a user already has an account in LDAP...
[sfa.git] / sfa / iotlab / LDAPapi.py
index d01c82b..94565b8 100644 (file)
@@ -466,6 +466,8 @@ class LDAPapi:
                 if record['first_name'] != record['last_name']:
                     req_ldapdict['cn'] = str(record['first_name'])+" "\
                         + str(record['last_name'])
+            if 'uid' in record:
+                req_ldapdict['uid'] = record['uid']
             if 'email' in record:
                 req_ldapdict['mail'] = record['email']
             if 'mail' in record:
@@ -958,6 +960,10 @@ class LDAPapi:
             #then the login is different from the one found in its hrn
             if tmpname != hrn.split('.')[1]:
                 hrn = None
+        else:
+            hrn = None
+
+        if hrn is None:
             results = {
                 'type': 'user',
                 'pkey': ldapentry['sshPublicKey'],
@@ -972,7 +978,6 @@ class LDAPapi:
                 'authority': parent_hrn,
                 'peer_authority': peer_authority,
                 'pointer': -1,
-                'hrn': hrn,
              }
         else:
             #hrn = None
@@ -990,6 +995,7 @@ class LDAPapi:
                 'authority': parent_hrn,
                 'peer_authority': peer_authority,
                 'pointer': -1,
+                'hrn': hrn,
             }
         return results