POC Campus Condorcet : snapshot connecteur LDAP
This commit is contained in:
parent
800ebc8f3a
commit
0177a99e9c
|
@ -4,7 +4,7 @@ from ldap3 import Server, Connection, SUBTREE
|
|||
|
||||
wcs_base = "http://forms-condorcet.dev.entrouvert.org"
|
||||
form_slug = "/traitement_supann/"
|
||||
base = "ou=supannPeople,dc=condorcet,dc=dev,dc=entrouvert,dc=org"
|
||||
base = "ou=people,dc=condorcet,dc=dev,dc=entrouvert,dc=org"
|
||||
pocform = 'traitement_supann'
|
||||
scope = SUBTREE
|
||||
|
||||
|
@ -65,7 +65,10 @@ def ldap_add_entry(id):
|
|||
delimiter = ','
|
||||
# The new DN
|
||||
# (the "dn: " prefix musn't appear here):
|
||||
dn = 'uid='+id['nameid']+","+base
|
||||
if 'ep_principal_name' not in id:
|
||||
return [-1, 'EPPN manquant!']
|
||||
|
||||
dn = 'uid='+id.get('ep_principal_name')+","+base
|
||||
|
||||
objectClass = ['inetOrgPerson', 'supannPerson', 'eduPerson']
|
||||
|
||||
|
@ -73,29 +76,35 @@ def ldap_add_entry(id):
|
|||
|
||||
# All the entry attributes can be defined in a dictionary as below.
|
||||
# Only 'cn', 'uid' and 'sn' attributs are mandatory:
|
||||
addmod['cn'] = id['prenom']+" "+id['nom']
|
||||
addmod['uid'] = id['nameid']
|
||||
addmod['sn'] = id['nom']
|
||||
addmod['cn'] = id.get('prenom')+" "+id.get('nom')
|
||||
addmod['uid'] = id.get('ep_principal_name')
|
||||
addmod['sn'] = id.get('nom')
|
||||
|
||||
# eduPerson attributes:
|
||||
addmod['eduPersonPrincipalName'] = id['ep_principal_name']
|
||||
addmod['eduPersonPrimaryAffiliation'] = id['ep_primary_affiliation']
|
||||
addmod['eduPersonAffiliation'] = id['ep_affiliation'].split(delimiter)
|
||||
addmod['eduPersonPrincipalName'] = id.get('ep_principal_name')
|
||||
addmod['eduPersonPrimaryAffiliation'] = id.get('ep_primary_affiliation')
|
||||
|
||||
if id.get('ep_affiliation') is not None:
|
||||
addmod['eduPersonAffiliation'] = id.get('ep_affiliation').split(delimiter)
|
||||
|
||||
# supannPerson Attributes:
|
||||
addmod['supannEtablissement'] = id['s_etablissement']
|
||||
addmod['supannEntiteAffectationPrincipale'] = id['s_entite_affectation_principale']
|
||||
addmod['supannEntiteAffectation'] = id['s_entite_affectation'].split(delimiter)
|
||||
addmod['supannEmpCorps'] = id['s_emp_corps']
|
||||
addmod['supannEtablissement'] = id.get('s_etablissement')
|
||||
addmod['supannEntiteAffectationPrincipale'] = id.get('s_entite_affectation_principale')
|
||||
|
||||
if id['s_liste_rouge'] == True:
|
||||
if id.get('supannEntiteAffectation') is not None:
|
||||
addmod['supannEntiteAffectation'] = id.get('s_entite_affectation').split(delimiter)
|
||||
|
||||
addmod['supannEmpCorps'] = id.get('s_emp_corps')
|
||||
|
||||
if id.get('s_liste_rouge') == True:
|
||||
addmod['supannListeRouge'] = 'TRUE'
|
||||
elif id['s_liste_rouge'] == False:
|
||||
#elif id.get('s_liste_rouge') == False:
|
||||
else:
|
||||
addmod['supannListeRouge'] = 'FALSE'
|
||||
|
||||
# Extra attributes:
|
||||
addmod['givenName'] = id['prenom']
|
||||
addmod['mail'] = id['email']
|
||||
addmod['givenName'] = id.get('prenom')
|
||||
addmod['mail'] = id.get('email')
|
||||
|
||||
l = ldap_init()
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ CURRENT_CONNECTOR = 'condorcet'
|
|||
def dummy_view(request):
|
||||
return HttpResponse("Dummy LDAP connector view.")
|
||||
|
||||
@login_required
|
||||
#@login_required
|
||||
def wcs(request, slug="", wcs_entry_id=0):
|
||||
json_response = get_form_entry(wcs_entry_id)
|
||||
dict = json.loads(json_response)
|
||||
|
|
Reference in New Issue