3 # Checks the passwd file to make sure all entries are in the directory
5 import 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 = Line.split(":")
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
45 l.simple_bind_s("","");
47 PassCheck(l,sys.argv[1],sys.argv[2]);