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;
}
ama şimdi ne ben yapmak istiyorum i modeller klasöründe böyle bir şey (aşağıda) varsa
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)
}
sonra kontrolör i bir db gibi bir şey yapmak istiyorum
$ent = new Application_Model_entry();
$ent->email = "xyz@abc.xom";
...
$ent->save();
$ent->update();
Bu mümkün olabilir ki nasıl ben ldap bağlantısını başlatmak ve modellerde erişebilirsiniz