public function add($dn,$data) {
$conn = $this->conn();
- return ldap_add($conn, $dn, $data); # or self::bye("Unable to add entry to ldap server");
+ return ldap_add($conn, $dn, $data);
}
public function update($dn,$data) {
- return ldap_mod_add($this->conn(), $dn, $data); # or self::bye("Unable to add entry to ldap server");
+ return ldap_mod_add($this->conn(), $dn, $data);
}
public function delete($dn) {
- return ldap_delete($this->conn(), $dn); # or self::bye("Unable to add entry to ldap server");
+ return ldap_delete($this->conn(), $dn);
}
}
#debug($GLOBALS['DBQ_LDAP']);
$ldap = new Ldap($GLOBALS['DBQ_LDAP']);
- if ($this->params['table'] == 'add') {
- debug($this->params);
- $rows = (int)$ldap->add($this->params['action'],$_POST);
- bye($_POST);
- $this->page($rows);
+ if ($this->params['table'] == 'add') {
+ #debug($this->params);
+ $rows = (int)$ldap->add($this->params['action'],$_POST);
+ #bye($_POST);
+ $this->page($rows);
- } elseif ($this->params['table'] == 'update') {
- $rows = (int)$ldap->update($this->params['action'],$_POST);
- $this->page($rows);
+ } elseif ($this->params['table'] == 'update') {
+ $rows = (int)$ldap->update($this->params['action'],$_POST);
+ $this->page($rows);
- } elseif ($this->params['table'] == 'rm') {
- $rows = (int)$ldap->delete($this->params['action'],$_POST);
- $this->page($rows);
+ } elseif ($this->params['table'] == 'rm') {
+ $rows = (int)$ldap->delete($this->params['action'],$_POST);
+ $this->page($rows);
- }
+ } else {
- $filter = ($this->params['table'] ? $this->params['table'] : '');
- $attrs = ($this->params['action'] ? explode(',',$this->params['action']) : []);
+ $filter = ($this->params['table'] ? $this->params['table'] : '');
+ $attrs = ($this->params['action'] ? explode(',',$this->params['action']) : []);
- if (!empty($this->params['table']) and !strpos($this->params['table'],'=')) {
- $filter = '';
- $attrs = explode(',',$this->params['table']);
- }
+ if (!empty($this->params['table']) and !strpos($this->params['table'],'=')) {
+ $filter = '';
+ $attrs = explode(',',$this->params['table']);
+ }
- $search = [
- 'filter' => $filter,
- 'attrs' => $attrs,
- ];
+ $search = [
+ 'filter' => $filter,
+ 'attrs' => $attrs,
+ ];
- if (!$search['filter']) {
- if (preg_match('/^([^,]+),(.*?)$/',$GLOBALS['DBQ_LDAP']['user'],$m)) {
- $search['filter'] = $m[1];
- $search['base'] = $m[2];
- } else {
- $search['filter'] = 'cn='.Http::user();
+ if (!$search['filter']) {
+ if (preg_match('/^([^,]+),(.*?)$/',$GLOBALS['DBQ_LDAP']['user'],$m)) {
+ $search['filter'] = $m[1];
+ $search['base'] = $m[2];
+ } else {
+ $search['filter'] = 'cn='.Http::user();
+ }
}
- }
- $rows = $ldap->search($GLOBALS['DBQ_LDAP'] + $search);
+ $rows = $ldap->search($GLOBALS['DBQ_LDAP'] + $search);
+
+ #echo $rows[0]['jpegPhoto']; exit;
+ #$rows = [ 'jpegPhoto' => $rows[0]['jpegPhoto'] ];
+ if ($this->is_html
+ or ($this->params['format'] == $this->format_cli)
+ or ($this->params['format'] == 'csv')
+ ) $rows = $this->array_fill_assoc($rows);
- #echo $rows[0]['jpegPhoto']; exit;
- #$rows = [ 'jpegPhoto' => $rows[0]['jpegPhoto'] ];
- if ($this->is_html
- or ($this->params['format'] == $this->format_cli)
- or ($this->params['format'] == 'csv')
- ) $rows = $this->array_fill_assoc($rows);
+ $this->page($rows);
+ }
- $this->page($rows);
}
public function page_table_ls($args=null) {