3 # Checks the passwd file to make sure all entries are in the directory
5 import string, ldap, getopt, sys, os;
6 from userdir_ldap import *;
8 def PassCheck(l,File,HomePrefix):
11 # Fetch all the users and generate a map out of them
12 Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=*",\
13 ["uid","uidnumber","gidnumber","loginshell"]);
16 if x[1].has_key("uid") == 0:
18 UIDMap[x[1]["uid"][0]] = x[1];
20 # Iterate over every user in the passwd file
26 Split = string.split(Line,":");
27 if UIDMap.has_key(Split[0]) == 0:
31 Ats = UIDMap[Split[0]];
33 if Ats.has_key("uidnumber") and Ats["uidnumber"][0] != Split[2]:
35 if Ats.has_key("uidnumber") and Ats["gidnumber"][0] != Split[3]:
37 if Ats.has_key("homedirectory") and \
38 split[5] != HomePrefix + Split[0]:
41 print "mismatch",Split[0],Miss;
43 # Connect to the ldap server
44 l = ldap.open(LDAPServer);
45 l.simple_bind_s("","");
47 PassCheck(l,sys.argv[1],sys.argv[2]);