shadowlastchange_1prof.py
1 |
#!/usr/bin/python2.5
|
---|---|
2 |
|
3 |
# -*- coding: utf-8 -*-
|
4 |
|
5 |
# Script python
|
6 |
#
|
7 |
# Modification du champ shadowLastChange de l'annuaire LDAP
|
8 |
# pour contourner le blocage des utilisateurs anciens sur les clients Ubuntu
|
9 |
#
|
10 |
# Laurent.Brillard@ac-reunion.fr
|
11 |
#
|
12 |
# Pour executer : python shadowlastchange_1prof.py <login_prof> <valeur_shadowlastchange_voulue>
|
13 |
|
14 |
import sys |
15 |
|
16 |
fichier = open("ModifLDAP.log","a") |
17 |
|
18 |
from scribe import enseignants |
19 |
from scribe.enseignants import Enseignant |
20 |
login = sys.argv[1]
|
21 |
slc_voulue = sys.argv[2]
|
22 |
ldapuser = Enseignant() |
23 |
ldapuser.ldap_admin.connect() |
24 |
slc_lue_ldap = ldapuser._get_attr(login, 'shadowLastChange')
|
25 |
slc_lue = slc_lue_ldap[0]
|
26 |
|
27 |
if int(slc_lue) < int(slc_voulue): |
28 |
ldapuser._set_attr(login, 'shadowLastChange', slc_voulue)
|
29 |
ldapuser._touch(login) |
30 |
log = login + " shadowlastchange change de " + slc_lue + " a " + slc_voulue |
31 |
print log
|
32 |
log = "\n" + log
|
33 |
fichier.write(log) |
34 |
else:
|
35 |
log = login + " shadowlastchange reste a " + slc_lue
|
36 |
print log
|
37 |
log = "\n" + log
|
38 |
fichier.write(log) |
39 |
# ldapuser._set_attr(login, 'shadowMax', '9999')
|
40 |
ldapuser.ldap_admin.close() |
41 |
|