Commit 37b3832b authored by Valentin Samir's avatar Valentin Samir

[sip] Gestion dynamique du multidial (pour les numéros associé a un droit ldap)

On a donc un fonction pour convertir un droit ldap en liste de numéro
parent db5de1a8
......@@ -36,12 +36,17 @@ class Profile(object):
cur.close()
conn.close()
def right_to_nums(self, right):
conn=lc_ldap.shortcuts.lc_ldap_readonly()
ret=conn.search(u"(&(droits=%s)(!(chbre=EXT)))" % right)
return [ "1%04d" % adh['aid'][0].value for adh in ret]
def alias_to_num(self, alias):
try:
conn=lc_ldap.shortcuts.lc_ldap_readonly()
ret=conn.search(u"(|(uid=%(alias)s)(mailAlias=%(alias)s@crans.org)(canonicalAlias=%(alias)s@crans.org))" % {'alias' : alias})
if len(ret) == 1:
return "1" + str(ret[0]['aid'][0])
return "1%04d" % ret[0]['aid'][0].value
else:
return "NONE"
except:
......
#!/bin/bash /usr/scripts/python.sh
# -*- coding: utf-8 -*-
import sys
from sip.asterisk import Profile
if __name__ == '__main__' :
if len(sys.argv)>1:
profile = Profile()
nums=profile.right_to_nums(sys.argv[1])
if nums:
sys.stdout.write('SIP/' + '&SIP/'.join(nums))
else:
sys.stdout.write('NONE')
else:
print >> sys.stderr, "Usage %s {right}" % sys.argv[0]
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