add ldap, check if active member, create user and give console perms, retry getting mac, better handling of rtp

This commit is contained in:
Jordan Rodgers 2018-01-19 03:01:10 -05:00
parent 8161d97f21
commit cc2033f2ca
11 changed files with 136 additions and 58 deletions

24
ldapdb.py Normal file
View file

@ -0,0 +1,24 @@
from csh_ldap import CSHLDAP
from flask import current_app as app
def connect_ldap():
try:
ldap = CSHLDAP(app.config['LDAP_BIND_DN'],
app.config['LDAP_BIND_PW'])
except:
print("Unable to connect to LDAP.")
raise
return ldap
def is_rtp(user):
ldap = connect_ldap()
rtp_group = ldap.get_group('rtp')
return rtp_group.check_member(ldap.get_member(user, uid=True))
def is_active(ldap, user):
ldap = connect_ldap()
rtp_group = ldap.get_group('active')
return rtp_group.check_member(ldap.get_member(user, uid=True))