当前位置: 首页>>代码示例>>PHP>>正文


PHP Dn::fromArray方法代码示例

本文整理汇总了PHP中Zend\Ldap\Dn::fromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Dn::fromArray方法的具体用法?PHP Dn::fromArray怎么用?PHP Dn::fromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Ldap\Dn的用法示例。


在下文中一共展示了Dn::fromArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDnCreation

 public function testDnCreation()
 {
     Ldap\Dn::setDefaultCaseFold(Ldap\Dn::ATTR_CASEFOLD_NONE);
     $dnString1 = 'CN=Baker\\, Alice,CN=Users+OU=Lab,DC=example,DC=com';
     $dnArray1 = array(array('CN' => 'Baker, Alice'), array('CN' => 'Users', 'OU' => 'Lab'), array('DC' => 'example'), array('DC' => 'com'));
     $dnString2 = 'cn=Baker\\, Alice,cn=Users+ou=Lab,dc=example,dc=com';
     $dnArray2 = array(array('cn' => 'Baker, Alice'), array('cn' => 'Users', 'ou' => 'Lab'), array('dc' => 'example'), array('dc' => 'com'));
     $dnString3 = 'Cn=Baker\\, Alice,Cn=Users+Ou=Lab,Dc=example,Dc=com';
     $dnArray3 = array(array('Cn' => 'Baker, Alice'), array('Cn' => 'Users', 'Ou' => 'Lab'), array('Dc' => 'example'), array('Dc' => 'com'));
     $dn11 = Ldap\Dn::fromString($dnString1);
     $dn12 = Ldap\Dn::fromArray($dnArray1);
     $dn13 = Ldap\Dn::factory($dnString1);
     $dn14 = Ldap\Dn::factory($dnArray1);
     $this->assertEquals($dn11, $dn12);
     $this->assertEquals($dn11, $dn13);
     $this->assertEquals($dn11, $dn14);
     $this->assertEquals($dnString1, $dn11->toString());
     $this->assertEquals($dnString1, $dn11->toString(Ldap\Dn::ATTR_CASEFOLD_UPPER));
     $this->assertEquals($dnString2, $dn11->toString(Ldap\Dn::ATTR_CASEFOLD_LOWER));
     $this->assertEquals($dnArray1, $dn11->toArray());
     $this->assertEquals($dnArray1, $dn11->toArray(Ldap\Dn::ATTR_CASEFOLD_UPPER));
     $this->assertEquals($dnArray2, $dn11->toArray(Ldap\Dn::ATTR_CASEFOLD_LOWER));
     $dn21 = Ldap\Dn::fromString($dnString2);
     $dn22 = Ldap\Dn::fromArray($dnArray2);
     $dn23 = Ldap\Dn::factory($dnString2);
     $dn24 = Ldap\Dn::factory($dnArray2);
     $this->assertEquals($dn21, $dn22);
     $this->assertEquals($dn21, $dn23);
     $this->assertEquals($dn21, $dn24);
     $this->assertEquals($dnString2, $dn21->toString());
     $this->assertEquals($dnString1, $dn21->toString(Ldap\Dn::ATTR_CASEFOLD_UPPER));
     $this->assertEquals($dnString2, $dn21->toString(Ldap\Dn::ATTR_CASEFOLD_LOWER));
     $this->assertEquals($dnArray2, $dn21->toArray());
     $this->assertEquals($dnArray1, $dn21->toArray(Ldap\Dn::ATTR_CASEFOLD_UPPER));
     $this->assertEquals($dnArray2, $dn21->toArray(Ldap\Dn::ATTR_CASEFOLD_LOWER));
     $this->assertEquals($dnArray2, $dn22->toArray());
     $dn31 = Ldap\Dn::fromString($dnString3);
     $dn32 = Ldap\Dn::fromArray($dnArray3);
     $dn33 = Ldap\Dn::factory($dnString3);
     $dn34 = Ldap\Dn::factory($dnArray3);
     $this->assertEquals($dn31, $dn32);
     $this->assertEquals($dn31, $dn33);
     $this->assertEquals($dn31, $dn34);
     $this->assertEquals($dnString3, $dn31->toString());
     $this->assertEquals($dnString1, $dn31->toString(Ldap\Dn::ATTR_CASEFOLD_UPPER));
     $this->assertEquals($dnString2, $dn31->toString(Ldap\Dn::ATTR_CASEFOLD_LOWER));
     $this->assertEquals($dnArray3, $dn31->toArray());
     $this->assertEquals($dnArray1, $dn31->toArray(Ldap\Dn::ATTR_CASEFOLD_UPPER));
     $this->assertEquals($dnArray2, $dn31->toArray(Ldap\Dn::ATTR_CASEFOLD_LOWER));
     try {
         $dn = Ldap\Dn::factory(1);
         $this->fail('Expected Zend_LDAP_Exception not thrown');
     } catch (Ldap\Exception $e) {
         $this->assertEquals('Invalid argument type for $dn', $e->getMessage());
     }
 }
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:56,代码来源:CreationTest.php

示例2: copyToSubtree

 /**
  * Copies a LDAP entry from one DN to another subtree.
  *
  * @param  string|Dn $from
  * @param  string|Dn $to
  * @param  boolean   $recursively
  * @return Ldap Provides a fluid interface
  * @throws Exception\LdapException
  */
 public function copyToSubtree($from, $to, $recursively = false)
 {
     if ($from instanceof Dn) {
         $orgDnParts = $from->toArray();
     } else {
         $orgDnParts = Dn::explodeDn($from);
     }
     if ($to instanceof Dn) {
         $newParentDnParts = $to->toArray();
     } else {
         $newParentDnParts = Dn::explodeDn($to);
     }
     $newDnParts = array_merge(array(array_shift($orgDnParts)), $newParentDnParts);
     $newDn = Dn::fromArray($newDnParts);
     return $this->copy($from, $newDn, $recursively);
 }
开发者ID:Rovak,项目名称:zf2,代码行数:25,代码来源:Ldap.php


注:本文中的Zend\Ldap\Dn::fromArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。