diff --git a/www/index.py b/www/index.py
index e981d82..6bb4987 100755
--- a/www/index.py
+++ b/www/index.py
@@ -3,7 +3,7 @@ import os, sys, pymysql, re, time
from ldap3 import Server, Connection, NTLM
def application(environ, start_response):
- #sys.stdout._encoding = 'utf-8'
+ #sys.stdout._encoding = 'utf-8'замена сцепления патриот стоимость работ смоленск
status = '200 OK'
# проверяем наличие параметров в запросе и всяко-разно реагируем
if environ['QUERY_STRING'] == '':
@@ -17,7 +17,9 @@ def application(environ, start_response):
elif paramDict.get('query_type') == 'report':
output = bytes((header() + body() + ReportForm() + ReportData(environ) + footer()).encode('utf8'))
elif paramDict.get('query_type') == 'ldap':
- output = bytes((header() + body() + getLDAPusers() + footer()).encode('utf8'))
+ domain = paramDict.get('domain')
+ group = paramDict.get('group')
+ output = bytes((header() + body() + getLDAPusers(domain, group) + footer()).encode('utf8'))
else:
output = bytes((header() + body() + footer()).encode('utf8'))
@@ -48,14 +50,15 @@ def menu():
txtMenu = '
\n'
return txtMenu
-# Список внутренних номеров из СУБД
+
def getInternalNumbers():
conn = connectDB()
c = conn.cursor()
@@ -66,33 +69,65 @@ def getInternalNumbers():
listHeader = '№ п/п | \n' \
'Телефон | \n' \
'ФИО | \n' \
- 'Описание | Эл.почта |
\n'
+ 'Описание | Электро-почта | \n'
result = result + listHeader
for row in c.fetchall():
- rowData = "%s | %s | %s | %s | %s |
\n" % (row[0], row[1], row[2], row[4], row[3], row[3])
+ rowData = "%s | %s | %s | %s | %s |
\n" % (row[0], row[1], row[2], row[4], row[3])
result = result + rowData
return (result + "
\n")
-# Список пользователей (ФИО, телефон, почта, отдел) из LDAP (AD)
-def getLDAPusers():
+# Список пользователей (ФИО, телефон, почта, отдел) из LDAP (AD)
+def getLDAPusers(domain, group):
order = 'int_number'
- result = 'Список абонентов ЛТБ
'
- listHeader = '№ п/п | \n' \
- 'Телефон | \n' \
- 'ФИО | \n' \
- 'Описание | Эл.почта |
\n'
+ if domain == 'domain1':
+ head = 'Для внешних абонентов звонить на xxxxxx + добавочный номер
'
+ org = '1'
+ s = Server('192.168.1.1')
+ c = Connection(s, user='domain1\\phone', password="pass", authentication=NTLM)
+ # perform the Bind operation
+ if not c.bind():
+ print('error in bind', c.result)
+ c.search('OU=users,dc=domain1,dc=local', '(objectclass=person)',
+ attributes=['cn', 'mail', 'telephoneNumber', 'department', 'title', 'mobile'])
+ elif domain == 'domain2':
+ head = 'Для внешних абонентов звонить на xxxxxxx + добавочный номер
'
+ org = '2'
+ s = Server('192.168.2.2')
+ c = Connection(s, user='domain2\\phone', password="pass", authentication=NTLM)
+ # perform the Bind operation
+ if not c.bind():
+ print('error in bind', c.result)
+ c.search('OU=users,dc=domain2,dc=local', '(objectclass=person)',
+ attributes=['cn', 'mail', 'telephoneNumber', 'department', 'title', 'mobile'])
+ elif domain == 'domain3':
+ head = 'Для внешних абонентов звонить на xxxxxxx + добавочный номер
'
+ org = '3'
+ s = Server('192.168.3.3')
+ c = Connection(s, user='domain3\\phone', password="pass", authentication=NTLM)
+ # perform the Bind operation
+ if not c.bind():
+ print('error in bind', c.result)
+ c.search('OU=users,dc=domain3,dc=local', '(objectclass=person)',
+ attributes=['cn', 'mail', 'telephoneNumber', 'department', 'title', 'mobile'])
+
+ result = 'Список абонентов %s
\n%s' % (org, head)
+
+ #return (result + "
\n")
+
+ # listHeader = '\n' \
+ # 'ФИО | \n' \
+ # 'Отдел | Должность | \n' \
+ # 'Телефон | \n' \
+ # 'Эл.почта | Мобильный телефон |
\n'
+ listHeader = '\n' \
+ 'ФИО | \n' \
+ 'Отдел | Должность | \n' \
+ 'Телефон | \n' \
+ 'Эл.почта | Мобильный телефон |
\n'
+
result = result + listHeader
- # define the server and the connection
- s = Server('1.1.1.1')
- c = Connection(s, user="DOMEN\\user", password="some-pass", authentication=NTLM)
- # perform the Bind operation
- if not c.bind():
- print('error in bind', c.result)
- c.search('OU=LTB_users,dc=dals,dc=local', '(objectclass=person)',
- attributes=['cn', 'mail', 'telephoneNumber', 'department'])
- # print(c.result)
for item in c.entries:
# print(item)
# item = re.sub('\n', '', str(item))
@@ -108,6 +143,11 @@ def getLDAPusers():
dep = department.groups()[1]
else:
dep = ""
+ title = re.search("(title:)(.+?)(\n)", item)
+ if title:
+ title = title.groups()[1]
+ else:
+ title = ""
mail = re.search("(mail:)(.+?)(\n)", item)
if mail:
mail = mail.groups()[1]
@@ -118,11 +158,15 @@ def getLDAPusers():
phone = telephone.groups()[1]
else:
phone = ""
- rowData = " | %s | %s | %s | %s |
\n" % (name, phone, dep, mail, mail)
+ mobile = re.search("(mobile:)(.+?)(\n)", item)
+ if mobile:
+ mobile = mobile.groups()[1]
+ else:
+ mobile = ""
+ rowData = "%s | %s | %s | %s | %s | %s |
\n" % (name, dep, title, phone, mail, mail, mobile)
result = result + rowData
return (result + "
\n")
-
def getCOline():
conn = connectDB()
c = conn.cursor()
@@ -200,9 +244,9 @@ def ErrorMessage(txt):
def connectDB():
c = pymysql.connect(
- db='ats_test',
+ db='ats',
user='ats',
- passwd='',
- host='kis',
+ passwd='pass',
+ host='x.x.x.x',
charset='utf8')
return c