コード例 #1
0
ファイル: UpdateTest.php プロジェクト: navtis/xerxes-pazpar2
 public function testMoveNode()
 {
     $dnOld = $this->_createDn('ou=Test1,');
     $dnNew = $this->_createDn('ou=Test,');
     $node = Node::fromLDAP($dnOld, $this->_getLDAP());
     $node->setDn($dnNew);
     $node->update();
     $this->assertFalse($this->_getLDAP()->exists($dnOld));
     $this->assertTrue($this->_getLDAP()->exists($dnNew));
     $node = Node::fromLDAP($dnNew, $this->_getLDAP());
     $node->move($dnOld);
     $node->update();
     $this->assertFalse($this->_getLDAP()->exists($dnNew));
     $this->assertTrue($this->_getLDAP()->exists($dnOld));
     $node = Node::fromLDAP($dnOld, $this->_getLDAP());
     $node->rename($dnNew);
     $node->update();
     $this->assertFalse($this->_getLDAP()->exists($dnOld));
     $this->assertTrue($this->_getLDAP()->exists($dnNew));
 }
コード例 #2
0
ファイル: Ldap.php プロジェクト: Rovak/zf2
 /**
  * Returns the specified DN as a Zend\Ldap\Node
  *
  * @param  string|Dn $dn
  * @return Node|null
  * @throws Exception\LdapException
  */
 public function getNode($dn)
 {
     return Node::fromLdap($dn, $this);
 }
コード例 #3
0
ファイル: OnlineTest.php プロジェクト: navtis/xerxes-pazpar2
 public function testLoadFromLDAPWithDnObject()
 {
     $dn = Ldap\Dn::fromString($this->_createDn('ou=Test1,'));
     $node = Node::fromLDAP($dn, $this->_getLDAP());
     $this->assertInstanceOf('Zend\\Ldap\\Node', $node);
     $this->assertTrue($node->isAttached());
 }
コード例 #4
0
 /**
  * @return Node
  */
 protected function createTestNode()
 {
     return Node::fromArray($this->createTestArrayData(), true);
 }
コード例 #5
0
ファイル: OfflineTest.php プロジェクト: haoyanfei/zf2
 /**
  * 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);
 }
コード例 #6
0
ファイル: TestCase.php プロジェクト: navtis/xerxes-pazpar2
 /**
  * @return Zend_Ldap_Node
  */
 protected function _createTestNode()
 {
     return \Zend\Ldap\Node::fromArray($this->_createTestArrayData(), true);
 }
コード例 #7
0
ファイル: Collection.php プロジェクト: eltondias/Relogio
 /**
  * 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;
 }
コード例 #8
0
ファイル: Ldap.php プロジェクト: 1resu/humhub
 /**
  * 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());
     }
 }
コード例 #9
0
ファイル: OfflineTest.php プロジェクト: alab1001101/zf2
 public function testGetChanges()
 {
     $node = $this->_createTestNode();
     $node->host = array('d');
     $node->empty = 'not Empty';
     unset($node->boolean);
     $changes = $node->getChanges();
     $this->assertEquals(array('add' => array('empty' => array('not Empty')), 'delete' => array('boolean' => array()), 'replace' => array('host' => array('d'))), $changes);
     $node = Node::create('uid=test,dc=example,dc=org', array('account'));
     $node->host = 'host';
     unset($node->cn);
     unset($node['sn']);
     $node['givenName'] = 'givenName';
     $node->appendToAttribute('objectClass', 'domain');
     $this->assertEquals(array('uid' => array('test'), 'objectclass' => array('account', 'domain'), 'host' => array('host'), 'givenname' => array('givenName')), $node->getChangedData());
     $this->assertEquals(array('add' => array('uid' => array('test'), 'objectclass' => array('account', 'domain'), 'host' => array('host'), 'givenname' => array('givenName')), 'delete' => array(), 'replace' => array()), $node->getChanges());
 }