ajout support base de donnée pour ips
This commit is contained in:
parent
3d415a9347
commit
f1c9b6e522
@ -14,12 +14,14 @@ brie/websetup.py
|
||||
brie/config/__init__.py
|
||||
brie/config/app_cfg.py
|
||||
brie/config/environment.py
|
||||
brie/config/groups_enum.py
|
||||
brie/config/ldap_config.py
|
||||
brie/config/middleware.py
|
||||
brie/controllers/__init__.py
|
||||
brie/controllers/administration.py
|
||||
brie/controllers/auth.py
|
||||
brie/controllers/edit.py
|
||||
brie/controllers/import_actions.py
|
||||
brie/controllers/error.py
|
||||
brie/controllers/rooms.py
|
||||
brie/controllers/root.py
|
||||
brie/controllers/show.py
|
||||
@ -27,8 +29,8 @@ brie/controllers/template.py
|
||||
brie/i18n/ru/LC_MESSAGES/brie.po
|
||||
brie/lib/__init__.py
|
||||
brie/lib/app_globals.py
|
||||
brie/lib/aurore_helper.py
|
||||
brie/lib/base.py
|
||||
brie/lib/camembert_helpers.py
|
||||
brie/lib/helpers.py
|
||||
brie/lib/ldap_helper.py
|
||||
brie/model/__init__.py
|
||||
@ -45,6 +47,9 @@ brie/templates/__init__.py
|
||||
brie/templates/__init__.pyc
|
||||
brie/templates/index.html
|
||||
brie/templates/login_widget.html
|
||||
brie/templates/administration/__init__.py
|
||||
brie/templates/administration/__init__.pyc
|
||||
brie/templates/administration/index.html
|
||||
brie/templates/auth/__init__.py
|
||||
brie/templates/auth/__init__.pyc
|
||||
brie/templates/auth/login.html
|
||||
@ -56,8 +61,9 @@ brie/templates/edit/member.html
|
||||
brie/templates/edit/member_room_interface_edit_views.html
|
||||
brie/templates/edit/room.html
|
||||
brie/templates/edit/wifi.html
|
||||
brie/templates/error/__init__.py
|
||||
brie/templates/error/permission_denied.html
|
||||
brie/templates/models/__init__.py
|
||||
brie/templates/models/__init__.pyc
|
||||
brie/templates/models/about.html
|
||||
brie/templates/models/authentication.html
|
||||
brie/templates/models/debug.html
|
||||
|
@ -41,6 +41,26 @@ class EditController(AuthenticatedBaseController):
|
||||
|
||||
#end class
|
||||
|
||||
class MachineController(AuthenticatedBaseController):
|
||||
require_group = groups_enum.admin
|
||||
|
||||
|
||||
class MachineDeleteController(AuthenticatedRestController):
|
||||
require_group = groups_enum.admin
|
||||
|
||||
@expose()
|
||||
def post(self, residence, member_uid, machine_id):
|
||||
member = Member.get_by_uid(self.user, residence, member_uid)
|
||||
machine = Machine.get_machine_by_id(self.user, member.dn, machine_id)
|
||||
if machine is not None:
|
||||
self.user.ldap_bind.delete_entry_subtree(machine.dn)
|
||||
#end if
|
||||
|
||||
redirect("/edit/room/" + residence + "/" + member_uid)
|
||||
#end def
|
||||
#end def
|
||||
|
||||
|
||||
class WifiRestController(AuthenticatedRestController):
|
||||
require_group = groups_enum.respsalleinfo
|
||||
|
||||
|
33
Brie/brie/model/briedb.py
Normal file
33
Brie/brie/model/briedb.py
Normal file
@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Sample model module."""
|
||||
|
||||
from sqlalchemy import *
|
||||
from sqlalchemy.orm import mapper, relation
|
||||
from sqlalchemy import Table, ForeignKey, Column
|
||||
from sqlalchemy.types import Integer, Unicode
|
||||
from sqlalchemy.dialects.postgresql import MACADDR, INET, BOOLEAN, DATE
|
||||
#from sqlalchemy.orm import relation, backref
|
||||
|
||||
from brie.model import DeclarativeBase, metadata, DBSession
|
||||
|
||||
class Residences(DeclarativeBase):
|
||||
__tablename__ = "residences"
|
||||
|
||||
name = Column(Unicode(128), primary_key=True)
|
||||
|
||||
#end class
|
||||
|
||||
class Ips(DeclarativeBase):
|
||||
__tablename__ = "ips"
|
||||
|
||||
def __init__(self, ip, residence, taken):
|
||||
self.ip = ip
|
||||
self.residence = residence
|
||||
self.taken = taken
|
||||
#end
|
||||
|
||||
ip = Column(Unicode(512), primary_key=True)
|
||||
residence = Column(Unicode(128), nullable=False)
|
||||
taken = Column(BOOLEAN, nullable=False)
|
||||
|
||||
#end class
|
@ -147,7 +147,7 @@ class Machine(object):
|
||||
#end def
|
||||
|
||||
@staticmethod
|
||||
def get_machines_of_member(user_session, member_dn):
|
||||
def get_machine_tuples_of_member(user_session, member_dn):
|
||||
results = user_session.ldap_bind.search(member_dn, "(objectClass=organizationalRole)")
|
||||
machines = list()
|
||||
for result in results:
|
||||
@ -155,13 +155,25 @@ class Machine(object):
|
||||
dns = user_session.ldap_bind.search_first(result.dn, "(objectClass=dlzGenericRecord)")
|
||||
if dhcp is not None and dns is not None:
|
||||
mac = dhcp.dhcpHWAddress.first().replace("ethernet ", "")
|
||||
machines.append((dhcp.cn.first(), mac, dns.dlzData.first())) # tuple
|
||||
machines.append(
|
||||
(
|
||||
dhcp.cn.first(),
|
||||
mac,
|
||||
dns.dlzData.first(),
|
||||
result.cn.first()
|
||||
) #tuple
|
||||
)
|
||||
#end if
|
||||
#end for
|
||||
|
||||
return machines
|
||||
#end def
|
||||
|
||||
@staticmethod
|
||||
def get_machine_by_id(user_session, member_dn, machine_id):
|
||||
return user_session.ldap_bind.search_first(member_dn, "(cn=" + machine_id + ")")
|
||||
#end def
|
||||
|
||||
#end class
|
||||
|
||||
class Groupes(object):
|
||||
|
@ -37,13 +37,14 @@ beaker.session.secret = somesecret
|
||||
# %(here) may include a ':' character on Windows environments; this can
|
||||
# invalidate the URI when specifying a SQLite db via path name
|
||||
#sqlalchemy.url=postgresql://camembert:CamembertDB%40Pacat@172.17.22.7:5432/camembert
|
||||
sqlalchemy.url=postgresql://brie:brie@localhost/brie
|
||||
# sqlalchemy.url=mysql://username:password@hostname:port/databasename
|
||||
|
||||
|
||||
# If you have sqlite, here's a simple default to get you started
|
||||
# in development
|
||||
|
||||
sqlalchemy.url = sqlite:///%(here)s/devdata.db
|
||||
#sqlalchemy.url = sqlite:///%(here)s/devdata.db
|
||||
#echo shouldn't be used together with the logging module.
|
||||
#sqlalchemy.echo = false
|
||||
#sqlalchemy.echo_pool = false
|
||||
|
32
Brie/foo
32
Brie/foo
@ -1,32 +0,0 @@
|
||||
Boubakar OUATTARA
|
||||
boubakar.ouattara
|
||||
chambre 456 etage 4 aile nord
|
||||
Boubakar OUATTARA
|
||||
Tocha ZAABAY
|
||||
tocha.zaabay
|
||||
chambre 465 etage 4 aile nord
|
||||
Tocha ZAABAY
|
||||
Claude ALGOURDIN
|
||||
claude.algourdin
|
||||
chambre 418 etage 4 aile sud
|
||||
Claude ALGOURDIN
|
||||
Rachid CHEDRA
|
||||
rachid.chedra
|
||||
chambre 217 etage 2 aile sud
|
||||
Rachid CHEDRA
|
||||
Guillaume LETOUPIN
|
||||
guillaume.letoupin
|
||||
chambre 232 etage 2 aile sud
|
||||
Guillaume LETOUPIN
|
||||
erica MINUZ
|
||||
erica.minuz
|
||||
chambre 374 etage 3 aile nord
|
||||
Erica MINUZ
|
||||
FLAVIA MACHADO DOMINGUES
|
||||
flavia.machadodomingue
|
||||
chambre 452 etage 4 aile nord
|
||||
flavia.machadodomingue not found
|
||||
SOPHIA ID SALAH
|
||||
sophia.idsalah
|
||||
chambre 360 etage 3 aile nord
|
||||
Sophia ID SALAH
|
@ -1,130 +0,0 @@
|
||||
from paste.deploy import appconfig
|
||||
from pylons import config
|
||||
|
||||
from brie.config.environment import load_environment
|
||||
|
||||
conf = appconfig('config:development.ini', relative_to='.')
|
||||
load_environment(conf.global_conf, conf.local_conf)
|
||||
|
||||
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 *
|
||||
|
||||
#bind = Ldap.connect("uid=roven.gabriel," + ldap_config.username_base_dn, "foobar")
|
||||
bind = Ldap.connect("uid=admin,ou=Administrators,ou=TopologyManagement,o=netscaperoot", "t734DSSL61")
|
||||
|
||||
members = bind.search(ldap_config.username_base_dn, "(objectClass=pacatnetMember)")
|
||||
|
||||
def roomOrNone(member):
|
||||
if member.has("roomNumber"):
|
||||
return member.roomNumber.first()
|
||||
return None
|
||||
#end def
|
||||
|
||||
def first(items):
|
||||
for item in items:
|
||||
return item
|
||||
|
||||
return None
|
||||
#end def
|
||||
|
||||
nextuid = 30000
|
||||
|
||||
|
||||
base_chambres_dn = "ou=chambres," + ldap_config.base_dn
|
||||
|
||||
|
||||
results = DBSession.query(UserPacaterie)
|
||||
|
||||
for user in results:
|
||||
uid = Translations.to_uid(user.prenom, user.nom)
|
||||
print uid
|
||||
|
||||
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
|
||||
|
||||
print machine_dn
|
||||
|
||||
machine_attributes = {
|
||||
"objectClass" : ["top", "organizationalRole"],
|
||||
"cn" : str(machine_id)
|
||||
}
|
||||
|
||||
bind.add_entry(machine_dn, machine_attributes)
|
||||
|
||||
dhcp_dn = "cn=" + str(machine.name) + "," + machine_dn
|
||||
|
||||
print dhcp_dn
|
||||
|
||||
dhcp_attributes = {
|
||||
"objectClass" : ["top", "uidObject", "dhcpHost"],
|
||||
"cn" : str(machine.name),
|
||||
"uid" : "machine_membre",
|
||||
"dhcpHWAddress" : str("ethernet " + machine.mac),
|
||||
"dhcpStatements" : str("fixed-address " + machine.name)
|
||||
}
|
||||
|
||||
bind.add_entry(dhcp_dn, dhcp_attributes)
|
||||
|
||||
mac_auth_dn = "cn=mac," + machine_dn
|
||||
|
||||
print mac_auth_dn
|
||||
|
||||
flat_mac = str(machine.mac).replace(":", "")
|
||||
|
||||
print flat_mac
|
||||
|
||||
mac_auth_attributes = {
|
||||
"objectClass" : ["top", "organizationalRole", "simpleSecurityObject", "uidObject"],
|
||||
"cn" : "mac",
|
||||
"uid" : flat_mac,
|
||||
"userPassword" : flat_mac
|
||||
}
|
||||
|
||||
bind.add_entry(mac_auth_dn, mac_auth_attributes)
|
||||
|
||||
dns_dn = "dlzHostName=" + machine.name + "," + machine_dn
|
||||
|
||||
print dns_dn
|
||||
|
||||
dns_attributes = {
|
||||
"objectClass" : ["top", "dlzAbstractRecord", "dlzGenericRecord"],
|
||||
"dlzData" : str(machine.ip),
|
||||
"dlzHostName" : str(machine.name),
|
||||
"dlzRecordId" : "1",
|
||||
"dlzTTL" : "3600",
|
||||
"dlzType" : "A"
|
||||
}
|
||||
|
||||
bind.add_entry(dns_dn, dns_attributes)
|
||||
|
||||
machine_id = 1 + machine_id
|
||||
|
||||
#end for machine
|
||||
|
||||
|
||||
|
||||
#end for
|
@ -1,107 +0,0 @@
|
||||
from paste.deploy import appconfig
|
||||
from pylons import config
|
||||
|
||||
from brie.config.environment import load_environment
|
||||
|
||||
conf = appconfig('config:development.ini', relative_to='.')
|
||||
load_environment(conf.global_conf, conf.local_conf)
|
||||
|
||||
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 *
|
||||
|
||||
#bind = Ldap.connect("uid=roven.gabriel," + ldap_config.username_base_dn, "foobar")
|
||||
bind = Ldap.connect("uid=admin,ou=Administrators,ou=TopologyManagement,o=netscaperoot", "t734DSSL61")
|
||||
|
||||
members = bind.search(ldap_config.username_base_dn, "(objectClass=pacatnetMember)")
|
||||
|
||||
def roomOrNone(member):
|
||||
if member.has("roomNumber"):
|
||||
return member.roomNumber.first()
|
||||
return None
|
||||
#end def
|
||||
|
||||
def first(items):
|
||||
for item in items:
|
||||
return item
|
||||
|
||||
return None
|
||||
#end def
|
||||
|
||||
nextuid = 30000
|
||||
|
||||
|
||||
base_chambres_dn = "ou=chambres," + ldap_config.base_dn
|
||||
|
||||
|
||||
results = DBSession.query(Room)
|
||||
|
||||
for room in results:
|
||||
ldap_room = bind.search_first(base_chambres_dn, "(cn=" + room.name + ")")
|
||||
member_of = {
|
||||
"x-memberIn" : None
|
||||
}
|
||||
|
||||
try:
|
||||
bind.delete_attr(ldap_room.dn, member_of)
|
||||
print "deleted " + ldap_room.dn
|
||||
except:
|
||||
pass
|
||||
#end try
|
||||
|
||||
#end for
|
||||
|
||||
|
||||
results = DBSession.query(UserPacaterie, Room).filter(UserPacaterie.idroom == Room.idroom)
|
||||
|
||||
for (user, room) in results:
|
||||
uid = Translations.to_uid(user.prenom, user.nom)
|
||||
print uid
|
||||
|
||||
member = bind.search_first(ldap_config.username_base_dn, "(uid=" + uid + ")")
|
||||
|
||||
print room.name
|
||||
|
||||
member_dn = ""
|
||||
|
||||
if member is None:
|
||||
member_dn = "uid=" + uid + ",ou=2012," + ldap_config.username_base_dn
|
||||
|
||||
mail = user.mail
|
||||
if mail is None:
|
||||
mail = ""
|
||||
attributes = {
|
||||
"objectClass" : ["top", "person", "organizationalPerson", "inetOrgPerson", "pacatnetMember", "pykotaAccount", "posixAccount"],
|
||||
"uid" :(uid).encode("utf-8"),
|
||||
"cn" : (user.prenom + " " + user.nom.upper()).encode("utf-8"),
|
||||
"sn" : (user.nom.upper()).encode("utf-8"),
|
||||
"givenName" : (user.prenom).encode("utf-8"),
|
||||
"uidNumber" : str(-1),
|
||||
"gidNumber" : "10000",
|
||||
"homeDirectory" : ("/net/home/" + uid).encode("utf-8"),
|
||||
"mail" : (mail).encode("utf-8"),
|
||||
"loginShell" : "/usr/bin/zsh".encode("utf-8")
|
||||
}
|
||||
|
||||
bind.add_entry(member_dn, attributes)
|
||||
|
||||
else:
|
||||
member_dn = member.dn
|
||||
#end if
|
||||
|
||||
|
||||
|
||||
ldap_room = bind.search_first(base_chambres_dn, "(cn=" + room.name + ")")
|
||||
|
||||
print ldap_room.dn
|
||||
print member_dn
|
||||
|
||||
new_member_of = {
|
||||
"x-memberIn" : str(member_dn)
|
||||
}
|
||||
|
||||
bind.replace_attr(ldap_room.dn, new_member_of)
|
||||
#end for
|
@ -1,70 +0,0 @@
|
||||
from paste.deploy import appconfig
|
||||
from pylons import config
|
||||
|
||||
from brie.config.environment import load_environment
|
||||
|
||||
conf = appconfig('config:development.ini', relative_to='.')
|
||||
load_environment(conf.global_conf, conf.local_conf)
|
||||
|
||||
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 *
|
||||
|
||||
#bind = Ldap.connect("uid=roven.gabriel,ou=2011," + ldap_config.username_base_dn, "foobar")
|
||||
bind = Ldap.connect("uid=admin,ou=Administrators,ou=TopologyManagement,o=netscaperoot", "t734DSSL61")
|
||||
|
||||
members = bind.search(ldap_config.username_base_dn, "(&(ou:dn:=2011)(objectClass=pacatnetMember))")
|
||||
|
||||
def roomOrNone(member):
|
||||
if member.has("roomNumber"):
|
||||
return member.roomNumber.first()
|
||||
return None
|
||||
#end def
|
||||
|
||||
def first(items):
|
||||
for item in items:
|
||||
return item
|
||||
|
||||
return None
|
||||
#end def
|
||||
|
||||
nextuid = 30000
|
||||
|
||||
def add(uid, user, room_dn, nextuid):
|
||||
user_dn = "uid=" + uid + "," + ldap_config.username_base_dn
|
||||
mail = user.mail
|
||||
if mail is None:
|
||||
mail = ""
|
||||
attributes = {
|
||||
"objectClass" : ["top", "person", "organizationalPerson", "inetOrgPerson", "pacatnetMember", "pykotaAccount", "posixAccount"],
|
||||
"uid" :(uid).encode("utf-8"),
|
||||
"cn" : (user.prenom + " " + user.nom.upper()).encode("utf-8"),
|
||||
"sn" : (user.nom.upper()).encode("utf-8"),
|
||||
"givenName" : (user.prenom).encode("utf-8"),
|
||||
"uidNumber" : str(nextuid),
|
||||
"gidNumber" : "10000",
|
||||
"homeDirectory" : ("/net/home/" + uid).encode("utf-8"),
|
||||
"mail" : (mail).encode("utf-8"),
|
||||
"x-room" : (room_dn).encode("utf-8"),
|
||||
"loginShell" : "/usr/bin/zsh".encode("utf-8")
|
||||
}
|
||||
|
||||
bind.add_entry(user_dn, attributes)
|
||||
|
||||
#end def
|
||||
|
||||
filestream = open("people_to_change.txt", "r")
|
||||
|
||||
for line in filestream:
|
||||
uid = line.strip()
|
||||
print "++" + uid + "++"
|
||||
print "ou=2010," + ldap_config.username_base_dn
|
||||
result = bind.search_first(ldap_config.username_base_dn, "(uid=" + uid + ")")
|
||||
bind.rename_entry(result.dn, "uid=" + result.uid.first(), "ou=2010," + ldap_config.username_base_dn)
|
||||
|
||||
#end for
|
||||
|
||||
|
@ -1,80 +0,0 @@
|
||||
from paste.deploy import appconfig
|
||||
from pylons import config
|
||||
|
||||
from brie.config.environment import load_environment
|
||||
|
||||
conf = appconfig('config:development.ini', relative_to='.')
|
||||
load_environment(conf.global_conf, conf.local_conf)
|
||||
|
||||
from brie.config import ldap_config
|
||||
from brie.lib.ldap_helper import *
|
||||
|
||||
from brie.model import DBSession
|
||||
from brie.model.camembert import *
|
||||
|
||||
import socket
|
||||
|
||||
#bind = Ldap.connect("uid=roven.gabriel,ou=2010," + ldap_config.username_base_dn, "foobar")
|
||||
bind = Ldap.connect("uid=admin,ou=Administrators,ou=TopologyManagement,o=netscaperoot", "t734DSSL61")
|
||||
|
||||
members = bind.search(ldap_config.username_base_dn, "(objectClass=pacatnetMember)")
|
||||
|
||||
def roomOrNone(member):
|
||||
if member.has("roomNumber"):
|
||||
return member.roomNumber.first()
|
||||
return None
|
||||
#end def
|
||||
|
||||
def first(items):
|
||||
for item in items:
|
||||
return item
|
||||
|
||||
return None
|
||||
#end def
|
||||
|
||||
def area(room_number):
|
||||
floor_number = room_number % 100
|
||||
|
||||
if floor_number <= 33:
|
||||
return "sud"
|
||||
else:
|
||||
return "nord"
|
||||
#end if
|
||||
#end def
|
||||
|
||||
results = DBSession.query(Room, Materiel, Interface).filter(Room.idinterface == Interface.idinterface).filter(Interface.idmateriel == Materiel.idmateriel)
|
||||
|
||||
for room, materiel, interface in results:
|
||||
aile = area(room.idroom)
|
||||
etage = str(room.idroom / 100)
|
||||
|
||||
base_chambres_dn = "ou=chambres," + ldap_config.base_dn
|
||||
|
||||
other_dn = "cn=" + etage + ",cn=" + aile + "," + base_chambres_dn
|
||||
|
||||
full_dn = "cn=" + room.name + "," + other_dn
|
||||
|
||||
print room
|
||||
|
||||
switch_ip = socket.gethostbyname(str(materiel.hostname))
|
||||
|
||||
|
||||
attributes = {
|
||||
"objectClass" : "pacaterieRoom",
|
||||
"cn" : str(room.name),
|
||||
"x-switch" : str(switch_ip),
|
||||
"x-switchInterface" : str(interface.ifname)
|
||||
}
|
||||
|
||||
|
||||
print str(room.idinterface)
|
||||
|
||||
print full_dn
|
||||
try:
|
||||
bind.replace_attr(full_dn, attributes)
|
||||
except ldap.NO_SUCH_OBJECT:
|
||||
bind.add_entry(full_dn, attributes)
|
||||
# print attributes
|
||||
#end for
|
||||
|
||||
|
@ -1,59 +0,0 @@
|
||||
from paste.deploy import appconfig
|
||||
from pylons import config
|
||||
|
||||
from brie.config.environment import load_environment
|
||||
|
||||
conf = appconfig('config:development.ini', relative_to='.')
|
||||
load_environment(conf.global_conf, conf.local_conf)
|
||||
|
||||
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 *
|
||||
|
||||
#bind = Ldap.connect("uid=roven.gabriel," + ldap_config.username_base_dn, "foobar")
|
||||
bind = Ldap.connect("uid=admin,ou=Administrators,ou=TopologyManagement,o=netscaperoot", "t734DSSL61")
|
||||
|
||||
members = bind.search(ldap_config.username_base_dn, "(objectClass=pacatnetMember)")
|
||||
|
||||
def roomOrNone(member):
|
||||
if member.has("roomNumber"):
|
||||
return member.roomNumber.first()
|
||||
return None
|
||||
#end def
|
||||
|
||||
def first(items):
|
||||
for item in items:
|
||||
return item
|
||||
|
||||
return None
|
||||
#end def
|
||||
|
||||
nextuid = 30000
|
||||
|
||||
|
||||
base_chambres_dn = "ou=chambres," + ldap_config.base_dn
|
||||
|
||||
|
||||
results = DBSession.query(Room, Interface).filter(Room.idinterface == Interface.idinterface).order_by(Room.name)
|
||||
|
||||
for (room, interface) in results:
|
||||
ldap_room = bind.search_first(base_chambres_dn, "(cn=" + room.name + ")")
|
||||
print ldap_room.dn
|
||||
|
||||
switch_id = {
|
||||
"x-switchInterface" : str(interface.idinterface)
|
||||
}
|
||||
|
||||
bind.replace_attr(ldap_room.dn, switch_id)
|
||||
|
||||
uid_attr = {
|
||||
"objectClass" : "uidObject",
|
||||
"uid" : str(room.idroom)
|
||||
}
|
||||
|
||||
bind.add_attr(ldap_room.dn, uid_attr)
|
||||
|
||||
#end for
|
Loading…
Reference in New Issue
Block a user