Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.11.5

Request #1828 auto build and database schema of LDAP
Submitted: 2004-07-08 22:08 UTC
From: tdr32 at cs dot byu dot edu Assigned: alan_k
Status: Closed Package: DB_DataObject
PHP Version: 4.3.2 OS: Fedora Core 2
Roadmaps: (Not assigned)    

 [2004-07-08 22:08 UTC] tdr32 at cs dot byu dot edu
Description: ------------ I have a LDAP directory and have been connecting to it through DB_LDAP. When I started to use DB_DataObject, I noticed that it didn't auto build for the LDAP directory. The problem is that it doesn't support the functions of getListOf and tableInfo. Well, I tweaked around a bit and got it up and running on auto building for LDAP. I don't know about updating and that stuff since I haven't gotten that far, just thought you might want to see my patch. It isn't perfect, and it might only work for my situation. One thing that would need to be changed is not just assigning the type of the columns (attributes) to just string. But that was the easiest work around. Thanks for your great work. Reproduce code: --------------- In Generator.php, in the _createTableList(): if (!PEAR::isError($this->tables,DB_ERROR_NOT_CAPABLE)) { foreach($this->tables as $table) { // no change } } elseif (get_class($__DB) == 'db_ldap') { $sql = $__DB->prepare('(objectClass=!)'); $table =& $__DB->execute($sql,'*','list',array('attrsonly'=>0,'sizelimit'=>1)); if (!PEAR::isError($table)) { $defs = $table->fetchall(); $table_name = $defs[0]['dn']; $table_name = substr($table_name,0,strpos($table_name,'=')); $this->tables = array($table_name); foreach (array_keys($defs[0]) as $name) { $def = array ( 'table' => $table_name, 'name' => $name, 'type' => 'string', 'len' => '255', 'flags' => 'not_null'); $this->_definitions[$table_name][] = (object) $def; } }


 [2004-07-08 22:19 UTC] tdr32 at cs dot byu dot edu
I actually tried to extend DB_DataObject and write a LDAP version, but I had a problem with your errors. It _createTableList(), it checks for an error on line 170 and since LDAP doesn't support those functions it just quites. So, I can't even extend DB_DataObject (or I could and just have to use 2 createTables when I am generating the classes, one for SQL and one for LDAP). So maybe a better suggestion than my previous one, is to not make DB_DataObject support LDAP (since even DB doesn't support it) but to make it so that error doesn't kill the program until it has returned to the calling function, start(). That can be done by checking to see if $this->tables is an error in start and change the exit to continue in the foreach ($this->tables). Thanks Thanks
 [2004-07-16 02:23 UTC] alan_k
yeah - I did try doing a ldap_dataobject a long while ago - the fact that ldap can have multiple values for attributes makes it a huge kludge using pure db_dataobject. - will add the error failback..
 [2004-07-24 02:29 UTC] alan_k
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on In case this was a website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. added fatal death on table lookup failure.