Code

Updated roleGeneric.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 Aug 2009 07:33:54 +0000 (07:33 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 28 Aug 2009 07:33:54 +0000 (07:33 +0000)
-Members required cn attribute, which may not be present in some circumstances.

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

gosa-plugins/roleManagement/admin/roleManagement/class_roleGeneric.inc

index 8c9d221b813f99b954c34c8c98817426c0d584db..6f79e43d9c544671181604ea4fc9b4e8bcb64e94 100644 (file)
@@ -97,7 +97,22 @@ class roleGeneric extends plugin {
       if(!isset($this->roleOccCache[$dn])){
         if($ldap->dn_exists($dn)){
           $ldap->cat($dn, $attrs);
-          $this->roleOccCache[$dn] = $ldap->fetch();
+
+          $tmp = $ldap->fetch();
+          if(!isset($tmp['cn'])){
+         
+            // Extract the namingAttribute out of the dn.
+            $cn = preg_replace("/^[^=]*+=([^,]*).*$/","\\1",$tmp['dn']);
+            if(isset($tmp['uid'])){
+              $cn = $tmp['uid'][0];
+            }
+            if(isset($tmp['description'])){
+              $cn.= " [".$tmp['description'][0]."]";
+            }
+            $tmp['cn'][0] = $cn;
+          }
+
+          $this->roleOccCache[$dn] = $tmp;
         }
       }
     }