當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Ldap_Node類代碼示例

本文整理匯總了PHP中Zend_Ldap_Node的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Ldap_Node類的具體用法?PHP Zend_Ldap_Node怎麽用?PHP Zend_Ldap_Node使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Zend_Ldap_Node類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _createEntry

 /**
  * 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;
 }
開發者ID:kobmaki,項目名稱:icingaweb2,代碼行數:15,代碼來源:Collection.php

示例2: _createEntry

 /**
  * 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;
 }
開發者ID:netixx,項目名稱:Stock,代碼行數:16,代碼來源:Collection.php

示例3: getNode

 /**
  * Returns the specified DN as a Zend_Ldap_Node
  *
  * @param  string|Zend_Ldap_Dn $dn
  * @return Zend_Ldap_Node|null
  * @throws Zend_Ldap_Exception
  */
 public function getNode($dn)
 {
     /**
      * Zend_Ldap_Node
      */
     #require_once 'Zend/Ldap/Node.php';
     return Zend_Ldap_Node::fromLdap($dn, $this);
 }
開發者ID:jpbender,項目名稱:mage_virtual,代碼行數:15,代碼來源:Ldap.php

示例4: testLoadFromLdapWithDnObject

 public function testLoadFromLdapWithDnObject()
 {
     $dn = Zend_Ldap_Dn::fromString($this->_createDn('ou=Test1,'));
     $node = Zend_Ldap_Node::fromLdap($dn, $this->_getLdap());
     $this->assertType('Zend_Ldap_Node', $node);
     $this->assertTrue($node->isAttached());
 }
開發者ID:travisj,項目名稱:zf,代碼行數:7,代碼來源:OnlineTest.php

示例5: _createTestNode

 /**
  * @return Zend_Ldap_Node
  */
 protected function _createTestNode()
 {
     return Zend_Ldap_Node::fromArray($this->_createTestArrayData(), true);
 }
開發者ID:crodriguezn,項目名稱:crossfit-milagro,代碼行數:7,代碼來源:TestCase.php

示例6: getNode

 /**
  * Returns the specified DN as a Zend_Ldap_Node
  *
  * @param  string|Zend_Ldap_Dn $dn
  * @return Zend_Ldap_Node|null
  * @throws Zend_Ldap_Exception
  */
 public function getNode($dn)
 {
     /**
      * Zend_Ldap_Node
      */
     require_once PHP_LIBRARY_PATH . 'Zend/Ldap/Node.php';
     return Zend_Ldap_Node::fromLdap($dn, $this);
 }
開發者ID:netixx,項目名稱:Stock,代碼行數:15,代碼來源:Ldap.php

示例7: testGetChanges

 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 = Zend_Ldap_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());
 }
開發者ID:netvlies,項目名稱:zf,代碼行數:17,代碼來源:OfflineTest.php

示例8: testMoveNode

 public function testMoveNode()
 {
     $dnOld = $this->_createDn('ou=Test1,');
     $dnNew = $this->_createDn('ou=Test,');
     $node = Zend_Ldap_Node::fromLdap($dnOld, $this->_getLdap());
     $node->setDn($dnNew);
     $node->update();
     $this->assertFalse($this->_getLdap()->exists($dnOld));
     $this->assertTrue($this->_getLdap()->exists($dnNew));
     $node = Zend_Ldap_Node::fromLdap($dnNew, $this->_getLdap());
     $node->move($dnOld);
     $node->update();
     $this->assertFalse($this->_getLdap()->exists($dnNew));
     $this->assertTrue($this->_getLdap()->exists($dnOld));
     $node = Zend_Ldap_Node::fromLdap($dnOld, $this->_getLdap());
     $node->rename($dnNew);
     $node->update();
     $this->assertFalse($this->_getLdap()->exists($dnOld));
     $this->assertTrue($this->_getLdap()->exists($dnNew));
 }
開發者ID:crodriguezn,項目名稱:crossfit-milagro,代碼行數:20,代碼來源:UpdateTest.php

示例9: handleLdapUser

 /**
  * Updates or creates user by given ldap node
  * 
  * @param Zend_Ldap_Node $node
  * @return User User Object
  */
 public function handleLdapUser($node)
 {
     $username = $node->getAttribute(HSetting::Get('usernameAttribute', 'authentication_ldap'), 0);
     $email = $node->getAttribute('mail', 0);
     $guid = $this->binToStrGuid($node->getAttribute('objectGUID', 0));
     // Try to load User:
     $userChanged = false;
     $user = null;
     if ($guid != "") {
         $user = User::model()->findByAttributes(array('guid' => $guid, 'auth_mode' => User::AUTH_MODE_LDAP));
     } else {
         // Fallback use e-mail
         $user = User::model()->findByAttributes(array('email' => $email, 'auth_mode' => User::AUTH_MODE_LDAP));
     }
     if ($user === null) {
         $user = new User();
         if ($guid != "") {
             $user->guid = $guid;
         }
         $user->status = User::STATUS_ENABLED;
         $user->auth_mode = User::AUTH_MODE_LDAP;
         $user->group_id = 1;
         Yii::log('Create ldap user ' . $username . '!', CLogger::LEVEL_INFO, 'authentication_ldap');
     }
     // Update Group Mapping
     foreach (Group::model()->findAll('ldap_dn != ""') as $group) {
         if (in_array($group->ldap_dn, $node->getAttribute('memberOf'))) {
             if ($user->group_id != $group->id) {
                 $userChanged = true;
                 $user->group_id = $group->id;
             }
         }
     }
     // Update Users Field
     if ($user->username != $username) {
         $userChanged = true;
         $user->username = $username;
     }
     if ($user->email != $email) {
         $userChanged = true;
         $user->email = $email;
     }
     if ($user->validate()) {
         // Only Save user when something is changed
         if ($userChanged || $user->isNewRecord) {
             $user->save();
         }
         // Update Profile Fields
         foreach (ProfileField::model()->findAll('ldap_attribute != ""') as $profileField) {
             $ldapAttribute = $profileField->ldap_attribute;
             $profileFieldName = $profileField->internal_name;
             $user->profile->{$profileFieldName} = $node->getAttribute($ldapAttribute, 0);
         }
         if ($user->profile->validate()) {
             $user->profile->save();
             // Update Space Mapping
             foreach (Space::model()->findAll('ldap_dn != ""') as $space) {
                 if (in_array($space->ldap_dn, $node->getAttribute('memberOf'))) {
                     $space->addMember($user->id);
                 }
             }
         } else {
             Yii::log('Could not create or update ldap user profile! (' . print_r($user->profile->getErrors(), true) . ")", CLogger::LEVEL_ERROR, 'authentication_ldap');
         }
     } else {
         Yii::log('Could not create or update ldap user! (' . print_r($user->getErrors(), true) . ")", CLogger::LEVEL_ERROR, 'authentication_ldap');
     }
     return $user;
 }
