Changeset 1105

Show
Ignore:
Timestamp:
07/28/03 11:11:12 (21 years ago)
Author:
jalet
Message:

PyKota now tries to add its attributes intelligently in existing LDAP
directories.

Location:
pykota/trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r1089 r1105  
    2323# 
    2424# $Log$ 
     25# Revision 1.55  2003/07/28 09:11:12  jalet 
     26# PyKota now tries to add its attributes intelligently in existing LDAP 
     27# directories. 
     28# 
    2529# Revision 1.54  2003/07/21 06:32:42  jalet 
    2630# Prevents email messages to be sent at modification/creation time for 
     
    445449                else :         
    446450                    self.logger.log_message(_("Prototype object %s not found in Quota Storage.") % protoentry.Name) 
     451                     
    447452            if not options["noquota"] :     
    448453                if hardlimit is None :     
     
    469474                    if not options["groups"] : 
    470475                        changed[entry.Name]["ingroups"] = [] 
    471                 if not entrypquota.Exists : 
     476                         
     477                if not entry.Exists :         
    472478                    # not found 
    473479                    if options["add"] : 
     
    477483                        # only remotely 
    478484                        if self.isValidName(entry.Name) : 
    479                             if not entry.Exists : 
    480                                 entry = getattr(self.storage, "add%s" % suffix)(entry) 
    481                             entrypquota = getattr(self.storage, "add%sPQuota" % suffix)(entry, printer) 
     485                            entry = getattr(self.storage, "add%s" % suffix)(entry) 
    482486                        else :     
    483487                            if options["groups"] : 
     
    485489                            else :     
    486490                                self.logger.log_message(_("Invalid user name %s") % entry.Name) 
     491                                 
     492                if not entrypquota.Exists : 
     493                    # not found 
     494                    if options["add"] : 
     495                        entrypquota = getattr(self.storage, "add%sPQuota" % suffix)(entry, printer) 
     496                         
    487497                if not entrypquota.Exists :      
    488498                    self.logger.log_message(_("Quota not found for object %s on printer %s.") % (entry.Name, printer.Name)) 
  • pykota/trunk/conf/pykota.conf.sample

    r1095 r1105  
    7373#groupquotabase: ou=GQuotas,ou=PyKota,dc=librelogiciel,dc=com 
    7474#lastjobbase: ou=LastJobs,ou=PyKota,dc=librelogiciel,dc=com 
     75# 
     76# How to create new accounts and groups 
     77# authorized values are "below" and "attach(objectclass name)" 
     78# 
     79# "below" creates the new accounts/groups as standalone entries 
     80# below the above defined 'userbase' ou 
     81#  
     82# attach(objectclass name) tries to find some existing user/group 
     83# using the above defined 'userrdn' or 'grouprdn' and 'userbase' 
     84# 'groupbase', and attach the PyKota specific entries to it. 
     85# 
     86# a possible value:  newuser: attach(posixAccount) 
     87newuser : below 
     88newgroup : below 
     89 
    7590#  
    7691# Choose what attribute contains the list of group members 
  • pykota/trunk/NEWS

    r1099 r1105  
    2222PyKota NEWS : 
    2323 
     24    - 1.14beta : 
     25     
     26        - Two new LDAP-specific configuration fields were introduced, 
     27          newuser and newgroup. Use them to specify if you want to add 
     28          quota information to existing entries or elsewhere. 
     29          See sample configuration file for details. 
     30           
    2431    - 1.14alpha9 : 
    2532     
  • pykota/trunk/pykota/config.py

    r1087 r1105  
    2121# 
    2222# $Log$ 
     23# Revision 1.34  2003/07/28 09:11:12  jalet 
     24# PyKota now tries to add its attributes intelligently in existing LDAP 
     25# directories. 
     26# 
    2327# Revision 1.33  2003/07/16 21:53:07  jalet 
    2428# Really big modifications wrt new configuration file's location and content. 
     
    231235                        "userquotabase", "groupquotabase", \ 
    232236                        "jobbase", "lastjobbase", \ 
     237                        "newuser", "newgroup", \ 
    233238                      ] : 
    234             ldapinfo[option] = self.getGlobalOption(option) 
     239            ldapinfo[option] = self.getGlobalOption(option).strip() 
     240        for field in ["newuser", "newgroup"] : 
     241            if ldapinfo[field].lower().startswith('attach(') : 
     242                ldapinfo[field] = ldapinfo[field][7:-1] 
    235243        return ldapinfo 
    236244         
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1099 r1105  
    2121# 
    2222# $Log$ 
     23# Revision 1.21  2003/07/28 09:11:12  jalet 
     24# PyKota now tries to add its attributes intelligently in existing LDAP 
     25# directories. 
     26# 
    2327# Revision 1.20  2003/07/25 10:41:30  jalet 
    2428# Better documentation. 
     
    468472    def addUser(self, user) :         
    469473        """Adds a user to the quota storage, returns it.""" 
    470         fields = { self.info["userrdn"] : user.Name, 
    471                    "objectClass" : ["pykotaObject", "pykotaAccount", "pykotaAccountBalance"], 
    472                    "cn" : user.Name, 
    473                    "pykotaUserName" : user.Name, 
    474                    "pykotaLimitBY" : (user.LimitBy or "quota"), 
    475                    "pykotaBalance" : str(user.AccountBalance or 0.0), 
    476                    "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), 
    477                  }  
    478         dn = "%s=%s,%s" % (self.info["userrdn"], user.Name, self.info["userbase"]) 
    479         self.doAdd(dn, fields) 
     474        newfields = { 
     475                       "pykotaUserName" : user.Name, 
     476                       "pykotaLimitBY" : (user.LimitBy or "quota"), 
     477                       "pykotaBalance" : str(user.AccountBalance or 0.0), 
     478                       "pykotaLifeTimePaid" : str(user.LifeTimePaid or 0.0), 
     479                    }    
     480        mustadd = 1 
     481        if self.info["newuser"].lower() != 'below' : 
     482            result = self.doSearch("(&(objectClass=%s)(%s=%s))" % (self.info["newuser"], self.info["userrdn"], user.Name), None, base=self.info["userbase"]) 
     483            if result : 
     484                (dn, fields) = result[0] 
     485                fields["objectClass"].extend(["pykotaAccount", "pykotaAccountBalance"]) 
     486                fields.update(newfields) 
     487                self.doModify(dn, fields) 
     488                mustadd = 0 
     489                 
     490        if mustadd : 
     491            fields = { self.info["userrdn"] : user.Name, 
     492                       "objectClass" : ["pykotaObject", "pykotaAccount", "pykotaAccountBalance"], 
     493                       "cn" : user.Name, 
     494                     }  
     495            fields.update(newfields)          
     496            dn = "%s=%s,%s" % (self.info["userrdn"], user.Name, self.info["userbase"]) 
     497            self.doAdd(dn, fields) 
    480498        return self.getUser(user.Name) 
    481499         
    482500    def addGroup(self, group) :         
    483501        """Adds a group to the quota storage, returns it.""" 
    484         fields = { self.info["grouprdn"] : group.Name, 
    485                    "objectClass" : ["pykotaObject", "pykotaGroup"], 
    486                    "cn" : group.Name, 
    487                    "pykotaGroupName" : group.Name, 
    488                    "pykotaLimitBY" : (group.LimitBy or "quota"), 
    489                  }  
    490         dn = "%s=%s,%s" % (self.info["grouprdn"], group.Name, self.info["groupbase"]) 
    491         self.doAdd(dn, fields) 
     502        newfields = {  
     503                      "pykotaGroupName" : group.Name, 
     504                      "pykotaLimitBY" : (group.LimitBy or "quota"), 
     505                    }  
     506        mustadd = 1 
     507        if self.info["newgroup"].lower() != 'below' : 
     508            result = self.doSearch("(&(objectClass=%s)(%s=%s))" % (self.info["newgroup"], self.info["grouprdn"], group.Name), None, base=self.info["groupbase"]) 
     509            if result : 
     510                (dn, fields) = result[0] 
     511                fields["objectClass"].extend(["pykotaGroup"]) 
     512                fields.update(newfields) 
     513                self.doModify(dn, fields) 
     514                mustadd = 0 
     515                 
     516        if mustadd : 
     517            fields = { self.info["grouprdn"] : group.Name, 
     518                       "objectClass" : ["pykotaObject", "pykotaGroup"], 
     519                       "cn" : group.Name, 
     520                     }  
     521            fields.update(newfields)          
     522            dn = "%s=%s,%s" % (self.info["grouprdn"], group.Name, self.info["groupbase"]) 
     523            self.doAdd(dn, fields) 
    492524        return self.getGroup(group.Name) 
    493525         
  • pykota/trunk/pykota/version.py

    r1099 r1105  
    2121# 
    2222 
    23 __version__ = "1.14alpha9_unofficial" 
     23__version__ = "1.14beta_unofficial" 
    2424 
    2525__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" 
  • pykota/trunk/setup.py

    r1095 r1105  
    2323# 
    2424# $Log$ 
     25# Revision 1.21  2003/07/28 09:11:12  jalet 
     26# PyKota now tries to add its attributes intelligently in existing LDAP 
     27# directories. 
     28# 
    2529# Revision 1.20  2003/07/23 16:51:32  jalet 
    2630# waitprinter.sh is now included to prevent PyKota from asking the 
     
    241245            sys.stderr.write("INSTALLATION ABORTED FOR SECURITY REASONS.\n") 
    242246            sys.exit(-1) 
     247             
     248        # warns for new LDAP fields     
     249        if sb.get("storagebackend") == "ldapstorage" :     
     250            newuser = conf.getGlobalOption("newuser", ignore=1) 
     251            newgroup = conf.getGlobalOption("newgroup", ignore=1) 
     252            if not (newuser and newgroup) : 
     253                sys.stderr.write("From version 1.14 on, PyKota LDAP Support needs two additional configuration fields.\n") 
     254                sys.stderr.write("Please put the 'newuser' and 'newgroup' configuration fields in a [global] section in /etc/pykota/pykota.conf\n") 
     255                sys.stderr.write("You can look at the conf/pykota.conf.sample file for examples.\n") 
     256                sys.stderr.write("YOU HAVE TO DO THESE MODIFICATIONS MANUALLY, AND RESTART THE INSTALLATION.\n") 
     257                sys.stderr.write("INSTALLATION ABORTED BECAUSE CONFIGURATION INCOMPLETE.\n") 
     258                sys.exit(-1) 
    243259         
    244260    # change files permissions