diff --git a/Brie/brie/config/ldap_config.py b/Brie/brie/config/ldap_config.py index 6f728a6..f0e9c16 100644 --- a/Brie/brie/config/ldap_config.py +++ b/Brie/brie/config/ldap_config.py @@ -2,14 +2,10 @@ uri = "ldaps://172.17.31.4" -base_dn = "dc=pacaterie,dc=u-psud,dc=fr" +username_base_dn = "ou=membres," +room_base_dn = "ou=chambres," +group_base_dn = "ou=groupes," -username_base_dn = "ou=membres," + base_dn - -room_base_dn = "ou=chambres," + base_dn - -group_base_dn = "ou=groupes," + base_dn - -area_filter = "(objectClass=pacateriearea)" -floor_filter = "(objectClass=pacateriefloor)" -room_filter = "(objectClass=pacaterieRoom)" +aurore_dn = "dc=aurore,dc=u-psud,dc=fr" +parametres_aurore_dn = "ou=parametres," + aurore_dn +liste_residence_dn = "cn=residences," + parametres_aurore_dn diff --git a/Brie/brie/controllers/administration.py b/Brie/brie/controllers/administration.py index c872409..2c98b77 100644 --- a/Brie/brie/controllers/administration.py +++ b/Brie/brie/controllers/administration.py @@ -4,12 +4,8 @@ from tg import session from tg.controllers import redirect from tg.decorators import expose, validate -from brie.lib.camembert_helpers import * - from brie.config import ldap_config from brie.lib.ldap_helper import * -from brie.model import DBSession -from brie.model.camembert import Interface from brie.model.ldap import * from brie.controllers import auth @@ -22,13 +18,13 @@ class GroupAddMemberController(AuthenticatedRestController): @expose() def post(self, group_cn, user_dn): - groups_of_user = Groupes.get_by_user_dn(self.user, user_dn) + groups_of_user = Groupes.get_by_user_dn(self.user, self.user.residence_dn, user_dn) if group_cn in groups_of_user: redirect("/administration/") #end if - target_group = Groupes.get_by_cn(self.user, group_cn) + target_group = Groupes.get_by_cn(self.user, self.user.residence_dn, group_cn) if target_group is None: redirect("/administration/") @@ -47,10 +43,10 @@ class GroupController(AuthenticatedBaseController): @expose() def delete_member(self, group_cn, user_dn): - groups_of_user = Groupes.get_by_user_dn(self.user, user_dn) + groups_of_user = Groupes.get_by_user_dn(self.user, self.user.residence_dn, user_dn) if group_cn in groups_of_user: - target_group = Groupes.get_by_cn(self.user, group_cn) + target_group = Groupes.get_by_cn(self.user, self.user.residence_dn, group_cn) attr = Groupes.unique_member_attr(user_dn) self.user.ldap_bind.delete_attr(target_group.dn, attr) @@ -71,8 +67,8 @@ class AdministrationController(AuthenticatedBaseController): @expose("brie.templates.administration.index") def index(self): - groups = Groupes.get_all(self.user) - all_users = sorted(Member.get_all(self.user), key=lambda u: u.cn.first()) + groups = Groupes.get_all(self.user, self.user.residence_dn) + all_users = sorted(Member.get_all(self.user, self.user.residence_dn), key=lambda u: u.cn.first()) return { "user" : self.user, "groups_ldap" : groups, "all_users" : all_users } #end def diff --git a/Brie/brie/controllers/auth.py b/Brie/brie/controllers/auth.py index aa0c599..51e141f 100644 --- a/Brie/brie/controllers/auth.py +++ b/Brie/brie/controllers/auth.py @@ -7,6 +7,7 @@ from tg.decorators import expose, validate from brie.lib.base import BaseController from brie.config import ldap_config from brie.lib.ldap_helper import * +from brie.lib.aurore_helper import * from brie.model.ldap import Groupes class Groups(object): @@ -30,14 +31,18 @@ class User(object): ldap_bind = None attrs = None groups = None + residence_dn = None - def __init__(self, ldap_bind, attrs): + def __init__(self, ldap_bind, attrs, residence_dn = None): self.ldap_bind = ldap_bind self.attrs = attrs + self.residence_dn = residence_dn - groups = Groupes.get_by_user_dn(self, self.attrs.dn) + if attrs is not None: + groups = Groupes.get_by_user_dn(self, residence_dn, self.attrs.dn) - self.groups = Groups(groups) + self.groups = Groups(groups) + #end if #end def #end class @@ -54,12 +59,17 @@ class AuthHandler(object): return self.__anon_bind #end if #end def + + def get_anon_user(self): + return User(self.get_anon_bind(), None) + #end def - def login(self, username, password): + def login(self, residence_dn, username, password): if self.get_anon_bind() is None: return False - actual_user = self.get_anon_bind().search_first(ldap_config.username_base_dn, "(uid=" + username + ")") + user_base_dn = ldap_config.username_base_dn + residence_dn + actual_user = self.get_anon_bind().search_first(user_base_dn, "(uid=" + username + ")") if actual_user is None: return False @@ -72,7 +82,7 @@ class AuthHandler(object): attributes = bind.search_first(username_dn, "(uid=" + username + ")") - user = User(bind, attributes) + user = User(bind, attributes, residence_dn) AuthHandler.__users[username] = user @@ -153,17 +163,38 @@ class LoginRestController(RestController): @expose("brie.templates.auth.login") def get(self): - return dict(login = "", error = "") + residences = Residences.get_residences(current.get_anon_user()) + + return dict(residences = residences, login = "", error = "") + #end def @expose("brie.templates.auth.login") - def post(self, username, password): - success = current.login(username, password) + def post(self, residence, username, password): + anon_user = current.get_anon_user() + + residence_dn = Residences.get_dn_by_name(anon_user, residence) + + if residence_dn is None: + return dict( + login = username, + error = "erreur de résidence" + ) + #end if + + success = current.login(residence_dn, username, password) if success: redirect("/") #end if - return dict(login = username, error = "erreur de connexion") + residences = Residences.get_residences(anon_user) + + return dict( + residences = residences, + login = username, + residence = residence, + error = "erreur de connexion" + ) #end def diff --git a/Brie/brie/controllers/edit.py b/Brie/brie/controllers/edit.py index 9ceeb7c..352150c 100644 --- a/Brie/brie/controllers/edit.py +++ b/Brie/brie/controllers/edit.py @@ -4,17 +4,13 @@ from tg import session from tg.controllers import redirect from tg.decorators import expose, validate -from brie.lib.camembert_helpers import * - from brie.config import ldap_config from brie.config import groups_enum from brie.lib.ldap_helper import * -from brie.model import DBSession from brie.model.ldap import * from brie.controllers import auth from brie.controllers.auth import AuthenticatedBaseController, AuthenticatedRestController -from brie.controllers.import_actions import * from operator import itemgetter @@ -43,25 +39,6 @@ class EditController(AuthenticatedBaseController): return self.show.room(room_number) #end def - @expose("brie.templates.edit.interface") - def interface(self, interface_id): - return self.show.interface(interface_id) - #end def - - @expose("brie.templates.edit.import_from") - def import_from(self, room_number): - success = True - message = "" - -# try: - Migration.import_all(self.user.ldap_bind, room_number) -# except Exception as ex: -# success = False -# message = str(ex) - #end try - - return { "room_number" : room_number, "success" : success, "message" : message } - #end def #end class class WifiRestController(AuthenticatedRestController): @@ -74,7 +51,7 @@ class WifiRestController(AuthenticatedRestController): @expose("brie.templates.edit.wifi") def get(self, uid): - member = Member.get_by_uid(self.user, uid) + member = Member.get_by_uid(self.user, self.user.residence_dn, uid) if member is None: self.show.error_no_entry() @@ -86,7 +63,7 @@ class WifiRestController(AuthenticatedRestController): @expose("brie.templates.edit.wifi") def post(self, uid, password): - member = Member.get_by_uid(self.user, uid) + member = Member.get_by_uid(self.user, self.user.residence_dn, uid) if member is None: self.show.error_no_entry() diff --git a/Brie/brie/controllers/error.py b/Brie/brie/controllers/error.py index daf2d12..d9f0781 100644 --- a/Brie/brie/controllers/error.py +++ b/Brie/brie/controllers/error.py @@ -4,12 +4,10 @@ from tg import session from tg.controllers import redirect from tg.decorators import expose, validate -from brie.lib.camembert_helpers import * from brie.config import ldap_config from brie.lib.ldap_helper import * from brie.model import DBSession -from brie.model.camembert import Interface from brie.model.ldap import * from brie.controllers import auth diff --git a/Brie/brie/controllers/import_actions.py b/Brie/brie/controllers/import_actions.py deleted file mode 100644 index f17ae27..0000000 --- a/Brie/brie/controllers/import_actions.py +++ /dev/null @@ -1,151 +0,0 @@ -# -*- coding: utf-8 -*- - -from brie.config import ldap_config -from brie.lib.ldap_helper import * -from brie.lib.camembert_helpers import * - -from brie.model import DBSession -from brie.model.camembert import * -from brie.model.ldap import Machine, Member - -class Migration: - - @staticmethod - def first(target_list, default = None): - for item in target_list: - return item - #end for - - return default - #end def - - @staticmethod - def import_all(bind, target_id): - Migration.delete_room_member(bind, target_id) - Migration.import_member(bind, target_id) - Migration.import_machines(bind, target_id) - #end def - - @staticmethod - def delete_room_member(bind, target_id): - results = DBSession.query(Room).filter(Room.idroom == target_id) - - room = Migration.first(results) - - if not room is None: - ldap_room = bind.search_first(ldap_config.room_base_dn, "(cn=" + room.name + ")") - - print room.name - member_of = { - "x-memberIn" : None - } - - try: - bind.delete_attr(ldap_room.dn, member_of) - except: - pass - #end try - #end if - #end def - - @staticmethod - def import_member(bind, target_id): - results = DBSession.query(UserPacaterie, Room).filter(UserPacaterie.idroom == Room.idroom).filter(Room.idroom == target_id) - - user, room = Migration.first(results) - - if user is not None and room is not None: - uid = Translations.to_uid(user.prenom, user.nom) - - member = bind.search_first(ldap_config.username_base_dn, "(uid=" + uid + ")") - - member_dn = "" - if member is None: - member_dn = "uid=" + uid + ",ou=2012," + ldap_config.username_base_dn - - print member_dn - - mail = user.mail - if mail is None: - mail = "" - attributes = Member.entry_attr(uid, user.prenom, user.nom, mail, str(-1)) - bind.add_entry(member_dn, attributes) - - else: - member_dn = member.dn - #end if - - - - ldap_room = bind.search_first(ldap_config.room_base_dn, "(cn=" + room.name + ")") - - - new_member_of = { - "x-memberIn" : str(member_dn) - } - - bind.replace_attr(ldap_room.dn, new_member_of) - #end if - #end def - - @staticmethod - def import_machines(bind, target_id): - print target_id - - results = DBSession.query(UserPacaterie, Room).filter(UserPacaterie.idroom == Room.idroom).filter(Room.idroom == target_id) - user, room = Migration.first(results) - - print room.idroom - print user.idroom - - if user is None: return - - uid = Translations.to_uid(user.prenom, user.nom) - - member = bind.search_first(ldap_config.username_base_dn, "(uid=" + uid + ")") - - print member.dn - - machines = DBSession.query(Computer).filter(Computer.iduser == user.iduser) - - machine_id = 1 - - for machine in machines: - print machine_id - print machine.name - print machine.mac - print machine.ip - - machine_dn = "cn=" + str(machine_id) + "," + member.dn - - existant = bind.search_first(machine_dn, "(objectClass=*)") - - if existant is not None: - bind.delete_entry_subtree(existant.dn) - print "deleted : " + existant.dn - - - machine_attributes = Machine.entry_attr(machine_id) - bind.add_entry(machine_dn, machine_attributes) - - dhcp_dn = "cn=" + str(machine.name) + "," + machine_dn - dhcp_attributes = Machine.dhcp_attr(machine.name, machine.mac) - bind.add_entry(dhcp_dn, dhcp_attributes) - - mac_auth_dn = "cn=mac," + machine_dn - flat_mac = str(machine.mac).replace(":", "") - - mac_auth_attributes = Machine.auth_attr(flat_mac) - bind.add_entry(mac_auth_dn, mac_auth_attributes) - - dns_dn = "dlzHostName=" + machine.name + "," + machine_dn - dns_attributes = Machine.dns_attr(machine.name, machine.ip) - bind.add_entry(dns_dn, dns_attributes) - - machine_id = 1 + machine_id - - #end for machine - - #end def - -#end class diff --git a/Brie/brie/controllers/rooms.py b/Brie/brie/controllers/rooms.py index 7ea700f..3e62c47 100644 --- a/Brie/brie/controllers/rooms.py +++ b/Brie/brie/controllers/rooms.py @@ -3,13 +3,10 @@ from tg.controllers import redirect from tg.decorators import expose, validate from brie.lib.base import BaseController -from brie.lib.camembert_helpers import * - from brie.config import ldap_config from brie.config import groups_enum from brie.lib.ldap_helper import * -from brie.model import DBSession -from brie.model.camembert import * +from brie.lib.aurore_helper import * from brie.model.ldap import * from brie.controllers import auth @@ -47,54 +44,54 @@ class RoomsController(AuthenticatedBaseController): return sorted(name_items, key=itemgetter(0)) @expose("brie.templates.rooms.index") - def index(self): - result = DBSession.query(Interface) - - interfaces_dict = dict() - for interface in result: - interfaces_dict[str(interface.idinterface)] = interface - + def index(self, residence_name): stats = dict() areas = dict() - - rooms = self.user.ldap_bind.search(ldap_config.room_base_dn, ldap_config.room_filter) - - rooms = sorted(rooms, key = lambda a: a.cn.first()) - for room in rooms: - interface = interfaces_dict[room.get("x-switchInterface").first()] - - color = self.color_picker(interface.ifdescription) - if color in stats: - stats[color] = stats[color] + 1 - else: - stats[color] = 0 - #end if - - room_id = int(room.uid.first()) - floor = Translations.floor_of_room(room_id) - area = Translations.area_of_room(room_id) - - if area not in areas: - areas[area] = dict() - #end if - if floor not in areas[area]: - areas[area][floor] = [] - #end if + residence_dn = Residences.get_dn_by_name(self.user, residence_name) + if residence_dn is None: + raise Exception("unknown residence") + #end if - areas[area][floor].append((room, interface)) - #end for + for area in Room.get_areas(self.user, residence_dn): + areas[area] = dict() - return { "areas" : areas, "color_picker" : self.color_picker, "reverse_sorted_name" : self.reverse_sort_name, "sorted_name" : self.sort_name, "stats" : stats} + for floor in Room.get_floors(self.user, area.dn): + areas[area][floor] = list() + + for room in Room.get_rooms_of_floor(self.user, floor.dn): + areas[area][floor].append(room) + + + color = self.color_picker("foobar") + if color in stats: + stats[color] = stats[color] + 1 + else: + stats[color] = 0 + #end if + + #end for room + #end for floor + #end for area + + + return { + "areas" : areas, + "color_picker" : self.color_picker, + "reverse_sorted_name" : self.reverse_sort_name, + "sorted_name" : self.sort_name, + "stats" : stats, + "residence" : residence_name + } #end def @expose("brie.templates.rooms.index") - def preview(self, number): - if not number.isdigit(): redirect("/rooms/") + def preview(self, residence, number): + if not number.isdigit(): redirect("/rooms/" + residence) - index_result = self.index() + index_result = self.index(residence) - room = Room.get_by_uid(self.user, number) + room = Room.get_by_uid(self.user, self.user.residence_dn, number) member = None @@ -102,13 +99,7 @@ class RoomsController(AuthenticatedBaseController): member = Member.get_by_dn(self.user, room.get("x-memberIn").first()) - interface = ( - DBSession.query(Interface) - .filter(Interface.idinterface == room.get("x-switchInterface").first()) - .first() - ) - - preview = member, room, interface + preview = member, room index_result["preview"] = preview return index_result diff --git a/Brie/brie/controllers/root.py b/Brie/brie/controllers/root.py index 3c9d188..04598d0 100644 --- a/Brie/brie/controllers/root.py +++ b/Brie/brie/controllers/root.py @@ -7,8 +7,9 @@ from catwalk.tg2 import Catwalk from repoze.what import predicates from brie.lib.base import BaseController -from brie.model import DBSession, metadata +from brie.lib.aurore_helper import * from brie import model + #from brie.controllers.secure import SecureController import brie.controllers.auth as auth_handler from brie.controllers.auth import AuthRestController @@ -18,7 +19,6 @@ from brie.controllers.edit import EditController from brie.controllers.administration import AdministrationController from brie.controllers.error import ErrorController -from brie.model.camembert import Materiel __all__ = ['RootController'] @@ -38,7 +38,7 @@ class RootController(BaseController): """ # admin = Catwalk(model, DBSession) - + auth = AuthRestController() rooms = RoomsController() show = ShowController() @@ -48,10 +48,13 @@ class RootController(BaseController): @expose('brie.templates.index') def index(self): - """Handle the front-page.""" - materiel = DBSession.query(Materiel) user = auth_handler.current.get_user() + residence = None + + if user is not None: + residence = Residences.get_name_by_dn(user, user.residence_dn) + #end if - return { "user" : user, "materiel" : materiel } + return { "user" : user, "residence" : residence } #end def #end class diff --git a/Brie/brie/controllers/show.py b/Brie/brie/controllers/show.py index c5fe547..fa84fac 100644 --- a/Brie/brie/controllers/show.py +++ b/Brie/brie/controllers/show.py @@ -3,13 +3,9 @@ from tg import session from tg.controllers import redirect from tg.decorators import expose, validate - -from brie.lib.camembert_helpers import * - from brie.config import ldap_config from brie.lib.ldap_helper import * -from brie.model import DBSession -from brie.model.camembert import Interface +from brie.lib.aurore_helper import * from brie.model.ldap import * from brie.controllers import auth @@ -26,64 +22,50 @@ class ShowController(AuthenticatedBaseController): """ Affiche les détails du membre, de la chambre et de l'interface """ @expose("brie.templates.show.member") - def member(self, uid): - member = Member.get_by_uid(self.user, uid) + def member(self, residence, uid): + residence_dn = Residences.get_dn_by_name(self.user, residence) + + member = Member.get_by_uid(self.user, residence_dn, uid) if member is None: return self.error_no_entry() - room = Room.get_by_member_dn(self.user, member.dn) - interface = None + room = Room.get_by_member_dn(self.user, residence_dn, member.dn) - if room is not None: - interface = ( - DBSession.query(Interface) - .filter(Interface.idinterface == room.get("x-switchInterface").first()) - .first() - ) - #end if - machines = Machine.get_machines_of_member(self.user, member.dn) - groups = Groupes.get_by_user_dn(self.user, member.dn) + groups = Groupes.get_by_user_dn(self.user, residence_dn, member.dn) - return { "user" : self.user, "member_ldap" : member, "interface" : interface, "room_ldap" : room, "machines" : machines, "groups" : groups} + return { + "residence" : residence, + "user" : self.user, + "member_ldap" : member, + "room_ldap" : room, + "machines" : machines, + "groups" : groups + } #end def @expose("brie.templates.show.room") - def room(self, room_id): - room = Room.get_by_uid(self.user, room_id) + def room(self, residence, room_id): + residence_dn = Residences.get_dn_by_name(self.user, residence) + + room = Room.get_by_uid(self.user, residence_dn, room_id) if room is None: return self.error_no_entry() - interface = ( - DBSession.query(Interface) - .filter(Interface.idinterface == room.get("x-switchInterface").first()) - .first() - ) - member = None if room.has("x-memberIn"): member = Member.get_by_dn(self.user, room.get("x-memberIn").first()) - return { "user" : self.user, "interface" : interface, "room_ldap" : room, "member_ldap" : member } + return { + "residence" : residence, + "user" : self.user, + "room_ldap" : room, + "member_ldap" : member + } #end def - @expose("brie.templates.show.interface") - def interface(self, interface_id): - interface = ( - DBSession.query(Interface) - .filter(Interface.idinterface == interface_id) - .first() - ) - - if interface is None: - return self.error_no_entry() - - room = Room.get_by_interface(self.user, interface.idinterface) - - return { "user" : self.user, "interface" : interface, "room_ldap" : room } - #end def #end class diff --git a/Brie/brie/lib/aurore_helper.py b/Brie/brie/lib/aurore_helper.py new file mode 100644 index 0000000..709563d --- /dev/null +++ b/Brie/brie/lib/aurore_helper.py @@ -0,0 +1,32 @@ +from brie.config import ldap_config + +class Residences: + + @staticmethod + def get_dn_by_name(user_session, name): + result = user_session.ldap_bind.search_first(ldap_config.liste_residence_dn, "(cn=" + name + ")") + + if result is None: + return None + #end if + + return result.uniqueMember.first() + #end def + + @staticmethod + def get_name_by_dn(user_session, dn): + result = user_session.ldap_bind.search_first(ldap_config.liste_residence_dn, "(uniqueMember=" + dn + ")") + + if result is None: + return None + #end if + + return result.cn.first() + #end def + + @staticmethod + def get_residences(user_session): + return user_session.ldap_bind.search(ldap_config.liste_residence_dn, "(objectClass=groupOfUniqueNames)") + #end def +#end class + diff --git a/Brie/brie/lib/camembert_helpers.py b/Brie/brie/lib/camembert_helpers.py deleted file mode 100644 index 317db5d..0000000 --- a/Brie/brie/lib/camembert_helpers.py +++ /dev/null @@ -1,42 +0,0 @@ -# -*- coding: utf-8 -*- -import unicodedata - - -class Translations(object): - - @staticmethod - def to_uid(name, surname): - clean_name = Translations.strip_accents(name.replace(" ", "")).lower()[:15] - clean_surname = Translations.strip_accents(surname.replace(" ", "")).lower()[:15] - - return clean_name + "." + clean_surname - #end def - - @staticmethod - def floor_of_room(room): - return room / 100 - #end def - - @staticmethod - def area_of_room(room): - if Translations.floor_of_room(room) == 5: - return "crous" - - floor_number = room % 100 - - if floor_number <= 33: - return "sud" - else: - return "nord" - #end if - #end def - -#end class - - - - # http://stackoverflow.com/questions/517923/what-is-the-best-way-to-remove-accents-in-a-python-unicode-string - @staticmethod - def strip_accents(s): - return ''.join((c for c in unicodedata.normalize('NFD', s) if unicodedata.category(c) != 'Mn')) - #end def diff --git a/Brie/brie/model/ldap.py b/Brie/brie/model/ldap.py index a419aa9..4d22e13 100644 --- a/Brie/brie/model/ldap.py +++ b/Brie/brie/model/ldap.py @@ -27,13 +27,13 @@ class Member(object): #end def @staticmethod - def get_by_uid(user_session, uid): - return user_session.ldap_bind.search_first(ldap_config.username_base_dn, "(uid=" + uid + ")") + def get_by_uid(user_session, residence_dn, uid): + return user_session.ldap_bind.search_first(ldap_config.username_base_dn + residence_dn, "(uid=" + uid + ")") #end def @staticmethod - def get_all(user_session): - return user_session.ldap_bind.search(ldap_config.username_base_dn, "(objectClass=pacatnetMember)") + def get_all(user_session, residence_dn): + return user_session.ldap_bind.search(ldap_config.username_base_dn + residence_dn, "(objectClass=pacatnetMember)") #end def #end class @@ -41,23 +41,39 @@ class Member(object): class Room(object): @staticmethod - def get_by_name(user_session, name): - return user_session.ldap_bind.search_first(ldap_config.room_base_dn, "(&" + ldap_config.room_filter + "(cn=" + name + "))") + def get_by_name(user_session, residence_dn, name): + return user_session.ldap_bind.search_first(ldap_config.room_base_dn + residence_dn, "(&(objectClass=pacaterieRoom)(cn=" + name + "))") #end def @staticmethod - def get_by_uid(user_session, uid): - return user_session.ldap_bind.search_first(ldap_config.room_base_dn, "(&" + ldap_config.room_filter + "(uid=" + uid + "))") + def get_by_uid(user_session, residence_dn, uid): + return user_session.ldap_bind.search_first(ldap_config.room_base_dn + residence_dn, "(&(objectClass=pacaterieRoom)(uid=" + uid + "))") #end def @staticmethod - def get_by_member_dn(user_session, dn): - return user_session.ldap_bind.search_first(ldap_config.room_base_dn, "(&" + ldap_config.room_filter + "(x-memberIn=" + dn + "))") + def get_by_member_dn(user_session, residence_dn, dn): + return user_session.ldap_bind.search_first(ldap_config.room_base_dn + residence_dn, "(&(objectClass=pacaterieRoom)(x-memberIn=" + dn + "))") #end def @staticmethod - def get_by_interface(user_session, interface_id): - return user_session.ldap_bind.search_first(ldap_config.room_base_dn, "(&" + ldap_config.room_filter + "(x-switchInterface=" + str(interface_id) + "))") + def get_areas(user_session, residence_dn): + return user_session.ldap_bind.search(ldap_config.room_base_dn + residence_dn, "(objectClass=pacaterieArea)") + #end def + + @staticmethod + def get_floors(user_session, area_dn): + return user_session.ldap_bind.search(area_dn, "(objectClass=pacaterieFloor)") + #end def + + @staticmethod + def get_rooms_of_floor(user_session, floor_dn): + return user_session.ldap_bind.search(floor_dn, "(objectClass=pacaterieRoom)") + #end def + + @staticmethod + def get_rooms(user_session, residence_dn): + return user_session.ldap_bind.search(ldap_config.room_base_dn + residence_dn, "(objectClass=pacaterieRoom)") + #end def #end class @@ -151,8 +167,8 @@ class Machine(object): class Groupes(object): @staticmethod - def get_by_user_dn(user_session, user_dn): - results = user_session.ldap_bind.search(ldap_config.group_base_dn, "(&(objectClass=groupOfUniqueNames)(uniqueMember=" + user_dn + "))") + def get_by_user_dn(user_session, residence_dn, user_dn): + results = user_session.ldap_bind.search(ldap_config.group_base_dn + residence_dn, "(&(objectClass=groupOfUniqueNames)(uniqueMember=" + user_dn + "))") groups = list() @@ -165,15 +181,15 @@ class Groupes(object): #end def @staticmethod - def get_by_cn(user_session, cn): - results = user_session.ldap_bind.search_first(ldap_config.group_base_dn, "(&(objectClass=groupOfUniqueNames)(cn=" + cn + "))") + def get_by_cn(user_session, residence_dn, cn): + results = user_session.ldap_bind.search_first(ldap_config.group_base_dn + residence_dn, "(&(objectClass=groupOfUniqueNames)(cn=" + cn + "))") return results #end def @staticmethod - def get_all(user_session): - results = user_session.ldap_bind.search(ldap_config.group_base_dn, "(objectClass=groupOfUniqueNames)") + def get_all(user_session, residence_dn): + results = user_session.ldap_bind.search(ldap_config.group_base_dn + residence_dn, "(objectClass=groupOfUniqueNames)") return results #end def diff --git a/Brie/brie/templates/auth/login.html b/Brie/brie/templates/auth/login.html index a6f8351..2b6b3e6 100644 --- a/Brie/brie/templates/auth/login.html +++ b/Brie/brie/templates/auth/login.html @@ -1,4 +1,7 @@ - +
@@ -8,6 +11,22 @@ CONNEXION