From: hickert Date: Fri, 30 Apr 2010 06:52:23 +0000 (+0000) Subject: Updated class ldap::generateLdif X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9c309d6fc3d3ff65caf535b6f53ea3177433d29b;p=gosa.git Updated class ldap::generateLdif -Fixed parameter and add comments. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@17983 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/include/class_ldap.inc b/gosa-core/include/class_ldap.inc index 5d815810e..c34036c32 100644 --- a/gosa-core/include/class_ldap.inc +++ b/gosa-core/include/class_ldap.inc @@ -857,17 +857,27 @@ 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; - $dn = escapeshellarg($dn); - $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"; + exec($cmd, $ret,$code); + $res = implode($ret,"\n"); + return($res); }