radius/auth.py: contexte pour modifier la mac
This commit is contained in:
parent
d5bd1ec23e
commit
4564c6ece2
1 changed files with 5 additions and 6 deletions
|
@ -135,7 +135,6 @@ def get_prise(auth_data):
|
|||
|
||||
@use_ldap_admin
|
||||
def register_mac(auth_data, machine, conn):
|
||||
machine = conn.search(unicode(machine.dn.split(',',1)[0]), mode='rw')[0]
|
||||
for (key, value) in auth_data:
|
||||
if key == 'Calling-Station-Id':
|
||||
try:
|
||||
|
@ -144,9 +143,11 @@ def register_mac(auth_data, machine, conn):
|
|||
except:
|
||||
radiusd.radlog(radiusd.L_ERR, 'Cannot format MAC !')
|
||||
|
||||
if mac is not None:
|
||||
if mac is None:
|
||||
radiusd.radlog(radiusd.L_ERR, 'Cannot find MAC')
|
||||
return
|
||||
mac = unicode(mac.lower())
|
||||
|
||||
with conn.search(unicode(machine.dn.split(',',1)[0]), mode='rw')[0] as machine:
|
||||
radiusd.radlog(radiusd.L_INFO, 'Registering mac %s' % mac)
|
||||
machine['macAddress'] = mac
|
||||
machine.history_add(u'auth.py', u'macAddress (<automatique> -> %s)' % mac)
|
||||
|
@ -155,8 +156,6 @@ def register_mac(auth_data, machine, conn):
|
|||
radiusd.radlog(radiusd.L_INFO, 'Triggering komaz')
|
||||
trigger_generate('komaz')
|
||||
radiusd.radlog(radiusd.L_INFO, 'done ! (triggered komaz)')
|
||||
else:
|
||||
radiusd.radlog(radiusd.L_ERR, 'Cannot find MAC')
|
||||
|
||||
@use_ldap_admin
|
||||
@use_ldap
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue