X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_ldap.inc;h=1a991f1b6e122ba7466593abe2bd1ec1336cda9a;hb=ec31213715f17cad47d051582e1f73ea1feb85fe;hp=3d6649cc716b60777c4dd761b50b0d7ed845e125;hpb=4e339cb2472f003494c8c99648e03dac80e95564;p=gosa.git diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index 3d6649cc7..1a991f1b6 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -690,7 +690,7 @@ class LDAP{ /* Bail out, if we've nothing to do... */ if ($ocname == ""){ - msg_dialog::display(_("Internal error"), sprintf(_("Cannot automatically create subtrees with RDN '%s': no object class found"),$type), FATAL_ERROR_DIALOG); + msg_dialog::display(_("Internal error"), sprintf(_("Cannot automatically create subtrees with RDN %s: no object class found"), bold($type)), FATAL_ERROR_DIALOG); exit(); } @@ -741,7 +741,7 @@ class LDAP{ $na["dc"]= $param; break; default: - msg_dialog::display(_("Internal error"), sprintf(_("Cannot automatically create subtrees with RDN '%s': not supported"),$type), FATAL_ERROR_DIALOG); + msg_dialog::display(_("Internal error"), sprintf(_("Cannot automatically create subtrees with RDN %s: not supported"), bold($type)), FATAL_ERROR_DIALOG); exit(); } @@ -828,9 +828,9 @@ class LDAP{ } else { $adderror= $this->get_additional_error(); if ($adderror != ""){ - $error= $this->error." (".$this->get_additional_error().", ".sprintf(_("while operating on %s using LDAP server %s"), "".$this->basedn."", "".$this->hostname."").")"; + $error= $this->error." (".$this->get_additional_error().", ".sprintf(_("while operating on %s using LDAP server %s"), bold($this->basedn), bold($this->hostname)).")"; } else { - $error= $this->error." (".sprintf(_("while operating on LDAP server %s"), "".$this->hostname."").")"; + $error= $this->error." (".sprintf(_("while operating on LDAP server %s"), bold($this->hostname)).")"; } return $error; } @@ -857,27 +857,16 @@ class LDAP{ } - function gen_ldif ($srp, $dn, $filter= "(objectClass=*)", $attributes= array('*'), $recursive= TRUE) + function generateLdif ($dn, $filter= "(objectClass=*)", $attributes= array(), $scope = 'sub', $limit=0) { - $display= ""; - - if ($recursive){ - $this->cd($dn); - $this->ls($srp, $filter,$dn, array('dn','objectClass')); - $deps = array(); - - $display .= $this->gen_one_entry($dn)."\n"; - - while ($attrs= $this->fetch($srp)){ - $deps[] = $attrs['dn']; - } - foreach($deps as $dn){ - $display .= $this->gen_ldif($srp, $dn, $filter,$attributes,$recursive); - } - } else { - $display.= $this->gen_one_entry($dn); - } - return ($display); + $host = $this->hostname; + $attrs = (count($attributes))?implode($attributes,' '):''; + $scope = (!empty($scope))?' -s '.$scope: ''; + $limit = (!$limit)?'':' -z '.$limit; + $cmd = "ldapsearch -x -LLLL '{$filter}' {$limit} {$scope} -H '{$host}' -b '{$dn}' $attrs"; + exec($cmd, $ret,$code); + $res = implode($ret,"\n"); + return($res); } @@ -904,57 +893,6 @@ class LDAP{ } - function gen_one_entry($dn, $filter= "(objectClass=*)" , $name= array("*")) - { - $ret = ""; - $data = ""; - if($this->reconnect){ - $this->connect(); - } - - /* Searching Ldap Tree */ - $sr= @ldap_read($this->cid, LDAP::fix($dn), $filter, $name); - - /* Get the first entry */ - $entry= @ldap_first_entry($this->cid, $sr); - - /* Get all attributes related to that Objekt */ - $atts = array(); - - /* Assemble dn */ - $atts[0]['name'] = "dn"; - $atts[0]['value'] = array('count' => 1, 0 => $dn); - - /* Reset index */ - $i = 1 ; - $identifier = array(); - $attribute= @ldap_first_attribute($this->cid,$entry,$identifier); - while ($attribute) { - $i++; - $atts[$i]['name'] = $attribute; - $atts[$i]['value'] = @ldap_get_values_len($this->cid, $entry, "$attribute"); - - /* Next one */ - $attribute= @ldap_next_attribute($this->cid,$entry,$identifier); - } - - foreach($atts as $at) - { - for ($i= 0; $i<$at['value']['count']; $i++){ - - /* Check if we must encode the data */ - if(!preg_match('/^[a-z0-9+@#.=, \/ -]+$/i', $at['value'][$i])) { - $ret .= $at['name'].":: ".base64_encode($at['value'][$i])."\n"; - } else { - $ret .= $at['name'].": ".$at['value'][$i]."\n"; - } - } - } - - return($ret); - } - - function dn_exists($dn) { return @ldap_list($this->cid, LDAP::fix($dn), "(objectClass=*)", array("objectClass")); @@ -1052,7 +990,7 @@ class LDAP{ /* Every block must begin with a dn */ if($dn != "dn") { - $error= sprintf(_("Invalid DN '%s': block to be imported should start with 'dn: ...' in line %s"), $line, "".$current_line.""); + $error= sprintf(_("Invalid DN %s: block to be imported should start with 'dn: ...' in line %s"), bold($line), bold($current_line)); return -2; } @@ -1081,7 +1019,7 @@ class LDAP{ /* If we can't Import, return with a file error */ if(!$this->import_single_entry($srp, $single,$usemodify,$usermdir) ) { - $error= sprintf(_("Error while importing DN '%s': please check LDIF from line %s on!"), $line, + $error= sprintf(_("Error while importing DN %s: please check LDIF from line %s on!"), bold($line), $current_line); return UNKNOWN_TOKEN_IN_LDIF_FILE; } }