X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_ldap.inc;h=f6e908a375ea958e1d0618d1095f9762db08d8f9;hb=e1e757ca6816d818fa1a393b66f165ffefb1afe7;hp=1a991f1b6e122ba7466593abe2bd1ec1336cda9a;hpb=47eed52d20d0e6f117c395614cf2dd2d3ecfc415;p=gosa.git diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index 1a991f1b6..f6e908a37 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -857,16 +857,29 @@ class LDAP{ } + /*! \brief Generates an ldif for all entries matching the filter settings, scope and limit. + * @param $dn The entry to export. + * @param $filter Limit the exported object to those maching this filter. + * @param $attributes Specify the attributes to export here, empty means all. + * @param $scope 'base', 'sub' .. see manpage for 'ldapmodify' for details. + * @param $limit Limits the result. + */ function generateLdif ($dn, $filter= "(objectClass=*)", $attributes= array(), $scope = 'sub', $limit=0) { - $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); + $attrs = (count($attributes))?implode($attributes,' '):''; + $scope = (!empty($scope))?' -s '.$scope: ''; + $limit = (!$limit)?'':' -z '.$limit; + $dn = escapeshellarg($dn); + $admin = escapeshellarg($this->binddn); + $pwd = escapeshellarg($this->bindpw); + $filter = escapeshellarg($filter); + $host = escapeshellarg($this->hostname); + $cmd = "ldapsearch -x -LLLL -D {$admin} -w {$pwd} {$filter} {$limit} {$scope} -H {$host} -b {$dn} $attrs "; + ob_start(); + passthru($cmd); + $res=ob_get_contents(); + ob_end_clean(); + return($res); }