Code

Fixed messed up regular expression.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 16 Nov 2009 06:56:21 +0000 (06:56 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 16 Nov 2009 06:56:21 +0000 (06:56 +0000)
-Couldn't create primary groups anymore out of posixAccount class.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14813 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/personal/posix/class_posixAccount.inc

index 9ae31c78e8f69c3a6e98abefc202e336933dfacb..92be4091f53697932b24249b2afedb2a53de1d3d 100644 (file)
@@ -894,24 +894,24 @@ class posixAccount extends plugin
       if ($ldap->count() == 0){
 
         $groupcn = $this->uid;
-        $groupdn= preg_replace ('/^'.preg_quote($this->config->get_cfg_value("accountPrimaryAttribute").'=[^,]+,'.get_people_ou(), '/').'/i',
+        $pri_attr = $this->config->get_cfg_value("accountPrimaryAttribute");
+        $groupdn= preg_replace ('/^'.preg_quote($pri_attr,'/').'=[^,]+,'.preg_quote(get_people_ou(),'/').'/i',
             'cn='.$groupcn.','.get_groups_ou(), $this->dn);
 
         /* Request a new and uniqe gidNumber, if required */
         if(!$this->force_ids){
           $this->gidNumber= get_next_id("gidNumber", $this->dn);
-        }else{
-
-          /* If forced gidNumber could not be found, then check if the given group name already exists 
-              we do not want to modify the gidNumber of an existing group.
-           */
-          $cnt= 0; 
-          while($ldap->dn_exists($groupdn)){
-            $cnt ++;
-            $groupcn = $this->uid."_".$cnt;
-            $groupdn= preg_replace ('/^'.preg_quote($this->config->get_cfg_value("accountPrimaryAttribute").'=[^,]+,'.get_people_ou(), '/').'/i',
-            'cn='.$groupcn.','.get_groups_ou(), $this->dn);
-          }
+        }
+
+        /* If forced gidNumber could not be found, then check if the given group name already exists 
+           we do not want to modify the gidNumber of an existing group.
+         */
+        $cnt= 0; 
+        while($ldap->dn_exists($groupdn) && ($cnt < 100)){
+          $cnt ++;
+          $groupcn = $this->uid."_".$cnt;
+          $groupdn= preg_replace ('/^'.preg_quote($pri_attr,'/').'=[^,]+,'.preg_quote(get_people_ou(),'/').'/i',
+              'cn='.$groupcn.','.get_groups_ou(), $this->dn);
         }
 
         /* Create new primary group and enforce the new gidNumber */