i want to use my ldap server as a DB. then i will create persistence classes in the models directory that will extend to Zend_Ldap so that i won't have to write all the CRUD operations but how can i initialize the ldap connection in the bootstrap.php file
for e.g. a database connection using doctrine can be initialized like this, i want to do the same for ldap connection
protected function _initDoctrine()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Doctrine');
$this->getApplication()->getAutoloader()
->pushAutoloader(array('Doctrine', 'autoload'));
spl_autoload_register(array('Doctrine', 'modelsAutoload'));
$manager = Doctrine_Manager::getInstance();
$doctrineConfig = $this->getOption('doctrine');
$manager->setAttribute(Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
$manager->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, true);
Doctrine_Core::loadModels($doctrineConfig['models_path']);
$conn = Doctrine_Manager::connection($doctrineConfig['dsn'],'doctrine');
$conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true);
return $conn;
}
but now what i want to do is if i have some thing like this(below) in the models folder
class Application_Model_entry extends Zend_Ldap_Node_collection {
public static function getInstance() {
$options = Zend_Registry::get('config')->ldap;//i want to avoid this line
$ldap = new Zend_Ldap($options); // i want to avoid this line
$dn = $ldap->getBaseDn(); // i want to avoid this line
$a = new Zend_Ldap_Node_Collection(new Zend_Ldap_Collection_Iterator_Default($ldap,'email')); //also this one
return $a;//where $a is an instance of an LDAP entry(node)
}
then in the controller i want to do some thing like a db
$ent = new Application_Model_entry();
$ent->email = "[email protected]";
...
$ent->save();
$ent->update();
how can i initialize the ldap connection and access it in the models so that this could be possible