public function testExistsDn() { $data = array('dn' => $this->_createDn('ou=name,'), 'ou' => array('name'), 'l' => array('a', 'b', 'c'), 'objectClass' => array('organizationalUnit', 'top')); $node1 = Node::fromArray($data); $node1->attachLDAP($this->_getLDAP()); $this->assertFalse($node1->exists()); $dn = $this->_createDn('ou=Test1,'); $node2 = Node::fromLDAP($dn, $this->_getLDAP()); $this->assertTrue($node2->exists()); }
/** * @return Node */ protected function createTestNode() { return Node::fromArray($this->createTestArrayData(), true); }
/** * 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 = Ldap\Node::fromArray($data, true); $cn = $node->getAttribute('cn'); $this->assertEquals(array(0 => 'The Funkygroup', 1 => 'funkygroup'), $cn); }
/** * @return Zend_Ldap_Node */ protected function _createTestNode() { return \Zend\Ldap\Node::fromArray($this->_createTestArrayData(), true); }
/** * Creates the data structure for the given entry data * * @param array $data * @return \Zend\Ldap\Node */ protected function createEntry(array $data) { $node = Ldap\Node::fromArray($data, true); $node->attachLDAP($this->iterator->getLDAP()); return $node; }
/** * 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(Setting::Get('userFilter', 'authentication_ldap'), Setting::Get('baseDn', 'authentication_ldap'), \Zend\Ldap\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::find()->where(['auth_mode' => User::AUTH_MODE_LDAP])->andWhere(['!=', 'status', User::STATUS_DISABLED])->each() as $user) { if (!in_array($user->id, $ldapUserIds)) { // User no longer available in ldap $user->status = User::STATUS_DISABLED; $user->save(); Yii::warning('Disabled user ' . $user->username . ' (' . $user->id . ') - Not found in LDAP!'); } } } catch (Exception $ex) { Yii::error($ex->getMessage()); } }
public function testDnObjectCloning() { $node1 = $this->_createTestNode(); $dn1 = 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 = Ldap\Dn::fromString('cn=name2,dc=example,dc=org'); $node2 = Node::create($dn2); $dn2->prepend(array('cn' => 'name')); $this->assertNotEquals($dn2->toString(), $node2->getDn()->toString()); $dn3 = Ldap\Dn::fromString('cn=name2,dc=example,dc=org'); $node3 = Node::fromArray(array('dn' => $dn3, 'ou' => 'Test'), false); $dn3->prepend(array('cn' => 'name')); $this->assertNotEquals($dn3->toString(), $node3->getDn()->toString()); }