]> git.nbdom.net Git - nb.git/commitdiff
etc/dbq/ldap.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 19 Feb 2018 00:22:11 +0000 (00:22 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 19 Feb 2018 00:22:11 +0000 (00:22 +0000)
etc/dbq/ldap.php
etc/profile.d/ldap.sh
lib/php/db/field.php
lib/php/db/table.php
lib/php/db/types/ldap.php
lib/php/ldap.php
www/dbq/dbq.php
www/dbq/html/default.css
www/dbq/html/default.min.css

index 0e42d772d940d1d0fad3b1112233f53fe481ecb1..b142a2883c989285813808df93f1d9b37a2ca2cf 100644 (file)
@@ -51,10 +51,59 @@ $filter = '(&('.$filter.')(userPassword=*))';
 $DBQ['ldap'] = $GLOBALS['DBQ_LDAP'] + [
        'type' => 'ldap',
        'tables' => [
-               'objectClass=*' => [ 'fields' => ['!dn','objectClass'], 'type' => 'table'],
-               $filter => [ 'fields' => ['!dn','objectClass'], 'type' => 'table'],
+               'me' => [
+                       'type' => 'table',
+                       'sql' => $filter,
+                       'fields' => ['!dn','objectClass','cn','jpegPhoto'],
+               ],
+               'all' => [
+                       'type' => 'table',
+                       'sql' => 'objectClass=*',
+                       'fields' => ['!dn','objectClass','cn'],
+               ],
+               'person' => [
+                       'type' => 'table',
+                       'sql' => 'objectClass=person',
+                       'fields' => ['!dn', 'cn', 'sn', 'userPassword','telephoneNumber', 'description', 'seeAlso'],
+               ],
+               'inetOrgPerson' => [
+                       'type' => 'table',
+                       'sql' => 'objectClass=inetOrgPerson',
+                       'fields' => [
+                               '!dn',
+                               'cn',
+                               'dn',
+                               'uid',
+                               'displayName',
+                               'givenName',
+                               #'audio',
+                               'businessCategory',
+                               'carLicense',
+                               #'departmentNumber',
+                               #'employeeNumber',
+                               #'employeeType',
+                               'homePhone',
+                               'homePostalAddress',
+                               'initials',
+                               'jpegPhoto',
+                               #'labeledURI',
+                               'mail',
+                               #'manager',
+                               'mobile',
+                               'o',
+                               #'pager',
+                               #'photo',
+                               #'roomNumber',
+                               #'secretary',
+                               #'userCertificate',
+                               #'x500uniqueIdentifier',
+                               #'preferredLanguage',
+                               #'userSMIMECertificate',
+                               #'userPKCS12',
+                       ],
+               ],
        ],
-       'default_table' => $filter,
+       'default_table' => 'me',
 ];
 #debug($GLOBALS['DBQ_LDAP']);
 ?>
index 194ba8aab8dcd2390fb6689eb62d94fb4137931c..d06e56de8c14178920e85a12ea61b1dbe38143af 100644 (file)
@@ -38,7 +38,7 @@ ldap_config() {
 }
 
 ldap_databases() {
-       slapcat -o ldif-wrap=no -b cn=config | grep "^dn: olcDatabase="
+       slapcat -o ldif-wrap=no -b cn=config | awk -F': ' '/^dn: olcDatabase=/{print $2}'
 }
 
 ldap_schema_config() {
index 9e8bbfc313fbf8b9c74237bbdea44d95d5058061..3efea7af3d221169a5ce893125c06d77a08623c3 100644 (file)
@@ -89,6 +89,7 @@ class field extends nb {
       return preg_match('/^(1|yes|on|true)/i',$value) ? 'Yes' : 'No';
     }
 
+               $value = Mime::html($value);
     return $value;
   }
 
index ef7206cb5c7827bd6b67f791a33e3f41b10f2679..f7470b99e3b1e741655dd55d8fd9d09dc7cda694 100644 (file)
@@ -62,9 +62,9 @@ Class Table extends nb {
 
                if(!empty($name)) $opt['name'] = $this->name = $name;
 
-               // Type
+               // Sql / Type
                if (isset($opt['sql'])) {
-                       $this->type = 'sql'; unset($opt['type']);
+                       if (empty($opt['type'])) $opt['type'] = 'sql';
                        $this->sql = $opt['sql']; unset($opt['sql']);
                }
 
@@ -1102,18 +1102,16 @@ Class Table extends nb {
 
        public function rows(&$opt=[]) { # ,$opt_by_val=null) {
                #
-               # Db type change
+               # Options
+               #
+
                #
+               # Db type change
                $db_type = $this->db()->type;
                if (!empty($opt['db_type_from'])) {
                        $this->db()->type = $opt['db_type_from'];
                }
 
-               #
-               # Build query
-               #
-               $this->create_temporary();
-
                if (isset($opt['format']) and $opt['format']==='') {
                        $format = '';
                } else {
@@ -1123,9 +1121,12 @@ Class Table extends nb {
                        if (!$format) $this->bye("Parameter `format` missing!");
                }
 
-#debug($opt);
-               list($sql,$where,$limit,$select_count) = $this->rows_sql($opt);
+               #
+               # Build query
+               #
                $nosql = $this->db()->conf_type('nosql');
+               if (!$nosql) $this->create_temporary();
+               list($sql,$where,$limit,$select_count) = $this->rows_sql($opt);
 
                if ($nosql) {
                        $sql = empty($this->sql) ? $this->name : $this->sql;
index a56eb28c89ad9b9440474df8e45c1158afdc3d1e..03c89e4aab144880975107429070b7353a382233 100644 (file)
@@ -47,8 +47,7 @@ $DB_TYPES['ldap'] = [
                return $row;
        },
        'update' => function(&$table,&$values) {
-               $dn = $values['dn'];
-               unset($values['dn']);
+               $dn = $values['dn']; unset($values['dn']);
                #bye([$dn,$values]);
                return (int)$table->db()->ldap->update($dn,$values);
        },
index bf340d804a9e82680895dad90f3b2b0aced2f947..7937be6d9ac362e34949b94a8b359e22e334e757 100644 (file)
@@ -131,7 +131,7 @@ class Ldap {
                        } elseif ($v === '') {
                                unset($data[$k]);
                                #ldap_mod_del($this->connect(),$dn,[$k=>$v]);
-                               if (!ldap_mod_del($this->connect(),$dn,[$k=>[]])) bye("$dn: $k: ".ldap_error($this->connect()));
+                               if (!ldap_mod_del($this->connect(),$dn,[$k=>[]])) 1;#bye("$dn: $k: ".ldap_error($this->connect()));
 
                        }
                        #if ($data[$k] === null 
index cc0943c1e828edca5fe5dda23c6fd960084ab362..dfd568c8da1e2372286adec40c552bee17af9f50 100644 (file)
@@ -588,7 +588,7 @@ class DbQ extends nb {
 
                        # We Allow SELECT only in admin
                        if ($this->perm < self::ADMIN or !preg_match('/^SELECT /',$this->params['table'])) {
-                               $this->not_found('Unknown table: '.$this->params['table']);
+                               if ($this->db->type != 'ldap') $this->not_found('Unknown table: '.$this->params['table']);
                        }
 
                }
index 50b8a6eccf2514c6d1917193eeb28d05a48c338c..53909f6c74922c77a067a466f4b635e4acd96a36 100644 (file)
@@ -226,12 +226,8 @@ div.row div {
        height: 1.2em;
 }
 
-div.row div.ZjpegPhoto span {
-       max-width: 5em;
-       max-height: 1,2em;
-       text-overflow: ellipsis;
-       overflow: hidden;
-       display: none;
+.action-vi.jpegPhoto img {
+       max-width: 200px;
 }
 
 div.row div.view .button { margin-bottom: 5px; }
index 655ae00d45374383952202738401a1e11b27cacd..aaae83cd88d16b4ceb1bea15d322798045132add 100644 (file)
@@ -1 +1 @@
-html{font:90% 'Trebuchet MS',sans-serif;background-color:#eee}body{display:table;margin-left:auto;margin-right:auto;padding-left:1em;padding-right:1em;color:#444}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.loader{border:16px solid #fff;border-radius:50%;border-top:16px solid #000;padding:0;margin:0 auto 0 auto;width:8em;height:8em;animation:spin 2s linear infinite;display:block}body.loader{margin-top:8em}.loader *{display:none!important}h1{margin:0 0 .2em 0;font-size:180%;padding-bottom:.3em;margin-bottom:.5em;border-bottom:dashed 1px #444}h1 select{padding:0;border:none;background:inherit;font:inherit}a{color:inherit}div>a,li a,p a,td a{color:#3572b0}a,a:visited{text-decoration:none}.button:hover,a:hover{opacity:.8}ul{padding:0;margin:0}li{list-style:none;padding:0 0 0 .3em}table{border-collapse:collapse}td,th{padding:.2em .7em}th a.sort{float:left;margin-right:.1em}input:not([type]),input[type=''],input[type=date],input[type=email],input[type=password],input[type=text],input[type=url],select,textarea{border-radius:3px;border:solid 1px #ddd;padding:.3em .4em;box-shadow:0 1px 1px #eee}input[size]{max-width:70%}div.row div label:after,form label:after{content:':'}form input,form label,form select{vertical-align:middle;margin:.2em .4em .2em 0}.rows{padding:0}.rows form{display:inline-block}.block,.menu,div.row,form.edit,iframe,pre,table.rows,ul.row{border-radius:4px;border-spacing:0;padding:.5em .2em;margin-bottom:.5em;border:solid 1px #ddd;background-color:#fafafa;box-shadow:0 1px 2px #eee}table.rows{border-style:hidden;border-collapse:collapse;box-shadow:0 0 0 1px #ddd;table-layout:fixed}table.rows tr:nth-child(even) td{background-color:#fefefe}div.row div,table.rows td,table.rows th,ul.row li{border-bottom:solid 1px #ddd}div.row div,table.rows tr:last-child td,ul.row li{border-bottom:none}table.rows td,table.rows th{border-right:dashed 1px #ddd}.rows .count{text-align:right}table.rows th{text-align:left}table.rows td{padding:.3em .3em}table.rows.fixed{width:100%}div.row div label,table.rows.fixed td,table.rows.fixed th{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}table.rows.fixed th{white-space:normal}table.rows td.delete,table.rows td.view{width:1%;white-space:nowrap}table.rows.fixed th.view{width:2em}table.rows.fixed th.delete{width:2.7em}div.rows{clear:both}div.row{float:left;margin-right:4px;min-width:24%}.nofloat{float:none}div.row div{margin:0;padding:.1em .2em;border-bottom:solid 1px #fff}.rows .row img{height:1.2em}div.row div.ZjpegPhoto span{max-width:5em;max-height:1,2em;text-overflow:ellipsis;overflow:hidden;display:none}div.row div.view .button{margin-bottom:5px}div.row div.delete .button{margin-top:5px}div.row div:last-child{border-bottom:none;padding-bottom:0}div.row div.delete label,div.row div.view label{display:none}div.row div.delete,div.row div.view{text-align:center}div.row div label,ul.row li label{padding:.1em .5em .1em 0;min-width:20%;display:inline-block}.button{font:inherit;display:inline-block;text-decoration:none;line-height:1.6em;cursor:pointer;white-space:nowrap;box-sizing:border-box;margin:0 .1em 0 0;padding:0 .3em;border-radius:4px;border:none;color:#3572b0;background-color:#eee;background:linear-gradient(to bottom right,#eee,#ddd);box-shadow:0 1px 1px #bbb}.bottom,.center,.menu,.nav,.rows{clear:both;display:table}.bottom,.buttons,.center,.menu,.nav,.rows,td.button{margin-left:auto;margin-right:auto}div.buttons{text-align:center;margin-top:.5em}form.menu{padding:.5em;background-color:#fafafa;max-width:1024px}form.menu .button.add{float:right;margin-top:.2em}form.menu .criterias{border-top:dashed 1px #ddd;margin-top:.3em;padding-top:.3em;clear:both}form.menu .criterias span.label{border-right:solid 1px #fff;border-radius:3px;margin:0 .2em;white-space:nowrap;float:left}form.menu .criterias span.label:last-child{border-right:none}form.menu select:focus{max-width:auto}form.menu select{max-width:20%}form.menu .criterias input[type=text]{width:4em}div.row label,form.edit .fields label{width:25%;text-align:right;display:inline-block;margin-right:1em;vertical-align:top}div.row .label span,form.edit .fields .label span{width:54%;display:inline-block;text-align:left;vertical-align:middle;margin-top:.2em}form.edit .fields input[size],form.edit .fields select,form.edit .fields textarea{width:65%}
+html{font:90% 'Trebuchet MS',sans-serif;background-color:#eee}body{display:table;margin-left:auto;margin-right:auto;padding-left:1em;padding-right:1em;color:#444}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.loader{border:16px solid #fff;border-radius:50%;border-top:16px solid #000;padding:0;margin:0 auto 0 auto;width:8em;height:8em;animation:spin 2s linear infinite;display:block}body.loader{margin-top:8em}.loader *{display:none!important}h1{margin:0 0 .2em 0;font-size:180%;padding-bottom:.3em;margin-bottom:.5em;border-bottom:dashed 1px #444}h1 select{padding:0;border:none;background:inherit;font:inherit}a{color:inherit}div>a,li a,p a,td a{color:#3572b0}a,a:visited{text-decoration:none}.button:hover,a:hover{opacity:.8}ul{padding:0;margin:0}li{list-style:none;padding:0 0 0 .3em}table{border-collapse:collapse}td,th{padding:.2em .7em}th a.sort{float:left;margin-right:.1em}input:not([type]),input[type=''],input[type=date],input[type=email],input[type=password],input[type=text],input[type=url],select,textarea{border-radius:3px;border:solid 1px #ddd;padding:.3em .4em;box-shadow:0 1px 1px #eee}input[size]{max-width:70%}div.row div label:after,form label:after{content:':'}form input,form label,form select{vertical-align:middle;margin:.2em .4em .2em 0}.rows{padding:0}.rows form{display:inline-block}.block,.menu,div.row,form.edit,iframe,pre,table.rows,ul.row{border-radius:4px;border-spacing:0;padding:.5em .2em;margin-bottom:.5em;border:solid 1px #ddd;background-color:#fafafa;box-shadow:0 1px 2px #eee}table.rows{border-style:hidden;border-collapse:collapse;box-shadow:0 0 0 1px #ddd;table-layout:fixed}table.rows tr:nth-child(even) td{background-color:#fefefe}div.row div,table.rows td,table.rows th,ul.row li{border-bottom:solid 1px #ddd}div.row div,table.rows tr:last-child td,ul.row li{border-bottom:none}table.rows td,table.rows th{border-right:dashed 1px #ddd}.rows .count{text-align:right}table.rows th{text-align:left}table.rows td{padding:.3em .3em}table.rows.fixed{width:100%}div.row div label,table.rows.fixed td,table.rows.fixed th{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}table.rows.fixed th{white-space:normal}table.rows td.delete,table.rows td.view{width:1%;white-space:nowrap}table.rows.fixed th.view{width:2em}table.rows.fixed th.delete{width:2.7em}div.rows{clear:both}div.row{float:left;margin-right:4px;min-width:24%}.nofloat{float:none}div.row div{margin:0;padding:.1em .2em;border-bottom:solid 1px #fff}.rows .row img{height:1.2em}.action-vi.jpegPhoto img{max-width:200px}div.row div.view .button{margin-bottom:5px}div.row div.delete .button{margin-top:5px}div.row div:last-child{border-bottom:none;padding-bottom:0}div.row div.delete label,div.row div.view label{display:none}div.row div.delete,div.row div.view{text-align:center}div.row div label,ul.row li label{padding:.1em .5em .1em 0;min-width:20%;display:inline-block}.button{font:inherit;display:inline-block;text-decoration:none;line-height:1.6em;cursor:pointer;white-space:nowrap;box-sizing:border-box;margin:0 .1em 0 0;padding:0 .3em;border-radius:4px;border:none;color:#3572b0;background-color:#eee;background:linear-gradient(to bottom right,#eee,#ddd);box-shadow:0 1px 1px #bbb}.bottom,.center,.menu,.nav,.rows{clear:both;display:table}.bottom,.buttons,.center,.menu,.nav,.rows,td.button{margin-left:auto;margin-right:auto}div.buttons{text-align:center;margin-top:.5em}form.menu{padding:.5em;background-color:#fafafa;max-width:1024px}form.menu .button.add{float:right;margin-top:.2em}form.menu .criterias{border-top:dashed 1px #ddd;margin-top:.3em;padding-top:.3em;clear:both}form.menu .criterias span.label{border-right:solid 1px #fff;border-radius:3px;margin:0 .2em;white-space:nowrap;float:left}form.menu .criterias span.label:last-child{border-right:none}form.menu select:focus{max-width:auto}form.menu select{max-width:20%}form.menu .criterias input[type=text]{width:4em}div.row label,form.edit .fields label{width:25%;text-align:right;display:inline-block;margin-right:1em;vertical-align:top}div.row .label span,form.edit .fields .label span{width:54%;display:inline-block;text-align:left;vertical-align:middle;margin-top:.2em}form.edit .fields input[size],form.edit .fields select,form.edit .fields textarea{width:65%}