Example #1
0
File: Node.php Project: narixx/zf2
 /**
  * Factory method to create an attached Zend_Ldap_Node for a given DN.
  *
  * @param  string|array|\Zend\Ldap\Dn $dn
  * @param  \Zend\Ldap\Ldap                 $ldap
  * @return \Zend\Ldap\Node|null
  * @throws \Zend\Ldap\Exception
  */
 public static function fromLdap($dn, Ldap $ldap)
 {
     if (is_string($dn) || is_array($dn)) {
         $dn = Dn::factory($dn);
     } else {
         if ($dn instanceof Dn) {
             $dn = clone $dn;
         } else {
             throw new Exception(null, '$dn is of a wrong data type.');
         }
     }
     $data = $ldap->getEntry($dn, array('*', '+'), true);
     if ($data === null) {
         return null;
     }
     $entry = new self($dn, $data, true, $ldap);
     return $entry;
 }