Index: /pykota/trunk/conf/pykota.conf.sample
===================================================================
--- /pykota/trunk/conf/pykota.conf.sample (revision 1502)
+++ /pykota/trunk/conf/pykota.conf.sample (revision 1510)
@@ -98,14 +98,19 @@
 #
 # How to create new accounts and groups
-# authorized values are "below" and "attach(objectclass name)"
+# authorized values are "below" and "attach(objectclass name [, fail|warn])"
 #
 # "below" creates the new accounts/groups as standalone entries
 # below the above defined 'userbase' ou
 # 
-# attach(objectclass name) tries to find some existing user/group
+# attach(objectclass name [, action]) tries to find some existing user/group
 # using the above defined 'userrdn' or 'grouprdn' and 'userbase'
 # 'groupbase', and attach the PyKota specific entries to it.
-#
-# a possible value:  newuser: attach(posixAccount)
+# if action is "warn" and no entry exists to attach to, a new
+# entry is created, and a message is logged. 
+# if action is "fail" and no entry exists to attach to, program
+# logs an error message and aborts.
+# if action is not set, the default value is "fail".
+#
+# a possible value:  newuser: attach(posixAccount, warn)
 #newuser : below
 #newgroup : below
Index: /pykota/trunk/TODO
===================================================================
--- /pykota/trunk/TODO (revision 1509)
+++ /pykota/trunk/TODO (revision 1510)
@@ -40,7 +40,4 @@
           is cancelled by the user.
           
-        - newuser: attach(posixAccount | inetOrgPerson | ..., fail|warn)
-          same for newgroup
-          
         - Test and document a possible workaround for knowing
           if the job is a banner (embed a postscript comment
Index: /pykota/trunk/pykota/storages/ldapstorage.py
===================================================================
--- /pykota/trunk/pykota/storages/ldapstorage.py (revision 1506)
+++ /pykota/trunk/pykota/storages/ldapstorage.py (revision 1510)
@@ -22,4 +22,7 @@
 #
 # $Log$
+# Revision 1.66  2004/05/28 20:56:45  jalet
+# Extended syntax for LDAP specific newuser and newgroup directives. Untested.
+#
 # Revision 1.65  2004/05/27 12:52:12  jalet
 # More useful error message in case of misconfiguration of an LDAP  search base
@@ -762,5 +765,9 @@
         mustadd = 1
         if self.info["newuser"].lower() != 'below' :
-            result = self.doSearch("(&(objectClass=%s)(%s=%s))" % (self.info["newuser"], self.info["userrdn"], user.Name), None, base=self.info["userbase"])
+            try :
+                (where, action) = [s.strip() for s in self.info["newuser"].split(",")]
+            except ValueError :
+                (where, action) = (self.info["newuser"].strip(), "fail")
+            result = self.doSearch("(&(objectClass=%s)(%s=%s))" % (where, self.info["userrdn"], user.Name), None, base=self.info["userbase"])
             if result :
                 (dn, fields) = result[0]
@@ -769,4 +776,10 @@
                 self.doModify(dn, fields)
                 mustadd = 0
+            else :
+                message = _("Unable to find an existing entry to attach pykotaAccount objectclass %s") % user.Name
+                if action.lower() == "warn" :    
+                    self.tool.logger.log_message("%s. A new entry will be created instead." % message, "warn")
+                else : # 'fail' or incorrect setting
+                    raise PyKotaStorageError, "%s. Action aborted. Please check your configuration." % message
                 
         if mustadd :
@@ -788,5 +801,9 @@
         mustadd = 1
         if self.info["newgroup"].lower() != 'below' :
-            result = self.doSearch("(&(objectClass=%s)(%s=%s))" % (self.info["newgroup"], self.info["grouprdn"], group.Name), None, base=self.info["groupbase"])
+            try :
+                (where, action) = [s.strip() for s in self.info["newgroup"].split(",")]
+            except ValueError :
+                (where, action) = (self.info["newgroup"].strip(), "fail")
+            result = self.doSearch("(&(objectClass=%s)(%s=%s))" % (where, self.info["grouprdn"], group.Name), None, base=self.info["groupbase"])
             if result :
                 (dn, fields) = result[0]
@@ -795,4 +812,10 @@
                 self.doModify(dn, fields)
                 mustadd = 0
+            else :
+                message = _("Unable to find an existing entry to attach pykotaGroup objectclass %s") % group.Name
+                if action.lower() == "warn" :    
+                    self.tool.logger.log_message("%s. A new entry will be created instead." % message, "warn")
+                else : # 'fail' or incorrect setting
+                    raise PyKotaStorageError, "%s. Action aborted. Please check your configuration." % message
                 
         if mustadd :
Index: /pykota/trunk/NEWS
===================================================================
--- /pykota/trunk/NEWS (revision 1502)
+++ /pykota/trunk/NEWS (revision 1510)
@@ -25,4 +25,10 @@
     - 1.19alpha16 :
     
+        - the newuser and newgroup LDAP specific directives now accept
+          a second parameter to attach(), "fail" or "warn". If no entry
+          is found to attach PyKota attributes to, and "fail" was used,
+          then action is aborted and program exits in error. If "warn"
+          is used, a new entry is created but a warning message is logged.
+          
         - The job's originating hostname is now stored in the database,
           and exported as PYKOTAJOBORIGINATINGHOSTNAME in the environment.
