X-Git-Url: https://git.adam-barratt.org.uk/?p=mirror%2Fuserdir-ldap.git;a=blobdiff_plain;f=ud-ldapshow;h=43249a448f71e57c4a46d758ff6739407fc4680d;hp=5faef77f26bc7ab411b1440d09c8428a36535afd;hb=871ab5f2e8bda25130c70834052fa8fb020a5373;hpb=c50d88536a4feb3087d1aa802e110250cb2861fc diff --git a/ud-ldapshow b/ud-ldapshow index 5faef77..43249a4 100755 --- a/ud-ldapshow +++ b/ud-ldapshow @@ -4,20 +4,20 @@ # Call with nokey to generate a missing key report # Call with noforward to generate a missing .forward report -import string, re, time, ldap, getopt, sys; +import re, time, ldap, getopt, sys; from userdir_ldap import *; def ShowDups(Attrs,Len): for x in Attrs: - if x[1].has_key("keyfingerprint") == 0: + if x[1].has_key("keyFingerPrint") == 0: continue; Count = 0; - for I in x[1]["keyfingerprint"]: + for I in x[1]["keyFingerPrint"]: if len(I) == Len: Count = Count + 1; if Count > 1: - for I in x[1]["keyfingerprint"]: + for I in x[1]["keyFingerPrint"]: if len(I) == Len: print "%s: %s" % (EmailAddress(x),I); @@ -31,61 +31,95 @@ for (switch, val) in options: print "Connecting to LDAP directory"; # Connect to the ldap server -l = ldap.open(LDAPServer); +l = connectLDAP() l.simple_bind_s("",""); if arguments[0] == "nokey": - Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(!(keyfingerprint=*))",\ - ["uid","cn","sn","emailforward","comment"]); + Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(!(keyFingerPrint=*))",\ + ["uid","cn","sn","emailForward","comment"]); Attrs.sort(); for x in Attrs: print "Key Missing:",EmailAddress(x); - if GetAttr(x,"emailforward") != "": - print " ->",GetAttr(x,"emailforward"); + if GetAttr(x,"emailForward") != "": + print " ->",GetAttr(x,"emailForward"); if GetAttr(x,"comment") != "": print " :",GetAttr(x,"comment"); if arguments[0] == "noforward": - Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(!(emailforward=*))",\ - ["uid","cn","sn","emailforward","comment"]); + Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(!(emailForward=*))",\ + ["uid","cn","sn","emailForward","comment"]); Attrs.sort(); for x in Attrs: print "No Forward:",EmailAddress(x); if arguments[0] == "badpriv": - Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(&(!(keyfingerprint=*))(privatesub=*))",\ - ["uid","cn","sn","privatesub"]); + Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(&(!(keyFingerPrint=*))(privateSub=*))",\ + ["uid","cn","sn","privateSub"]); Attrs.sort(); for x in Attrs: - print EmailAddress(x)+": "+GetAttr(x,"privatesub"); + print EmailAddress(x)+": "+GetAttr(x,"privateSub"); if arguments[0] == "nopriv": - Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(&(keyfingerprint=*)(!(privatesub=*)))",\ - ["uid","cn","sn","privatesub"]); + Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(&(keyFingerPrint=*)(!(privateSub=*)))",\ + ["uid","cn","sn","privateSub"]); Attrs.sort(); for x in Attrs: - print " ",EmailAddress(x)+": "+GetAttr(x,"privatesub"); + print " ",EmailAddress(x)+": "+GetAttr(x,"privateSub"); if arguments[0] == "keymap": Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=*",\ - ["uid","cn","sn","keyfingerprint"]); + ["uid","cn","sn","keyFingerPrint"]); Attrs.sort(); for x in Attrs: - if x[1].has_key("keyfingerprint"): - for I in x[1]["keyfingerprint"]: + if x[1].has_key("keyFingerPrint"): + for I in x[1]["keyFingerPrint"]: print "%s: %s" % (EmailAddress(x),I); if arguments[0] == "devcount": - Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(&(keyfingerprint=*)(gidnumber=800))",\ + Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"(&(keyFingerPrint=*)(supplementaryGid=Debian))",\ ["uid"]); Count = 0; for x in Attrs: Count = Count + 1; print "There are",Count,"developers as of",time.strftime("%a, %d %b %Y %H:%M:%S +0000",time.gmtime(time.time())); +if arguments[0] == "echelon": + Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,\ + "(&(|(activity-pgp=*)(activity-from=*))(&(keyFingerPrint=*)(supplementaryGid=Debian)))",\ + ["activity-pgp","activity-from"]); + Count = 0; + PGPCount = 0; + for x in Attrs: + Count = Count + 1; + if x[1].has_key("activity-pgp"): + PGPCount = PGPCount + 1; + print "Echelon has seen",Count,"developers, with",PGPCount,"PGP confirms as of",time.strftime("%a, %d %b %Y %H:%M:%S +0000",time.gmtime(time.time())); + +if arguments[0] == "missing": + Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,\ + "(&(!(|(activity-pgp=*)(activity-from=*)))(&(keyFingerPrint=*)(supplementaryGid=Debian)))",\ + ["uid","cn","sn","mn"]); + Attrs.sort(); + for x in Attrs: + print EmailAddress(x); + +if arguments[0] == "keystat": + Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"keyFingerPrint=*",\ + ["keyFingerPrint"]); + KeyCount = 0; + GPGCount = 0; + for x in Attrs: + if x[1].has_key("keyFingerPrint"): + KeyCount = KeyCount + 1; + for I in x[1]["keyFingerPrint"]: + if len(I) == 40: + GPGCount = GPGCount + 1; + break; + print "There are",KeyCount,"accounts with PGP2/5 keys and",GPGCount,"of them have PGP5 keys"; + if arguments[0] == "multikeys": Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=*",\ - ["uid","cn","sn","keyfingerprint"]); + ["uid","cn","sn","keyFingerPrint"]); Attrs.sort();