Commit 9a8fb3c4 authored by Vincent Le gallic's avatar Vincent Le gallic

lc_ldap.shortcuts

parent 93164291
......@@ -7,8 +7,8 @@ import datetime
import time
import re
import sys
sys.path.append('/usr/scripts/lc_ldap/')
import lc_ldap
sys.path.append('/usr/scripts/')
import lc_ldap.shortcuts
import lc_ldap.crans_utils
if settings.LOCATION == "o2":
......@@ -24,9 +24,9 @@ else:
ccups = None
if settings.BASE_LDAP_TEST:
cldap = lc_ldap.lc_ldap_test()
cldap = lc_ldap.shortcuts.lc_ldap_test()
else:
cldap = lc_ldap.lc_ldap_admin()
cldap = lc_ldap.shortcuts.lc_ldap_admin()
class Job(object):
......
......@@ -2,8 +2,6 @@
# -*- encoding: utf-8 -*-
import sys
sys.path.append('/usr/scripts/lc_ldap/')
import lc_ldap
from django.core.management.base import BaseCommand, CommandError
from intranet.apps.voip.models import Profile
......@@ -13,6 +11,5 @@ class Command(BaseCommand):
help = 'Génère une conf pour asterisk'
def handle(self, *args, **options):
conn = lc_ldap.lc_ldap()
for profile in Profile.objects.order_by('user__username').all():
self.stdout.write(profile.asterisk_config().encode('utf-8') + '\n')
......@@ -2,8 +2,6 @@
# -*- encoding: utf-8 -*-
import sys
sys.path.append('/usr/scripts/lc_ldap/')
import lc_ldap
from django.core.management.base import BaseCommand, CommandError
from intranet.apps.voip.models import Profile
......@@ -13,6 +11,5 @@ class Command(BaseCommand):
help = 'Génère une conf pour la boîte vocal d\'asterisk'
def handle(self, *args, **options):
conn = lc_ldap.lc_ldap()
for profile in Profile.objects.order_by('user__username').all():
self.stdout.write(profile.asterisk_alias_config().encode('utf-8') + '\n')
......@@ -2,8 +2,6 @@
# -*- encoding: utf-8 -*-
import sys
sys.path.append('/usr/scripts/lc_ldap/')
import lc_ldap
from django.core.management.base import BaseCommand, CommandError
from intranet.apps.voip.models import Profile
......@@ -13,6 +11,5 @@ class Command(BaseCommand):
help = 'Génère une conf pour la boîte vocal d\'asterisk'
def handle(self, *args, **options):
conn = lc_ldap.lc_ldap()
for profile in Profile.objects.order_by('user__username').all():
self.stdout.write(profile.asterisk_voicemail_config().encode('utf-8') + '\n')
......@@ -28,8 +28,8 @@ from django_cas.backends import CASBackend
# Pour se connecter à la base ldap
import sys
sys.path.append("/usr/scripts/lc_ldap")
import lc_ldap
sys.path.append("/usr/scripts/")
import lc_ldap.shortcuts
conn_pool = import_module('conn_pool', 'intranet')
......@@ -54,7 +54,7 @@ class CransCASBackend(CASBackend):
django_username = user.username
try:
conn = lc_ldap.lc_ldap_admin()
conn = lc_ldap.shortcuts.lc_ldap_admin(user=django_username)
ldap_user = conn.search('uid=%s' % django_username,\
scope = ldap.SCOPE_ONELEVEL)[0]
except IndexError:
......
......@@ -21,8 +21,8 @@
#
import time
import sys
sys.path.append("/usr/scripts/lc_ldap/")
import lc_ldap
sys.path.append("/usr/scripts/")
import lc_ldap.shortcuts
CONNS = {}
OBJECTS = {}
......@@ -33,7 +33,7 @@ LDAP_USER_TIMEOUT = 600
def get_conn(user):
if not user.username in CONNS.keys():
CONNS[user.username]= lc_ldap.lc_ldap_admin()
CONNS[user.username]= lc_ldap.shortcuts.lc_ldap_admin(user=user.username)
return CONNS[user.username]
def get_user(user, mode='ro', refresh=False):
......
......@@ -28,8 +28,8 @@ from django.utils.importlib import import_module
# Pour se connecter à la base ldap
import sys
sys.path.append("/usr/scripts/lc_ldap")
import lc_ldap
sys.path.append("/usr/scripts/")
import lc_ldap.shortcuts
conn_pool = import_module('conn_pool', 'intranet')
......@@ -44,9 +44,9 @@ class LDAPUserBackend(ModelBackend):
if not username or not password:
return None
lc_class = lc_ldap.lc_ldap_test if settings.BASE_LDAP_TEST else lc_ldap.lc_ldap
shortcut = lc_ldap.shortcuts.lc_ldap_test if settings.BASE_LDAP_TEST else lc_ldap.shortcuts.lc_ldap
try:
conn = lc_class(user = username, cred = password)
conn = shortcut(user = username, cred = password)
myself = conn.search(dn = conn.dn, scope = ldap.SCOPE_BASE)
ldap_user = myself[0]
except IndexError:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment