dump_creds reset les mdp
This commit is contained in:
parent
8a5822d4df
commit
6173bc8e89
3 changed files with 55 additions and 25 deletions
|
@ -6,17 +6,35 @@ import pika
|
|||
import json
|
||||
import sys
|
||||
|
||||
from lc_ldap.shortcuts import lc_ldap_readonly
|
||||
from lc_ldap.shortcuts import lc_ldap_admin
|
||||
from affich_tools import prompt
|
||||
import lc_ldap.filter2 as filter
|
||||
|
||||
from client import Ticket
|
||||
|
||||
ldap = lc_ldap_readonly()
|
||||
ldap = lc_ldap_admin()
|
||||
|
||||
f = filter.human_to_ldap(sys.argv[1].decode('utf-8'))
|
||||
res = ldap.search(f)
|
||||
if len(res) > 1:
|
||||
conf_wifi_only = True
|
||||
conf_reset_password = False
|
||||
conf_filter = None
|
||||
|
||||
for arg in sys.argv[1:]:
|
||||
if arg == '--all':
|
||||
conf_wifi_only = False
|
||||
elif arg == '--pass':
|
||||
conf_reset_password = True
|
||||
elif arg.startswith('--'):
|
||||
print("Unknown arg")
|
||||
exit(12)
|
||||
else:
|
||||
conf_filter = arg
|
||||
|
||||
f = filter.human_to_ldap(conf_filter.decode('utf-8'))
|
||||
res = ldap.search(f, mode='rw')
|
||||
if not conf_filter:
|
||||
print("Give a filter !")
|
||||
exit(3)
|
||||
elif len(res) > 1:
|
||||
print("More than one result")
|
||||
exit(1)
|
||||
elif not res:
|
||||
|
@ -33,10 +51,14 @@ else:
|
|||
break
|
||||
|
||||
ticket = Ticket()
|
||||
if 'uid' in item and conf_reset_password:
|
||||
ticket.reset_password(item)
|
||||
if hasattr(item, 'machines'):
|
||||
for m in item.machines():
|
||||
ticket.add_machine(m)
|
||||
if not conf_wifi_only or 'machineWifi' in m['objectClass']:
|
||||
ticket.add_machine(m)
|
||||
else:
|
||||
ticket.add_machine(item)
|
||||
|
||||
ticket.print()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue