X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-useradd;h=6dd82d9ad3652c1b846a05af0e8a79f78b03ba01;hb=fe67fab54bca15f4820e4f0a911023ed10a743b7;hp=d14edee2e4b7cb6818f292717a9e6a67a97f91ff;hpb=db0949115e2a549d3e8f5a71852422b853327293;p=mirror%2Fuserdir-ldap.git diff --git a/ud-useradd b/ud-useradd index d14edee..6dd82d9 100755 --- a/ud-useradd +++ b/ud-useradd @@ -51,7 +51,7 @@ def ShouldIgnoreID(uid): # search through all UIDs. def GetFreeID(l): Attrs = l.search_s(BaseBaseDn,ldap.SCOPE_SUBTREE, - "uidNumber=*",["uidNumber", "gidNumber", "uid"]); + "(|(uidNumber=*)(gidNumber=*))",["uidNumber", "gidNumber", "uid"]); HighestUID = 0; gids = []; uids = []; @@ -180,7 +180,7 @@ while 1: cn = GetAttr(Attrs[0],"cn"); sn = GetAttr(Attrs[0],"sn"); mn = GetAttr(Attrs[0],"mn"); - if privsub == None or privsub == "": + if privsub is None or privsub == "": privsub = " "; break; else: @@ -249,7 +249,7 @@ if GuestAccount: shadowExpire = int(time.time() / 3600 / 24) + exp res = raw_input("Hosts to grant access to: ") for h in res.split(): - if not '.' in h: h = h + '.' + HostDomain + if '.' not in h: h = h + '.' + HostDomain if exp > 0: h = h + " " + datetime.datetime.fromtimestamp( time.time() + exp * 24*3600 ).strftime("%Y%m%d") hostacl.append(h) @@ -267,7 +267,7 @@ if Update == 0 or ForceMail == 1: CryptedPass = GPGEncrypt("Your new password is '" + Password + "'\n",\ "0x"+Keys[0][1],UsePGP2); Password = None; - if CryptedPass == None: + if CryptedPass is None: raise "Error","Password Encryption failed" else: Pass = HashPass(Password); @@ -390,7 +390,7 @@ if Update == 1 and ForceMail == 0: # Send the Welcome message print "Sending Welcome Email" -templatepath = TemplatesDir + "/welcome-message-%d" % int(gidNumber) +templatepath = TemplatesDir + "/welcome-message-%s" % supplementaryGid if not os.path.exists(templatepath): templatepath = TemplatesDir + "/welcome-message" Reply = TemplateSubst(Subst,open(templatepath, "r").read())