Projet

Général

Profil

dataproxy_patch.txt

Patch pour dataproxy - Pascal MIETLICKI, 05/08/2015 06:31

Télécharger (2,01 ko)

 
1
@@ -37,6 +37,8 @@
2
 from eoleldaptor import eoleldapproxy
3
 from twisted.python import log, failure
4
 from util import get_replication_branches
5
+from scribe.eoleldap import Ldap
6
+from scribe.linker import _user_factory
7
 import os, socket
8
 
9
 class LDAPProxy:
10
@@ -117,6 +119,7 @@
11
             self.search_branches[host] = search_branches
12
             self.ldap_infos[host] = ldap_infos
13
             self.otp_config[host] = login_otp
14
+            #log.msg("Eole proxy %s" % eole_proxy)
15
         if nb_branches > 1:
16
             self.use_branches = True
17
 
18
@@ -221,15 +224,28 @@
19
 
20
     def callb_auth(self, result_auth, user_id, passwd, search_branch, servers):
21
         success, user_data = result_auth
22
-        # vérification du résultat de l'authentification sur le serveur précédent
23
-        if success == False:
24
-            # echec de l'authentification  sur ce serveur
25
-            if len(servers) > 0:
26
-                # test sur le serveur suivant
27
-                return self.authenticate(user_id, passwd, search_branch, servers)
28
-            else:
29
-                # on a essayé sur tous les serveurs
30
-                return False, {}
31
+
32
+        if success == True and "localhost" not in servers:
33
+            #log.msg("MAJ pwd vers localhost")
34
+            #recupere de ead2 backend/actions/scribe/userpwd.py
35
+            try:
36
+                conn = Ldap()
37
+                conn.connect()
38
+                ldapuser = _user_factory(user_id, conn.connexion)
39
+                ldapuser.c_mod_password(user_id, passwd)
40
+                conn.close()
41
+            except:
42
+                pass
43
+
44
+        # echec de l'authentification  sur ce serveur
45
+        if len(servers) > 0:
46
+            # test sur le serveur suivant
47
+            return self.authenticate(user_id, passwd, search_branch, servers)
48
+
49
+        if success == False :
50
+            # on a essayé sur tous les serveurs
51
+            return False, {}
52
+
53
         # on supprime certains champs (mot de passe)
54
         for user_attr in self.ignored_attrs:
55
             if user_attr in user_data: