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


PHP Dn::toArray方法代码示例

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


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

示例1: copy

 /**
  * Copies a LDAP entry from one DN to another DN.
  *
  * @param  string|Dn $from
  * @param  string|Dn $to
  * @param  boolean   $recursively
  * @return Ldap Provides a fluid interface
  * @throws Exception\LdapException
  */
 public function copy($from, $to, $recursively = false)
 {
     $entry = $this->getEntry($from, array(), true);
     if ($to instanceof Dn) {
         $toDnParts = $to->toArray();
     } else {
         $toDnParts = Dn::explodeDn($to);
     }
     $this->add($to, $entry);
     if ($recursively === true && $this->countChildren($from) > 0) {
         $children = $this->getChildrenDns($from);
         foreach ($children as $c) {
             $cDnParts = Dn::explodeDn($c);
             $newChildParts = array_merge(array(array_shift($cDnParts)), $toDnParts);
             $newChild = Dn::implodeDn($newChildParts);
             $this->copy($c, $newChild, true);
         }
     }
     return $this;
 }
开发者ID:Rovak,项目名称:zf2,代码行数:29,代码来源:Ldap.php

示例2: isChildOf

 /**
  * Checks if given $childDn is beneath $parentDn subtree.
  *
  * @param  string|Dn $childDn
  * @param  string|Dn $parentDn
  * @return bool
  */
 public static function isChildOf($childDn, $parentDn)
 {
     try {
         $keys = [];
         $vals = [];
         if ($childDn instanceof Dn) {
             $cdn = $childDn->toArray(DN::ATTR_CASEFOLD_LOWER);
         } else {
             $cdn = static::explodeDn($childDn, $keys, $vals, DN::ATTR_CASEFOLD_LOWER);
         }
         if ($parentDn instanceof Dn) {
             $pdn = $parentDn->toArray(DN::ATTR_CASEFOLD_LOWER);
         } else {
             $pdn = static::explodeDn($parentDn, $keys, $vals, DN::ATTR_CASEFOLD_LOWER);
         }
     } catch (Exception\LdapException $e) {
         return false;
     }
     $startIndex = count($cdn) - count($pdn);
     if ($startIndex < 0) {
         return false;
     }
     for ($i = 0, $count = count($pdn); $i < $count; $i++) {
         if ($cdn[$i + $startIndex] != $pdn[$i]) {
             return false;
         }
     }
     return true;
 }
开发者ID:GeeH,项目名称:zend-ldap,代码行数:36,代码来源:Dn.php


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