X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-generate;h=c44870179d2988969bf63f63d4bffde730843fa2;hb=059c1ab2073bf678019edafff8c515ed1d2c341a;hp=303f9f564651867438b6da967c8f7a4776446510;hpb=a10f6e27cfde5e7cf7fba28f00f73b8d5f52aeb0;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index 303f9f5..c448701 100755 --- a/ud-generate +++ b/ud-generate @@ -608,15 +608,13 @@ def GenPrivate(File): # Write out the position for each user for x in DebianDDUsers: - if x[1].has_key("privateSub") == 0: + a = UDLdap.Account(x[0], x[1]) + if not a.is_active_user(): continue - - # If the account has no PGP key, do not write it - if x[1].has_key("keyFingerPrint") == 0: + if not 'privateSub' in a: continue - try: - Line = "%s"%(GetAttr(x, "privateSub")) + Line = "%s"%(a['privateSub']) Line = Sanitize(Line) + "\n" F.write(Line) except: @@ -640,22 +638,13 @@ def GenDisabledAccounts(File): I = 0 for x in PasswdAttrs: - if x[1].has_key("uidNumber") == 0: + a = UDLdap.Account(x[0], x[1]) + if a.pw_active(): continue - - Pass = GetAttr(x, "userPassword") - Line = "" - # *LK* is the reference value for a locked account - # password starting with ! is also a locked account - if Pass.find("*LK*") != -1 or Pass.startswith("!"): - # Format is : - Line = "%s:%s" % (GetAttr(x, "uid"), "Account is locked") - DisabledUsers.append(x) - - if Line != "": - F.write(Sanitize(Line) + "\n") - - + Line = "%s:%s" % (a['uid'], "Account is locked") + DisabledUsers.append(x) + F.write(Sanitize(Line) + "\n") + # Oops, something unspeakable happened. except: Die(File, F, None) @@ -1104,7 +1093,7 @@ for x in Attrs: SubGroupMap.setdefault(x[1]["gid"][0], []).extend(x[1]["subGroup"]) # Fetch all the users -PasswdAttrs = l.search_s(BaseDn, ldap.SCOPE_ONELEVEL, "uid=*",\ +PasswdAttrs = l.search_s(BaseDn, ldap.SCOPE_ONELEVEL, "(&(uid=*)(!(uidNumber=0)))",\ ["uid", "uidNumber", "gidNumber", "supplementaryGid",\ "gecos", "loginShell", "userPassword", "shadowLastChange",\ "shadowMin", "shadowMax", "shadowWarning", "shadowInactive",