Preparation backend connecteur

This commit is contained in:
Paul Marillonnet 2017-03-01 16:38:23 +01:00
parent 9366da1baf
commit 367c534f0b
4 changed files with 35 additions and 5 deletions

11
doc.md
View File

@ -37,6 +37,8 @@ Compilation :
* IETF : *Internet Engineering Task Force*
* JPA : *Java Persistence API*
* L10N : *Localization*
* LDAP : *Lightweight Directory Access Protocol*
* LDIF : *LDAP Data Interchange Format*
* MVCC : *Multi Version Concurrency Control*
* NDS : *Novell Directory Services* // Vraiment pertinent ici ? Mentionné dans la RFC3384
* NIO : *Non-blocking I/O* (API Java)
@ -907,7 +909,14 @@ Ce connecteur devra supporter un grand nombre d'opérations sur un annuaire du c
La gestion des droits est laissée aux soins du serveur LDAP qui gère ses propres contrôles d'accès (par des ACL).
TODO Serveur, credentials et DN founis par l'utilisateur à la création du connecteur ?
TODO Serveur, credentials et DN founis par l'utilisateur à la création du connecteur ? DONE
Il est nécessaire d'effectuer quelques recherches documentaires sur l'API python ldap3 pour la mise en place d'une interface Web de requêtes sur le connecteur.
Plusieurs points sont à mentionner ici:
- ldap3 prend en charge les modifications sur l'annuaire par utilisation d'un fichier LDIF (LDAP Data Interchange Format).
TODO http://ldap3.readthedocs.io/operations.html
### Config SMTP
Lors de la réalisation du POC, la phase de demande de création d'un compte invité sur le méta-annuaire

View File

@ -18,7 +18,7 @@ from .utils import base
# read py files in passerelle/base/
CHOICES = (('1', 'BASE',), ('2', 'LEVEL',), ('3', 'SUBTREE',))
OPERATIONS = (('1', 'Search',), ('2', 'Add',), ('3', 'Modify',), ('4', 'Delete',))
OPERATIONS = (('1', 'Search',), ('2', 'Add',), ('3', 'Modify',), ('4', 'Delete',), ('5', 'LDIF',))
# Create your models here.
def format_person(p):

View File

@ -34,12 +34,31 @@ def ldap_init():
res = conn.bind()
return conn
def ldap_init(who='', cred='', server='localhost'):
def ldap_init3(who='', cred='', server='localhost'):
s = Server(server)
conn = Connection(s, user=who, password=cred)
res = conn.bind()
return conn
def ldap_operation(connector, data):
handle = ldap_init3(connector.user, connector.password, connector.server) #FIXME
# TODO
if data['operation'] == 1:
return 'TODO Search'
elif data['operation'] == 2:
return 'TODO Add'
elif data['operation'] == 3:
return 'TODO Modify'
elif data['operation'] == 4:
return 'TODO Delete'
elif data['operation'] == 5:
return 'TODO Generic LDIF operation'
ldap_terminate(handle)
return data['operation']
def ldap_terminate(conn):
conn.unbind()
return 0

View File

@ -11,7 +11,7 @@ from django.views.generic import View, UpdateView, CreateView
# Add library search path entry?
from passerelle import utils
from .utils import get_form_entry, ldap_add_entry
from .utils import get_form_entry, ldap_add_entry, ldap_init3, ldap_operation
from .models import LDAPResource, Query
from .forms import QueryForm
@ -60,7 +60,9 @@ class NewQueryView(CreateView):
def post(self, request, *args, **kwargs):
data = request.POST
connector = LDAPResource.objects.get(slug=self.kwargs['connector_slug'])
return HttpResponse("foo "+str(connector)+" "+self.kwargs['connector_slug'])
#return HttpResponse("foo "+str(connector)+" "+self.kwargs['connector_slug'])
#return HttpResponse(str(handle))
return HttpResponse(str(ldap_operation(connector, data)))
def get_context_data(self, **kwargs):
ctx = super(NewQueryView, self).get_context_data(**kwargs)