public function __construct($source = null, $entry = null) { if ($entry && (is_object($entry) || is_array($entry))) { if (is_array($entry)) { $entry = Zend_Ldap_Node::fromArray($entry); } $this->node = $entry; $attrs = $entry->getAttributes(false); foreach ($attrs as $attr => $value) { $this->remoteProperties[$attr] = $value; } if (isset($this->uid)) { $this->Title = is_array($this->uid) ? implode($this->uid) : $this->uid; } else { if (isset($this->cn)) { $this->Title = is_array($this->cn) ? implode($this->cn) : $this->cn; } else { if (isset($this->ou)) { $this->Title = is_array($this->ou) ? implode($this->ou) : $this->ou; } else { $this->Title = $entry->getCurrentDN(); } } } $this->DN = $entry->getCurrentDN(); parent::__construct($source, $entry->getCurrentDn()); } else { parent::__construct($source, $entry); } }
/** * Creates the data structure for the given entry data * * @param array $data * @return Zend_Ldap_Node */ protected function _createEntry(array $data) { /** * @see Zend_Ldap_Node */ $node = Zend_Ldap_Node::fromArray($data, true); $node->attachLdap($this->_iterator->getLdap()); return $node; }
/** * Creates the data structure for the given entry data * * @param array $data * @return Zend_Ldap_Node */ protected function _createEntry(array $data) { /** * @see Zend_Ldap_Node */ require_once PHP_LIBRARY_PATH . 'Zend/Ldap/Node.php'; $node = Zend_Ldap_Node::fromArray($data, true); $node->attachLdap($this->_iterator->getLdap()); return $node; }
public function testExistsDn() { $data = array('dn' => $this->_createDn('ou=name,'), 'ou' => array('name'), 'l' => array('a', 'b', 'c'), 'objectClass' => array('organizationalUnit', 'top')); $node1 = Zend_Ldap_Node::fromArray($data); $node1->attachLdap($this->_getLdap()); $this->assertFalse($node1->exists()); $dn = $this->_createDn('ou=Test1,'); $node2 = Zend_Ldap_Node::fromLdap($dn, $this->_getLdap()); $this->assertTrue($node2->exists()); }
/** * @return Zend_Ldap_Node */ protected function _createTestNode() { return Zend_Ldap_Node::fromArray($this->_createTestArrayData(), true); }
public function testDnObjectCloning() { $node1 = $this->_createTestNode(); $dn1 = Zend_Ldap_Dn::fromString('cn=name2,dc=example,dc=org'); $node1->setDn($dn1); $dn1->prepend(array('cn' => 'name')); $this->assertNotEquals($dn1->toString(), $node1->getDn()->toString()); $dn2 = Zend_Ldap_Dn::fromString('cn=name2,dc=example,dc=org'); $node2 = Zend_Ldap_Node::create($dn2); $dn2->prepend(array('cn' => 'name')); $this->assertNotEquals($dn2->toString(), $node2->getDn()->toString()); $dn3 = Zend_Ldap_Dn::fromString('cn=name2,dc=example,dc=org'); $node3 = Zend_Ldap_Node::fromArray(array('dn' => $dn3, 'ou' => 'Test'), false); $dn3->prepend(array('cn' => 'name')); $this->assertNotEquals($dn3->toString(), $node3->getDn()->toString()); }
/** * Reads out all users from configured ldap backend and creates or update * existing users. * * Also disabling deleted ldap users in humhub */ public function refreshUsers() { $ldapUserIds = array(); try { $items = $this->ldap->search(HSetting::Get('userFilter', 'authentication_ldap'), HSetting::Get('baseDn', 'authentication_ldap'), Zend_Ldap::SEARCH_SCOPE_SUB); foreach ($items as $item) { $node = Zend_Ldap_Node::fromArray($item); $user = $this->handleLdapUser($node); if ($user != null) { $ldapUserIds[] = $user->id; } } foreach (User::model()->findAllByAttributes(array('auth_mode' => User::AUTH_MODE_LDAP), 'status!=' . User::STATUS_DISABLED) as $user) { if (!in_array($user->id, $ldapUserIds)) { // User not longer available in ldap $user->status = User::STATUS_DISABLED; $user->save(); Yii::log('Disabled user ' . $user->username . ' (' . $user->id . ') - Not found in LDAP!', CLogger::LEVEL_ERROR, 'authentication_ldap'); } } } catch (Exception $ex) { Yii::log($ex->getMessage(), CLogger::LEVEL_ERROR, 'authentication_ldap'); } }
/** * ZF-11611 */ public function testRdnAttributesHandleMultiValuedAttribute3() { $data = array('dn' => 'cn=funkygroup,ou=Groupes,dc=domain,dc=local', 'objectClass' => array('groupOfNames', 'top'), 'cn' => array(0 => 'The Funkygroup'), 'member' => 'uid=john-doe,ou=Users,dc=domain,dc=local'); $node = Zend_Ldap_Node::fromArray($data, true); $cn = $node->getAttribute('cn'); $this->assertEquals(array(0 => 'The Funkygroup', 1 => 'funkygroup'), $cn); }