[patch] Ignore some required attributes

View: New views
2 Messages — Rating Filter:   Alert me  

[patch] Ignore some required attributes

by Loris Santamaria :: Rate this Message:

| View Threaded | Show Only this Message

Some ldap servers may generate automatically numeric attributes like
uidNumber. For example, Fedora Directory Server includes a plugin called
Distributed Numeric Assignment which can be used to generate uidNumber,
gidNumber, sambaSID, etc.

The attached patch (based on 1.1.0.5) adds a new configuration
parameter, $ignored_attrs which is an array of required attributes to
ignore when checking for... required attributes. This allows to create
posix and samba accounts with no uidNumber and no sambaSID and having
the directory server generating those attributes.


--
Loris Santamaria   linux user #70506   xmpp:loris@...
Links Global Services, C.A.            http://www.lgs.com.ve
Tel: 0286 952.06.87  Cel: 0414 095.00.10  sip:103@...
------------------------------------------------------------
-O9 -omg-optimize -fomit-instructions

[ignored-attrs.patch]

--- config/config.php.example.old 2008-01-27 05:47:28.000000000 -0430
+++ config/config.php.example 2008-07-24 19:00:09.000000000 -0430
@@ -490,6 +490,18 @@
 #  $unique_attrs = array('uid','uidNumber','mail');
 
 /*********************************************/
+/* ignore required attributes                */
+/*********************************************/
+  
+/* These attributes will not be required when creating
+ * or modifying an entry, which is useful for
+ * server-generated attributes.
+ * In Fedora Directory Server using the DNA Plugin
+ * one could ignore uidNumber, gidNumber and sambaSID */
+
+#$ignored_attrs = array ('uidNumber', 'gidNumber', 'sambaSID');
+
+/*********************************************/
 /* Group attributes                          */
 /*********************************************/
 
--- ./lib/functions.php.old 2008-01-30 06:47:00.000000000 -0430
+++ ./lib/functions.php 2008-07-24 18:30:48.000000000 -0430
@@ -331,6 +331,7 @@
  if (isset($read_only_attrs)) $config->read_only_attrs = $read_only_attrs;
  if (isset($read_only_except_dn)) $config->read_only_except_dn = $read_only_except_dn;
  if (isset($unique_attrs)) $config->unique_attrs = $unique_attrs;
+ if (isset($ignored_attrs)) $config->ignored_attrs = $ignored_attrs;
 
  # Check the memory limit parameter.
  if (ini_get('memory_limit') < $config->GetValue('session','memorylimit'))
--- ./lib/server_functions.php.old 2008-01-31 08:04:26.000000000 -0430
+++ ./lib/server_functions.php 2008-07-24 18:54:28.000000000 -0430
@@ -2709,6 +2709,26 @@
  return false;
  }
 
+        /**
+         * This function determines if the specified attribute is contained in the $ignored_attrs list
+         * configured in config.php.
+         * @return bool True if the specified attribute is in the $ignored_attrs list and false
+         *              otherwise.
+         */
+        function isIgnoredAttr($attr_name) {
+                if (DEBUG_ENABLED)
+                        debug_log('Entered with (%s)',17,__FILE__,__LINE__,__METHOD__,$attr_name);
+
+                $ignored_attrs = isset($_SESSION[APPCONFIG]->ignored_attrs) ? $_SESSION[APPCONFIG]->ignored_attrs : array();
+
+                if (isset($ignored_attrs) && is_array($ignored_attrs))
+                        foreach ($ignored_attrs as $attr)
+                                if (strcasecmp($attr_name,$attr) == 0)
+                                        return true;
+
+                return false;
+        }
+
  /**
  * This function will check whether the value for an attribute being changed
  * is already assigned to another DN.
--- ./lib/config_default.php.old 2008-01-30 06:46:02.000000000 -0430
+++ ./lib/config_default.php 2008-07-24 18:58:04.000000000 -0430
@@ -38,6 +38,7 @@
  public $read_only_attrs = array();
  public $read_only_except_dn = '';
  public $unique_attrs = array();
+ public $ignored_attrs = array();
 
  public $hooks = array();
 
--- ./htdocs/create.php.old 2008-07-24 17:48:57.000000000 -0430
+++ ./htdocs/create.php 2008-07-24 18:33:41.000000000 -0430
@@ -69,8 +69,9 @@
  $new_vals[] = $val;
  }
 
- if ($attr->isRequired() && !$new_vals)
- pla_error(sprintf(_('You left the value blank for required attribute (%s).'), htmlspecialchars($attr->getName())));
+ if ($attr->isRequired() && !$new_vals && !$ldapserver->isIgnoredAttr($attr->getName()))
+ pla_error(sprintf(_('You left the value blank for required attribute (%s).'), htmlspecialchars($attr->getName())));
+
 
  if ($new_vals)
  $new_entry[$attr->getName()] = $new_vals;


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
______________________________________
phpLDAPadmin development mailing list.
To unsbuscribe: https://lists.sourceforge.net/lists/listinfo/phpldapadmin-devel
http://phpldapadmin.sourceforge.net/

Re: [patch] Ignore some required attributes

by Deon George :: Rate this Message:

| View Threaded | Show Only this Message

Thanks for your Patch.

Please submit all patches to Sourcforge - maillist lists tender to alter
the patches making them too hard to apply...

...deon

Loris Santamaria wrote:
> The attached patch (based on 1.1.0.5) adds a new configuration
> parameter, $ignored_attrs which is an array of required attributes to
> ignore when checking for... required attributes. This allows to create
> posix and samba accounts with no uidNumber and no sambaSID and having
> the directory server generating those attributes.
>  


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
______________________________________
phpLDAPadmin development mailing list.
To unsbuscribe: https://lists.sourceforge.net/lists/listinfo/phpldapadmin-devel
http://phpldapadmin.sourceforge.net/