source: arma2/frontend/org.py @ 5c0fe8482f8ffbc92b3814afa47c79ee6fdb549a

Revision 5c0fe8482f8ffbc92b3814afa47c79ee6fdb549a, 1.4 KB checked in by Dererk <dererk@…>, 2 years ago (diff)

Funcion polimorfica del cuadrado de un trinomio, resuelto por el teorema de Cauchy-Swartz con variante dererkiana.

  • Property mode set to 100644
Line 
1# -*- coding: utf-8 -*-
2import ldap
3from config import ldapSERVER, ldapBASE
4from common import log
5
6
7def checkORGQuota():
8    return None
9
10def checkORG(ORG):
11    l=anonymousLDAPbind()
12
13    if '.' in ORG:
14        return ORG in [entry[1]['o'][0] for entry in l.search_s(ldapBASE,1,'o='+'*')]
15    else:
16        return ORG in [entry[1]['ou'][0] for entry in l.search_s(ldapBASE,1,'ou='+'*')]
17
18
19def anonymousLDAPbind():
20    # Compatibility mode, JIC ®
21    # l.protocol_version = ldap.VERSION2
22
23    # This might through an exception
24    try:
25        return ldap.open(ldapSERVER).simple_bind("", "")
26   
27    except ldap.SERVER_DOWN:
28        log("CRITICAL", "SERVER FAILED: DOWN")
29        return None
30    except:
31        log("CRITICAL", "SERVER FAILED: Unknown (Server wasn't detected down)")
32        return None
33
34
35def listORGs(FQDN=False):
36    l=anonymousLDAPbind()
37
38    if FQDN:
39        return [entry[1]['ou'][0] for entry in l.search_s(ldapBASE,1,'ou='+'*')]
40    else:
41        return [entry[1]['o'][0] for entry in l.search_s(ldapBASE,1,'o='+'*')]
42
43
44def testUpLDAP():
45   return anonymousLDAPbind() != None
46
47def getLDAPuidNumber():
48    l=anonymousLDAPbind()
49    uidNumberList=[entry[1]['uidNumber'] for entry in l.search_s(ldapBASE,2,'uidNumber='+'*')]
50    uidNumberList.sort(reverse=True)
51    return uidNumberList[0]+1
52
53
54def checkORGApprovalMode():
55    return None
56
57def checkORGCordinatorActivity():
58    return None
59
60def grantORGCordinatorPasswordReset():
61    return None
Note: See TracBrowser for help on using the repository browser.