3
* Copyright (c) 2008 Zivios, LLC.
5
* This file is part of Zivios.
7
* Zivios is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* Zivios is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with Zivios. If not, see <http://www.gnu.org/licenses/>.
21
* @copyright Copyright (c) 2008 Zivios, LLC. (http://www.zivios.org)
22
* @license http://www.zivios.org/legal/license
32
public $ldapConfig, $uid, $dn;
33
protected $conn, $resource;
34
private $eventlisteners, $params, $dirty_params,$transaction;
39
public $attrs, $makedn, $isnew, $transmode, $cachetransid;
40
protected $_addarray,$_delarray,$_modarray;
41
private $emsaclarray,$iacllist;
43
public function __construct($dn=null,$attrs=null,$acllist=null)
45
$this->ldapConfig = Zend_Registry::get('ldapConfig');
46
$this->_addarray = array();
47
$this->_delarray = array();
48
$this->_modarray = array();
49
$this->eventlisteners = array();
52
$this->params = array();
53
$this->dirty_params = array();
59
$attrs[] = "objectclass";
60
$attrs[] = "emsmodelclass";
63
$attrs = array_unique($attrs);
64
$attrs = array_values($attrs);
69
$acllist[] = 'CORE_LOAD_DN';
70
$this->acllist = $acllist;
72
$this->attrs = $attrs;
74
Ecl_Log::debug("Constructed with Dn: " . $dn ." and class type: " . get_class($this) .
75
" and attrs: " . implode(",",$attrs));
86
public function addEventListener($eventname,$listener)
88
Ecl_Log::debug("Adding eventlistener on: " . $eventname . " for class: " . get_class($listener) .
89
" on dn: " . $this->getdn());
91
if (array_key_exists($eventname,$this->eventlisteners))
92
$listenerobj = $this->eventlisteners[$eventname];
94
$listenerobj = new StdClass();
95
$listenerobj->listeners = array();
96
$this->eventlisteners[$eventname] = $listenerobj;
99
$listenerobj->listeners[] = $listener;
102
public function fireEvent($eventname)
104
if (array_key_exists($eventname,$this->eventlisteners)) {
105
$listenerobj = $this->eventlisteners[$eventname];
106
foreach ($listenerobj->listeners as $listener) {
107
Ecl_Log::debug("Firing Event: $eventname on listener :".get_class($listener));
108
$listener->eventAction($eventname);
111
Ecl_Log::info("No event listeners for $eventname on dn :".$this->getdn());
114
protected function setMode()
116
$_userSession = new Zend_Session_Namespace("userSession");
117
if (isset($_userSession->transinprocess) && $_userSession->transinprocess > 0) {
118
$this->transmode = 1;
119
$this->cachetransid = $_userSession->transinprocess;
120
Ecl_Log::info("Cache operative in Transaction mode for id :".$_userSession->transinprocess);
124
public function inTransaction()
127
return ($this->transmode == 1);
130
public function getCacheTransId()
133
return $this->cachetransid;
136
protected function sp_query($dn,$property)
138
$filter = "(objectclass=*)";
139
$proparray = array();
140
$proparray[] = $property;
141
$entries = $this->search($filter,$proparray,$dn,"BASE");
143
if ($entries['count'] < 1) {
144
Ecl_Log::error("Special Query failed, DN not found");
148
if ($entries[0]['count'] < 1) {
149
Ecl_Log::info("Special query return no results for attrib : $property");
153
$retval = $entries[0][$property];
155
if ($retval['count'] == 1)
158
return array_splice($retval,1);
163
* This is a special function as its called during the INIT process
164
* we need to know what plugins an object has to intialize its ATTRS
165
* Intresting problem indeed
167
protected static function getPlugins($dn)
169
$obj = new Ecl_Ldap_Engine($dn);
170
return $obj->sp_query($dn,'emsplugins');
173
protected function getEmsPerms()
175
return $this->sp_query($this->dn,'emspermission');
178
protected function getLdapAci()
180
return $this->sp_query($this->dn,'openldapaci');
183
protected function getModelClass()
185
return $this->sp_query($this->dn,'emsmodelclass');
188
protected function getModifyTime()
190
return $this->sp_query($this->dn,'modifytimestamp');
193
public function exists()
195
$filter = "(objectclass=*)";
196
$entries = $this->search($filter,array('dn'),$this->dn,"BASE");
197
return ($entries['count'] > 0);
200
public function init()
203
$attrs = $this->attrs;
207
throw new Ecl_Ldap_Exception("Cannot instantiate Ldap_Engine with zero attrs");
209
$this->addAttrs($attrs,1);
210
$this->addEmsAcls($this->acllist,1);
213
$this->requireAcl('CORE_LOAD_DN');
216
protected function addEmsAcls($acls,$skipmerge=0)
219
$newacls = array_diff($acls,$this->acllist);
220
$this->acllist = array_merge($this->acllist,$newacls);
221
$this->acllist = array_values($this->acllist);
225
Ecl_Log::debug("Added ACLS: ".implode(",",$newacls));
227
if ($this instanceof EMSSecurityObject) {
228
Ecl_Log::debug("Skipping ACL loading for EMSSecurityObject at dn :$dn");
229
$aclreturn = array();
231
$emssec = new EMSSecurityObject($this->dn);
233
$aclreturn = $emssec->getEmsAclArray($newacls);
235
$this->emsaclarray = $aclreturn;
238
public function requireAcl($aclname)
241
return true; // This is WRONG, but necessary at the moment
243
if (array_key_exists($aclname,$this->emsaclarray)) {
244
$access = $this->emsaclarray[$aclname];
245
if ($access == Ecl_Acl::ACCESS_GRANTED)
246
Ecl_Log::info("Allowed access to ACL :$aclname to dn :".$this->getdn());
247
else if ($access == Ecl_Acl::ACCESS_DENIED)
248
throw new Ecl_AccessException("Access Denied to ACL : $aclname for dn ".$this->getdn());
250
Ecl_Log::error("Acl Calculation Ambiguous! Acl :$aclname has access :$access for dn :".
254
throw new Ecl_Exception("Acl $aclname not initialized for dn :".$this->getdn());
257
protected function addAttrs($attrs,$skipmerge=0)
263
$newattrs = array_diff($attrs,$this->attrs);
264
$this->attrs = array_merge($this->attrs,$newattrs);
265
$this->attrs = array_values($this->attrs);
269
Ecl_Log::debug("****Added ATTRS: ".implode(",",$newattrs));
270
if ($this instanceof EMSSecurityObject) {
271
Ecl_Log::debug("Skipping ACL loading for EMSSecurityObject at dn :$this->dn");
274
$emssec = new EMSSecurityObject($this->dn);
276
$acls = $emssec->getAclArray($newattrs);
279
$entries = $this->loadLdapDn();
281
foreach ($newattrs as $attr) {
282
if ($this instanceof EMSSecurityObject || $this->isNew()) {
283
$haswrite = $hasread = 1;
285
$hasread = preg_match("/\+".Ecl_Ldap_Aci::PERM_R."/",$acls[$attr]);
286
$haswrite = preg_match("/\+".Ecl_Ldap_Aci::PERM_W."/",$acls[$attr]);
289
if (is_array($entries) && array_key_exists($attr,$entries)) {
290
$value = $entries[$attr];
291
if ($value['count'] == 1)
293
else if ($value['count'] > 1)
294
$value = array_slice($value,1);
299
$this->params[$attr] = new Ecl_Parameter($attr,$value,$hasread,$haswrite);
303
public function getObject()
306
$modelclass = $this->getModelClass();
307
Ecl_Log::debug("Found modelclass : " . $modelclass);
309
if ($modelclass != null) {
310
$obj = new $modelclass($dn);
314
throw new Ecl_Exception("No modelclass found for dn : ".$dn);
317
public function getProperty($name,$forcearray=0)
319
if (array_key_exists($name,$this->params)) {
320
return $this->params[$name]->getValue($forcearray);
322
$bt = debug_backtrace();
324
Ecl_Log::error("Parameter: " . $name . " not loaded by dn: " . $this->getdn() .
325
" and classtype: " . get_class($this) . ". Called by: " . $bt[2]['class'] .
326
" on line: " . $bt[1]['line']);
330
public function getSecurityObject()
332
$emssec = new EMSSecurityObject($this->dn);
336
public function getParameter($name)
338
if (array_key_exists($name,$this->params)) {
339
return $this->params[$name];
341
Ecl_Log::error("Parameter: " . $name . " not loaded.");
344
public function setProperty($name,$value)
346
$bt = debug_backtrace();
347
$class = $bt[2]['class'];
348
$line = $bt[1]['line'];
350
Ecl_Log::debug("Set Property called with: " . $name . "=" . $value . " by " . $class . ":" . $line);
352
if (array_key_exists($name,$this->params)){
353
$retval = $this->params[$name]->setValue($value);
359
throw new Ecl_Exception("Parameter: " . $name . " not loaded.");
362
public function addPropertyItem($name,$value)
364
$param = $this->getParameter($name);
366
return $param->addValue($value);
369
public function removePropertyItem($name,$value)
371
Ecl_Log::debug("Removing property Item: " . $name);
372
$param = $this->getParameter($name);
375
return $param->removeValue($value);
378
public function addObjectClass($class)
380
$bt = debug_backtrace();
381
$classcalling = $bt[2]['class'];
382
$line = $bt[1]['line'];
383
Ecl_Log::debug("Add objectclass called adding: " . $class . " by: " . $classcalling . ":" . $line);
384
$param = $this->getParameter('objectclass');
385
$param->addValue($class);
388
public function removeObjectClass($class)
390
$param = $this->getParameter('objectclass');
391
$param->removeValue($class);
394
public static function loadDn($dn,$classname=null)
397
$bt = debug_backtrace();
398
$classcalling = $bt[2]['class'];
399
$line = $bt[1]['line'];
400
throw new Ecl_Exception("Attempt to load Null DN by: " . $classcalling . "::" . $line);
402
$testexist = new Ecl_Ldap_Engine($dn);
404
if (!$testexist->exists())
405
throw new Ecl_Exception("DN " . $dn . " does not exist in Ldap");
407
if ($classname == null) {
408
$obj = new Ecl_Ldap_Engine($dn);
409
return $obj->getObject();
410
} else if ($classname == 'NOMODEL') {
411
$obj = new $classname($dn);
415
$obj = new $classname($dn);
421
private function loadLdapDn()
426
$filter = "(objectclass=*)";
427
$entries = $this->search($filter,$this->attrs,$dn,"BASE");
429
if ($entries['count'] < 1)
430
throw new Ecl_Exception("dn: $dn does not exist in LDAP");
437
protected function reconnect($force=0)
439
if (!$this->conn || $force) {
443
if (!$this->resource || $force) {
444
$usercreds = self::getUserCreds();
446
if (isset($usercreds['auth']) && $usercreds['auth'] == 1) {
447
if (!$this->bind($usercreds['dn'],$usercreds['password']))
448
throw new Ecl_Ldap_Exception("Reconnection as user :".$usercreds['dn']." Failed! ");
450
Ecl_Log::info("Not Auth credentials, running anonymous");
454
public function search($filter,$attrs=null,$base=null,$scope=null)
457
$base = $this->ldapConfig->basedn;
463
$call = 'ldap_search';
464
else if ($scope == "ONE")
469
$attr_disp = implode(",",$attrs);
470
Ecl_Log::debug("Executing search with filter : $filter, base $base and attrs $attr_disp");
472
$results = $call($this->conn, $base, $filter, $attrs, 0, $this->ldapConfig->sizelimit,
473
$this->ldapConfig->timelimit, $this->ldapConfig->deref);
475
return ldap_get_entries($this->conn, $results);
478
private function mod_add($data)
480
if (sizeof($data) > 0) {
481
Ecl_Log::info("Attempting Ldap mod_add with dn: ".$this->dn);
482
$debdata = print_r($data,1);
483
Ecl_log::debug("mod add data : $debdata");
484
$ret = ldap_mod_add($this->conn,$this->dn,$data);
489
Ecl_Log::info("Ldap mod_add successfull with dn: " . $this->dn);
493
private function mod_del($data)
495
if (sizeof($data)>0) {
496
$dataarr = print_r($data,1);
497
Ecl_log::debug("Attempting mod del data with dn: ".$this->dn." data : $dataarr");
498
$ret = ldap_mod_del($this->conn,$this->dn,$data);
502
Ecl_Log::info("Ldap mod_del successfull with dn: " . $this->dn);
506
private function mod_replace($data)
508
if (sizeof($data) > 0) {
509
Ecl_Log::info("Attempting Ldap mod_replace with dn: ".$this->dn);
510
$debdata = print_r($data,1);
511
Ecl_log::debug("mod replace data : $debdata");
512
$ret = ldap_mod_replace($this->conn,$this->dn,$data);
516
Ecl_Log::info("Ldap mod_replace successfull with dn: " . $this->dn);
520
private function getError()
522
$error = ldap_error($this->conn);
523
$errcode = ldap_errno($this->conn);
524
throw new Ecl_Ldap_Exception("Ldap Caused Error",$error,$errcode);
527
public static function authenticate($uid=null,$dn=null,$password=null)
529
$engine = new Ecl_Ldap_Engine();
532
$dn = $engine->searchDn($uid);
533
Ecl_Log::debug("Auth got dn :$dn");
536
if ($engine->bind($dn,$password)) {
537
$_userSession = new Zend_Session_Namespace("userSession");
538
$securityConfig = Zend_Registry::get('securityConfig');
539
$_userSession->password = Ecl_Security::encrypt($password);
540
$_userSession->user_dn = $dn;
541
$_userSession->uid = $uid;
544
* Regenerate Session ID and Set Auth to true.
546
Zend_Session::regenerateId();
547
$_userSession->auth = 1;
548
$_userSession->setExpirationSeconds($securityConfig->inactivity_timeout, 'auth');
554
public function __wakeup()
560
public function wakeup()
565
private function connect()
567
if (!$this->conn = ldap_connect($this->ldapConfig->host, $this->ldapConfig->port))
568
throw new Ecl_Ldap_Exception("Connection to server ".$this->ldapConfig->host." failed");
570
if (!ldap_set_option($this->conn, LDAP_OPT_PROTOCOL_VERSION, $this->ldapConfig->protocol))
571
throw new Ecl_Ldap_Exception("LDAP Protocol version failed.");
573
if (!ldap_set_option($this->conn, LDAP_OPT_DEREF, $this->ldapConfig->deref))
574
throw new Ecl_Ldap_Exception("Could not set DEREF option.");
579
private function searchDn($uid)
585
$filter = '(uid='.$uid.')';
586
Ecl_Log::debug("LDAP Uid searching for uid = $filter");
588
$return = array('dn');
589
$rst = ldap_search($this->conn, $this->ldapConfig->basedn,$filter,$return);
590
$uidInfo = ldap_get_entries($this->conn, $rst);
592
if ($uidInfo["count"] > 1) {
594
* More than 1 ID returned -- this is a problem unless
595
* of course deref should have been set.
597
throw new Ecl_Ldap_Exception("FATAL::More than one unique ID
598
returned. Should deref be true?");
599
} elseif ($uidInfo["count"] == 0) {
600
Ecl_Log::error("LDAP: User not found. Authentication failed");
601
throw new Ecl_Exception("User: " . $uid . " not found. Authentication Failed");
604
* User found, try and bind with the established credentials
606
$dn = $uidInfo[0]["dn"];
612
protected function bind($dn=null,$password=null)
616
if (!$this->resource = ldap_bind($this->conn, $dn,$password)) {
617
Ecl_Log::error("LDAP: Authentication Failed as: " . $dn);
620
Ecl_Log::debug("LDAP: Authentication Successful as: " . $dn);
624
if (ldap_bind($this->conn)) {
625
Ecl_Log::debug("LDAP: Anonymous Auth Successful");
628
Ecl_Log::error("LDAP: Anonymous Auth disallowed");
634
private function smartupdate(&$array,$key,$val)
643
if (array_key_exists($key,$array)) {
644
if (is_array($array[$key]))
645
$array[$key] = array_merge($array[$key],$value);
647
$currvalue = $array[$key];
648
array_push($value,$currvalue);
649
$array[$key] = $value;
657
public function addItem($name,$value)
659
$this->smartupdate($this->_addarray,$name,$value);
662
public function updateItem($name,$value)
664
$this->smartupdate($this->_modarray,$name,$value);
668
public function removeItem($name,$value)
670
$this->smartupdate($this->_delarray,$name,$value);
673
public function deleteItem($name,$value)
675
$this->smartupdate($this->_delarray,$name,$value);
678
private function prepare()
680
$paramarray = $this->params;
682
foreach ($paramarray as $param) {
684
Ecl_Log::debug("Iterating for: " . $param->getId() . " and getchange is: " . $param->getChange());
685
Ecl_Log::debug($param->getValue());
686
Ecl_Log::debug("End parameter debug");
688
if (!$param->hasValidValue())
689
throw new Ecl_Exception("Invalid value in parameter: " . $param->getId());
691
if ($param->getChange() == Ecl_Parameter::CHANGE_ADDED) {
692
$this->addItem($param->getId(),$param->getValue());
693
$param->setPrepared();
694
$this->dirty_params[] = $param;
695
} else if ($param->getChange() == Ecl_Parameter::CHANGE_UPDATED && $param->getValue() != null) {
696
$this->updateItem($param->getId(),$param->getValue());
697
$param->setPrepared();
698
$this->dirty_params[] = $param;
699
} else if (($param->getChange() == Ecl_Parameter::CHANGE_UPDATED) && $param->getValue() == null) {
700
$this->deleteItem($param->getId(),$param->getOldValue());
701
$param->setPrepared();
702
$this->dirty_params[] = $param;
703
} else if ($param->getChange() == Ecl_Parameter::CHANGE_MULTIVALUEDADD) {
704
$this->addItem($param->getId(),$param->getMultiValuesAdded());
705
$param->setPrepared();
706
$this->dirty_params[] = $param;
707
} else if ($param->getChange() == Ecl_Parameter::CHANGE_MULTIVALUEDREMOVE ) {
708
$this->removeItem($param->getId(),$param->getMultiValuesRemoved());
709
$param->setPrepared();
710
$this->dirty_params[] = $param;
711
} else if ($param->getChange() == Ecl_Parameter::CHANGE_MULTIVALUEDADDREMOVE ) {
712
$this->removeItem($param->getId(),$param->getMultiValuesRemoved());
713
$this->addItem($param->getId(),$param->getMultiValuesAdded());
714
$param->setPrepared();
715
$this->dirty_params[] = $param;
720
public function add(Ecl_Ldap_Engine $parent,Ecl_Transaction_Handler $handler=null,$description=null)
723
$modelclass = get_class($this);
724
$this->setProperty('emsmodelclass',$modelclass);
726
if ($handler == null) {
727
$handler = $this->getTransaction();
730
$this->parent = $parent;
731
$this->makedn = $this->makeDn($parent);
733
if ($description == null)
734
$description = "Adding a: " . get_class($this) . " to LDAP with dn: " . $this->getdn();
736
$titem = new Ecl_Transaction_Item($description);
738
$titem->addObject('ldapobject',$this);
739
$titem->addObject('parent',$parent);
740
$titem->addCommitLine('$this->ldapobject->postAdd($this->parent);');
741
$titem->addCommitLine('$this->ldapobject->fireParameterEvents();');
742
$titem->addRollbackLine('$this->ldapobject->radd();');
743
$handler->addTransactionItem($titem);
747
public function fireParameterEvents()
749
foreach ($this->dirty_params as $param) {
750
$this->fireEvent("CORE_PCHANGE_".strtoupper($param->getId()));
754
$this->flushEvents();
758
public function flushLdap()
760
$this->_addarray = array();
761
$this->_delarray = array();
762
$this->_modarray = array();
765
public function flushEvents()
767
$this->dirty_params = array();
770
public function flush()
773
$this->flushEvents();
777
public function postAdd(Ecl_Ldap_Engine $parent)
780
$printadd = print_r($this->_addarray,1);
782
Ecl_Log::debug("Adding: " . $printadd);
784
$ret = ldap_add($this->conn,$this->makedn,$this->_addarray);
790
Ecl_Log::info("Ldap add successfull with dn:".$this->makedn);
791
$this->dn = $this->makedn;
792
unset($this->makedn);
796
public function update(Ecl_Transaction_Handler $handler=null,$description=null)
798
if ($handler == null)
799
$handler = $this->getTransaction();
801
$transaction = $handler;
803
if ($description == null)
804
$description = "Updating: ".get_class($this)." in LDAP with dn::".$this->getdn();
806
$titem = new Ecl_Transaction_Item($description);
807
$titem->addObject('ldapobject',$this);
808
$titem->addCommitLine('$this->ldapobject->postUpdate();');
809
$titem->addCommitLine('$this->ldapobject->fireParameterEvents();');
810
$titem->addRollbackLine('$this->ldapobject->rupdate();');
811
$transaction->addTransactionItem($titem);
815
public function fireEventLater($eventname,Ecl_Transaction_Handler $handler=null,$description=null)
817
if ($handler == null) {
818
$handler = $this->getTransaction();
819
Ecl_Log::info("Warning: FireEventLater called with Null transaction handler, " .
820
" make sure this is what you WANT");
823
if ($description == null)
824
$description = "Event: " . $eventname . " fired on " . get_class($this) . " dn: ". $this->getdn();
826
$titem = new Ecl_Transaction_Item($description);
827
$titem->addObject('ldapobject',$this);
828
$titem->addCommitLine('$this->ldapobject->fireEvent("'.$eventname.'");');
829
$handler->addTransactionItem($titem);
833
public function rupdate()
835
foreach ($this->params as $param)
836
$param->toUpdateRollbackMode();
838
$handler = new Ecl_Transaction_Handler();
839
$handler->setRollbackMode();
840
$handler = $this->update($handler);
844
protected function groupPolicyCheck($paramarray)
846
// Check and return 1 if group policies are okay. This is
847
// a generic GP check
851
public function isNew()
856
public function delete(Ecl_Transaction_Handler $transaction=null,$description=null)
858
if ($transaction == null)
859
$transaction = $this->getTransaction();
861
if ($description == null)
862
$description = "Deleting: " . get_class($this) . " from Ldap with dn: " . $this->getdn();
864
$titem = new Ecl_Transaction_Item($description);
865
$titem->addObject('ldapobject',$this);
866
$titem->addObject('emsparent',$this->getParent());
867
$titem->addCommitLine('$this->ldapobject->postDelete();');
868
$titem->addRollbackLine('$this->ldapobject->rdelete($this->emsparent);');
869
$transaction->addTransactionItem($titem);
874
public function getTransaction()
876
if ($this->transaction == null || $this->transaction->isCommitted())
877
$this->transaction = new Ecl_Transaction_Handler();
879
return $this->transaction;
882
public function getdn()
887
return $this->makedn;
892
public function getParent()
894
$appConfig = Zend_Registry::get('ldapConfig');
896
if ($this->getdn() == $appConfig->basedn) {
900
$tokendn = explode(',',$this->getdn());
901
$parentdnarray = array_slice($tokendn,1);
902
$parentdn = implode(',',$parentdnarray);
903
return Ecl_Ldap_Cache::loadDn($parentdn);
907
protected function getrdn()
912
protected function makeDn($parent)
914
return $this->getrdn().'='.$this->params[$this->getrdn()]->getValue().','.$parent->getdn();
917
public function postUpdate()
920
* We need to intelligently build a list using the add,mod and del
921
* arrays for a successful ldap mod_add operation.
922
* Note that update and add will function differently with the
923
* _addarray and _modarray when called. This is intentional
924
* You must use the functions properly. With great power comes
925
* great responsibility
929
* It is assumed that the user object has correctly filled
930
* the arrays. using add item means the user wants the items
931
* ADDED. This applies even to multi valued arrays. To add
932
* a new multi valued array item in ldap- the user object
933
* MUST use additem function. to modify existing entry, use
934
* the mod item function
938
$this->mod_del($this->_delarray,$this->dn);
939
$this->mod_replace($this->_modarray,$this->dn);
940
$this->mod_add($this->_addarray,$this->dn);
944
public function getImmediateChildren($filter=null,$emsIgnore=false)
946
return $this->getAllChildren($filter,'ONE',$emsIgnore);
949
public function getAllChildren($filter=null,$scope='SUB',$emsIgnore=false,$basedn=null)
952
* By ignoring OBJECTCLASS emsIgnore, we ensure there is no wastage
953
* in generating tree objects which are not required for display (like
954
* plugin entries housed in ldap)
956
* @note: the filter below needs the action plugin object to ignore.
962
if ($filter == null) {
963
if ($emsIgnore == false)
964
$filter = '(objectclass=emsobject)';
967
'(&(!(objectclass=emsIgnore))(objectclass=emsobject))';
971
Ecl_Log::debug("Calling getAllChildren with filter " .
975
* Generate immediate children objects.
978
$entries = $this->search($filter,array('dn'),$basedn,$scope);
982
* If a manual sort is run on the returned result, please ignore
983
* keys 0 and 1 as they (may) house EMSControl or ServiceContainer
984
* object types which should be listed before other entries appear.
986
* This is simply for a more consistent view of the tree.
989
$result_merge = array();
993
for ($i=0;$i<$entries['count'];$i++) {
994
$objdn = $entries[$i]['dn'];
995
if ($objdn != $this->dn) {
997
$objiter = Ecl_Ldap_Cache::loadDn($objdn);
1001
if ($tmp_get->getProperty('emstype') == 'ZiviosContainer') {
1002
$result_merge[0] = $tmp_get;
1003
} else if ($tmp_get->getProperty('emstype') == 'ServiceContainer') {
1004
$result_merge[$z] = $tmp_get;
1007
$result[$c] = $tmp_get;
1010
} catch (Ecl_AccessException $e) {
1011
Ecl_Log::info("Loading " .$objdn. " threw Exception : " .
1012
$e->getTraceAsString() . " ::: Ignoring");
1016
ksort(&$result_merge);
1017
return array_merge($result_merge, $result);
1020
public function postDelete()
1022
$ret = ldap_delete($this->conn,$this->dn);
1027
public static function getUserCreds()
1030
* @return array (with user credentials)
1032
$userSession = new Zend_Session_Namespace("userSession");
1034
'password' => Ecl_Security::decrypt($userSession->password),
1035
'dn' => $userSession->user_dn,
1036
'uid' => $userSession->uid,
1037
'auth' => $userSession->auth);