X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-info;h=4b0c10399da88fc545c0e28013ed51619892c886;hb=32e0c5640dc72acf4c362fd373f26be78a45a277;hp=b1d3b6ff785ed6a5c91dad3ed9baf4d6c19848cb;hpb=55004c1aa2b0c0e1dde3014f9b2535904e57adc4;p=mirror%2Fuserdir-ldap.git diff --git a/ud-info b/ud-info index b1d3b6f..4b0c103 100755 --- a/ud-info +++ b/ud-info @@ -45,7 +45,8 @@ AttrInfo = {"cn": ["First Name", 101], "latitude": ["Latitude",12], "longitude": ["Longitude",13], "comment": ["Comment",114], - "userpassword": ["Crypted Password",115]}; + "userpassword": ["Crypted Password",115], + "dnszoneentry": ["d.net Entry",116]}; AttrPrompt = {"cn": ["Common name or first name"], "mn": ["Middle name (or initial if it ends in a dot)"], @@ -67,6 +68,7 @@ AttrPrompt = {"cn": ["Common name or first name"], "member": ["LDAP Group Member for slapd ACLs"], "latitude": ["XEarth latitude in ISO 6709 format - see /usr/share/zoneinfo/zone.tab or etak.com"], "longitude": ["XEarth latitude in ISO 6709 format - see /usr/share/zoneinfo/zone.tab or etak.com"], + "dnszoneentry": ["DNS Zone fragment associated this this user"], "labeledurl": ["Web home page"]}; # Create a map of IDs to desc,value,attr @@ -119,27 +121,22 @@ def PrintKeys(Attrs): First = 1; else: print "%-24s:" % (""), + print FormatPGPKey(x); - # PGP Print - if (len(x) == 32): - I = 0; - while (I < len(x)): - print x[I]+x[I+1], - I = I + 2; - if I == 32/2: - print "", - elif (len(x) == 40): - # GPG Print - I = 0; - while (I < len(x)): - print x[I]+x[I+1]+x[I+2]+x[I+3], - I = I + 4; - if I == 40/2: - print "", +# Print the SSH RSA Authentication keys for a user +def PrintSshRSAKeys(Attrs): + if Attrs[1].has_key("sshrsaauthkey") == 0: + return; + First = 0; + for x in Attrs[1]["sshrsaauthkey"]: + if First == 0: + print "%-24s:" % ("SSH RSA Auth Keys"), + First = 1; else: - print x, - print; + print "%-24s:" % (""), + print FormatSSHAuth(x); + # Display all of the attributes in a numbered list def ShowAttrs(Attrs): print; @@ -147,6 +144,7 @@ def ShowAttrs(Attrs): PrintModTime(Attrs); PrintShadow(Attrs); PrintKeys(Attrs); + PrintSshRSAKeys(Attrs); for at in Attrs[1].keys(): if AttrInfo.has_key(at): @@ -171,7 +169,8 @@ def ShowAttrs(Attrs): # Change a single attribute def ChangeAttr(Attrs,Attr): - if (Attr == "supplementarygid" or Attr == "allowedhosts" or Attr == "member"): + if (Attr == "supplementarygid" or Attr == "allowedhosts" or \ + Attr == "member" or Attr == "dnszoneentry"): return MultiChangeAttr(Attrs,Attr); print "Old value: '%s'" % (GetAttr(Attrs,Attr,"")); @@ -287,6 +286,9 @@ if (RootMode == 1): # Query the server for all of the attributes Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=" + User); +if len(Attrs) == 0: + print "User",User,"was not found."; + sys.exit(0); # repeatedly show the account configuration while(1): @@ -311,9 +313,13 @@ while(1): NewUser = raw_input("User? "); if NewUser == "": continue; + NAttrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=" + NewUser); + if len(NAttrs) == 0: + print "User",NewUser,"was not found."; + continue; + Attrs = NAttrs; User = NewUser; UserDn = "uid=" + User + "," + BaseDn; - Attrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=" + User); OrderedIndex = copy.deepcopy(OrigOrderedIndex); continue;