Index: /pykota/trunk/conf/pykotadmin.conf.sample
===================================================================
--- /pykota/trunk/conf/pykotadmin.conf.sample (revision 2303)
+++ /pykota/trunk/conf/pykotadmin.conf.sample (revision 2418)
@@ -51,6 +51,7 @@
 
 #
-# THIS FILE CAN ONLY CONTAIN A [global] SECTION AND TWO FIELDS
-# NAMED storageadmin AND storageadminpw
+# THIS FILE CAN ONLY CONTAIN A [global] SECTION AND ONE MANDATORY
+# FIELD NAMED storageadmin, ALONG WITH THE FOLLOWING FOUR OPTIONAL
+# FIELDS : storageadminpw, storagebackend, storageserver, storagename.
 #
 
@@ -61,2 +62,6 @@
 # storageadminpw: Comment out if unused, or set to Quota Storage admin password
 
+# storagebackend: ldapstorage
+# storageserver: ldap://ldapmaster.example.com:389
+# storagename: dc=example,dc=com
+
Index: /pykota/trunk/pykota/storages/pgstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/pgstorage.py (revision 2302)
+++ /pykota/trunk/pykota/storages/pgstorage.py (revision 2418)
@@ -48,4 +48,5 @@
             port = -1         # Use PostgreSQL's default tcp/ip port (5432).
         
+        self.tool.logdebug("Trying to open database (host=%s, port=%s, dbname=%s, user=%s)..." % (host, port, dbname, user))
         self.database = pg.connect(host=host, port=port, dbname=dbname, user=user, passwd=passwd)
         self.closed = 0
Index: /pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/ldapstorage.py (revision 2388)
+++ /pykota/trunk/pykota/storages/ldapstorage.py (revision 2418)
@@ -72,4 +72,5 @@
         for tryit in range(3) :
             try :
+                self.tool.logdebug("Trying to open database (host=%s, dbname=%s, user=%s)..." % (self.savedhost, self.saveddbname, self.saveduser))
                 self.database = ldap.initialize(self.savedhost) 
                 if self.info["ldaptls"] :
Index: /pykota/trunk/pykota/config.py
===================================================================
--- /pykota/trunk/pykota/config.py (revision 2405)
+++ /pykota/trunk/pykota/config.py (revision 2418)
@@ -43,6 +43,11 @@
         self.directory = directory
         self.filename = os.path.join(directory, "pykota.conf")
+        self.adminfilename = os.path.join(directory, "pykotadmin.conf")
         if not os.path.isfile(self.filename) :
             raise PyKotaConfigError, _("Configuration file %s not found.") % self.filename
+        if not os.path.isfile(self.adminfilename) :
+            raise PyKotaConfigError, _("Configuration file %s not found.") % self.adminfilename
+        if os.access(self.adminfilename, os.R_OK) :    
+            self.isAdmin = 1
         self.config = ConfigParser.ConfigParser()
         self.config.read([self.filename])
@@ -97,18 +102,31 @@
         backendinfo["storageadmin"] = None
         backendinfo["storageadminpw"] = None
-        adminconf = ConfigParser.ConfigParser()
-        filename = os.path.join(self.directory, "pykotadmin.conf")
-        adminconf.read([filename])
-        if adminconf.sections() : # were we able to read the file ?
-            try :
-                backendinfo["storageadmin"] = adminconf.get("global", "storageadmin", raw=1)
-            except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) :    
-                raise PyKotaConfigError, _("Option %s not found in section global of %s") % ("storageadmin", filename)
-            else :    
-                self.isAdmin = 1 # We are a PyKota administrator
-            try :
-                backendinfo["storageadminpw"] = adminconf.get("global", "storageadminpw", raw=1)
-            except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) :    
-                pass # Password is optional
+        if self.isAdmin :
+            adminconf = ConfigParser.ConfigParser()
+            adminconf.read([self.adminfilename])
+            if adminconf.sections() : # were we able to read the file ?
+                try :
+                    backendinfo["storageadmin"] = adminconf.get("global", "storageadmin", raw=1)
+                except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) :    
+                    raise PyKotaConfigError, _("Option %s not found in section global of %s") % ("storageadmin", self.adminfilename)
+                try :
+                    backendinfo["storageadminpw"] = adminconf.get("global", "storageadminpw", raw=1)
+                except (ConfigParser.NoSectionError, ConfigParser.NoOptionError) :    
+                    pass # Password is optional
+                # Now try to overwrite the storagebackend, storageserver 
+                # and storagename. This allows admins to use the master LDAP
+                # server directly and users to use the replicas transparently.
+                try :
+                    backendinfo["storagebackend"] = adminconf.get("global", "storagebackend", raw=1)
+                except ConfigParser.NoOptionError :
+                    pass
+                try :
+                    backendinfo["storageserver"] = adminconf.get("global", "storageserver", raw=1)
+                except ConfigParser.NoOptionError :
+                    pass
+                try :
+                    backendinfo["storagename"] = adminconf.get("global", "storagename", raw=1)
+                except ConfigParser.NoOptionError :
+                    pass
         return backendinfo
         
Index: /pykota/trunk/pykota/version.py
===================================================================
--- /pykota/trunk/pykota/version.py (revision 2413)
+++ /pykota/trunk/pykota/version.py (revision 2418)
@@ -22,5 +22,5 @@
 #
 
-__version__ = "1.23alpha23_unofficial"
+__version__ = "1.23alpha24_unofficial"
 
 __doc__ = "PyKota : a complete Printing Quota Solution for CUPS and LPRng."
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 2414)
+++ /pykota/trunk/NEWS (revision 2418)
@@ -22,4 +22,13 @@
 PyKota NEWS :
        
+    - 1.23alpha24 :
+    
+        - Allows different databases to be used depending on the
+          user's rights. This allows PyKota admins to directly
+          use a master LDAP server for read+write, while letting
+          normal users using the replicas for readonly access.
+          NB : using different storage backends is also possible,
+          but you're on your own there.
+          
     - 1.23alpha23 :
     
