4 # Copyright (c) 2001 Jason Gunthorpe <jgg@debian.org>
5 # Copyright (c) 2004 Joey Schulze <joey@debian.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 import string, re, time, ldap, getopt, sys, pwd, os, posix;
22 from userdir_ldap import *;
24 # Main program starts here
25 User = pwd.getpwuid(posix.getuid())[0];
27 (options, arguments) = getopt.getopt(sys.argv[1:], "au:")
28 for (switch, val) in options:
34 # Connect to the ldap server
35 l = passwdAccessLDAP(LDAPServer, BaseDn, User)
37 Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"userpassword=*",\
38 ["uid","cn","mn","sn","userpassword"]);
42 if x[1].has_key("userpassword") == 0: continue;
43 Passwd = x[1]["userpassword"][0];
44 if string.find(Passwd,"*LK*") != -1 or string.find(Passwd,"}*") != -1:
46 if len(Passwd) > 21: continue;
48 print EmailAddress(x);
50 UserDn = "uid=" + x[1]["uid"][0] + "," + BaseDn;
52 Pass = "{crypt}" + HashPass(Password);
53 l.modify_s(UserDn,[(ldap.MOD_REPLACE,"userpassword",Pass)]);