開發者ID:luizreginaldo,項目名稱:humhub,代碼行數:75,代碼來源:HLdap.php

示例10: handleLdapUser

 /**
  * Updates or creates user by given ldap node
  * 
  * @param Zend_Ldap_Node $node
  * @return User User Object
  */
 public function handleLdapUser($node)
 {
     $usernameAttribute = Setting::Get('usernameAttribute', 'authentication_ldap');
     if ($usernameAttribute == '') {
         $usernameAttribute = 'sAMAccountName';
     }
     $emailAttribute = Setting::Get('emailAttribute', 'authentication_ldap');
     if ($emailAttribute == '') {
         $emailAttribute = 'mail';
     }
     $username = $node->getAttribute($usernameAttribute, 0);
     $email = $node->getAttribute($emailAttribute, 0);
     $guid = $this->binToStrGuid($node->getAttribute('objectGUID', 0));
     // Try to load User:
     $userChanged = false;
     $user = null;
     if ($guid != "") {
         $user = User::findOne(array('guid' => $guid, 'auth_mode' => User::AUTH_MODE_LDAP));
     } else {
         // Fallback use e-mail
         $user = User::findOne(array('email' => $email, 'auth_mode' => User::AUTH_MODE_LDAP));
     }
     if ($user === null) {
         $user = new User();
         if ($guid != "") {
             $user->guid = $guid;
         }
         $user->status = User::STATUS_ENABLED;
         $user->auth_mode = User::AUTH_MODE_LDAP;
         $user->group_id = 1;
         Yii::info('Create ldap user ' . $username . '!');
     }
     // Update Users Field
     if ($user->username != $username) {
         $userChanged = true;
         $user->username = $username;
     }
     if ($user->email != $email) {
         $userChanged = true;
         $user->email = $email;
     }
     if ($user->validate()) {
         // Only Save user when something is changed
         if ($userChanged || $user->isNewRecord) {
             $user->save();
         }
         // Update Profile Fields
         foreach (ProfileField::find()->andWhere(['!=', 'ldap_attribute', ''])->all() as $profileField) {
             $ldapAttribute = $profileField->ldap_attribute;
             $profileFieldName = $profileField->internal_name;
             $user->profile->{$profileFieldName} = $node->getAttribute($ldapAttribute, 0);
         }
         if ($user->profile->validate() && $user->profile->save()) {
             $this->trigger(self::EVENT_UPDATE_USER, new ParameterEvent(['user' => $user, 'node' => $node]));
         } else {
             Yii::error('Could not create or update ldap user profile! (' . print_r($user->profile->getErrors(), true) . ")");
         }
     } else {
         Yii::error('Could not create or update ldap user! (' . print_r($user->getErrors(), true) . ")");
     }
     return $user;
 }
開發者ID:1resu,項目名稱:humhub,代碼行數:68,代碼來源:Ldap.php

示例11: testRdnAttributesHandleMultiValuedAttribute3

 /**
  * 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);
 }
開發者ID:omusico,項目名稱:logica,代碼行數:10,代碼來源:OfflineTest.php

示例12: getNode

 /**
  * Returns the specified DN as a Zend_Ldap_Node
  *
  * @param  string|Zend_Ldap_Dn $dn
  * @return Zend_Ldap_Node|null
  * @throws Zend_Ldap_Exception
  */
 public function getNode($dn)
 {
     /**
      * Zend_Ldap_Node
      */
     return Zend_Ldap_Node::fromLdap($dn, $this);
 }
開發者ID:kobmaki,項目名稱:icingaweb2,代碼行數:14,代碼來源:Ldap.php

示例13: numChildren

 public function numChildren()
 {
     $conn = $this->source->getLdap();
     if ($conn) {
         return $conn->countChildren($this->node->getCurrentDN());
     }
     return 0;
 }
開發者ID:nyeholt,項目名稱:silverstripe-ldap-connector,代碼行數:8,代碼來源:LdapContentItem.php


注:本文中的Zend_Ldap_Node類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。