4 import string, re, time, ldap, getopt, sys, pwd, os, posix;
5 from userdir_ldap import *;
7 # Main program starts here
8 User = pwd.getpwuid(posix.getuid())[0];
10 (options, arguments) = getopt.getopt(sys.argv[1:], "au:")
11 for (switch, val) in options:
17 # Connect to the ldap server
18 l = ldap.open(LDAPServer);
19 print "Accessing LDAP directory as '" + User + "'";
20 Password = getpass(User + "'s password: ");
21 UserDn = "uid=" + User + "," + BaseDn;
22 l.simple_bind_s(UserDn,Password);
24 Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"userpassword=*",\
25 ["uid","cn","mn","sn","userpassword"]);
29 if x[1].has_key("userpassword") == 0: continue;
30 Passwd = x[1]["userpassword"][0];
31 if string.find(Passwd,"*LK*") != -1 or string.find(Passwd,"}*") != -1:
33 if len(Passwd) > 21: continue;
35 print EmailAddress(x);
37 UserDn = "uid=" + x[1]["uid"][0] + "," + BaseDn;
39 Pass = "{crypt}" + HashPass(Password);
40 l.modify_s(UserDn,[(ldap.MOD_REPLACE,"userpassword",Pass)]);