révision de get_etab pour le mode ldap
This commit is contained in:
@@ -200,7 +200,7 @@ index 69f3411..19ba7a1 100644
|
|||||||
Mise à niveau d'un compte enseignant
|
Mise à niveau d'un compte enseignant
|
||||||
"""
|
"""
|
||||||
diff --git usr/lib/python3/dist-packages/scribe/eoleldap.py usr/lib/python3/dist-packages/scribe/eoleldap.py
|
diff --git usr/lib/python3/dist-packages/scribe/eoleldap.py usr/lib/python3/dist-packages/scribe/eoleldap.py
|
||||||
index 45ec338..9a67c6d 100644
|
index 45ec338..0f6125b 100644
|
||||||
--- usr/lib/python3/dist-packages/scribe/eoleldap.py
|
--- usr/lib/python3/dist-packages/scribe/eoleldap.py
|
||||||
+++ usr/lib/python3/dist-packages/scribe/eoleldap.py
|
+++ usr/lib/python3/dist-packages/scribe/eoleldap.py
|
||||||
@@ -8,21 +8,21 @@
|
@@ -8,21 +8,21 @@
|
||||||
@@ -262,6 +262,41 @@ index 45ec338..9a67c6d 100644
|
|||||||
users = []
|
users = []
|
||||||
res = self.ldap_admin._search("(&%s%s)" % (USER_FILTER, filtre), attrs)
|
res = self.ldap_admin._search("(&%s%s)" % (USER_FILTER, filtre), attrs)
|
||||||
for user in res:
|
for user in res:
|
||||||
|
@@ -572,21 +570,29 @@ elif LDAP_MODE == 'openldap':
|
||||||
|
récupère le numéro d'etab du cache ou requète LDAP
|
||||||
|
"""
|
||||||
|
if not SUPPORT_ETAB:
|
||||||
|
return None
|
||||||
|
if not multi_etabs and name in self.cache_etab[_type]:
|
||||||
|
return self.cache_etab[_type][name]
|
||||||
|
need_close = False
|
||||||
|
if self.ldap_admin.connexion == None:
|
||||||
|
self.ldap_admin.connect()
|
||||||
|
need_close = True
|
||||||
|
- dn = self.ldap_admin._search(ldap_filter, [attr])[0][0]
|
||||||
|
+ try:
|
||||||
|
+ if _type == 'group':
|
||||||
|
+ attr = 'rne'
|
||||||
|
+ result = self.ldap_admin._search(ldap_filter, [attr])[0]
|
||||||
|
+ if _type == 'login':
|
||||||
|
+ etab = [rne[1]['rne'][0] for rne in self.ldap_admin._search(f'(&(objectClass=eolegroupe)(type=Etablissement)(memberUid={name}))', ['rne'])]
|
||||||
|
+ else:
|
||||||
|
+ etab = result[1]['rne']
|
||||||
|
+ if not multi_etabs:
|
||||||
|
+ etab = etab[0]
|
||||||
|
+ except:
|
||||||
|
+ etab = None
|
||||||
|
if need_close:
|
||||||
|
self.ldap_admin.close()
|
||||||
|
- etab = dn.split(',ou=')[-3]
|
||||||
|
- if multi_etabs:
|
||||||
|
- etab = [etab]
|
||||||
|
- else:
|
||||||
|
+ if not multi_etabs:
|
||||||
|
self.cache_etab[_type][name] = etab
|
||||||
|
return etab
|
||||||
|
else:
|
||||||
|
raise Exception('Unknown mode')
|
||||||
diff --git usr/lib/python3/dist-packages/scribe/eoleuser.py usr/lib/python3/dist-packages/scribe/eoleuser.py
|
diff --git usr/lib/python3/dist-packages/scribe/eoleuser.py usr/lib/python3/dist-packages/scribe/eoleuser.py
|
||||||
index 05569fd..74d9485 100644
|
index 05569fd..74d9485 100644
|
||||||
--- usr/lib/python3/dist-packages/scribe/eoleuser.py
|
--- usr/lib/python3/dist-packages/scribe/eoleuser.py
|
||||||
|
Reference in New Issue
Block a user