Import initial !
darcs-hash:20040831131446-d1718-0734aa73d3b8481b3b4b861e447e85128e488e8a.gz
This commit is contained in:
parent
c9083dfd86
commit
6626a44f15
20 changed files with 6494 additions and 0 deletions
41
gestion/chgpass.py
Executable file
41
gestion/chgpass.py
Executable file
|
@ -0,0 +1,41 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: iso-8859-15 -*-
|
||||
|
||||
import getpass, commands, os
|
||||
|
||||
import ldap_secret
|
||||
|
||||
def chgpass(dn) :
|
||||
print "Le mot de passe tapé ne sera pas écris à l'écran."
|
||||
print "Taper Ctrl-C pour abandonner"
|
||||
|
||||
try :
|
||||
|
||||
while 1 :
|
||||
mdp = getpass.getpass('Nouveau mot de passe :')
|
||||
mdp1 = getpass.getpass('Retaper mot de passe :')
|
||||
|
||||
if mdp != mdp1 :
|
||||
print 'Les deux mots de passe entrés sont différents, réesayer'
|
||||
continue
|
||||
|
||||
# Test du mdp
|
||||
test = commands.getoutput('echo "%s" | /usr/sbin/crack_testlib' % mdp)
|
||||
|
||||
if test.split(':')[1] == ' ok' :
|
||||
break
|
||||
else :
|
||||
print test.split(':')[1]
|
||||
|
||||
# Changement mdp
|
||||
if os.system('/usr/bin/ldappasswd -x -D "%s" -w %s "%s" -s %s > /dev/null' % (ldap_secret.auth_dn, ldap_secret.password, dn, mdp) ):
|
||||
print 'Erreur lors du changement de mot de passe'
|
||||
else :
|
||||
print 'Changement effectué avec succès'
|
||||
|
||||
except KeyboardInterrupt :
|
||||
pass
|
||||
|
||||
if __name__ == '__main__' :
|
||||
print 'TODO : interface de sélection'
|
||||
chgpass('aid=10,dc=crans,dc=org')
|
Loading…
Add table
Add a link
Reference in a new issue