Example #1
0
 /**
  * Fix a bug, ex. CN=Alice Baker,CN=Users,DC=example,DC=com
  *
  * @param  string $acctname
  * @return string - Account DN
  */
 protected function getAccountDn($acctname)
 {
     $baseDn = $this->getBaseDn();
     if ($this->getBindRequiresDn() && isset($baseDn)) {
         try {
             return parent::getAccountDn($acctname);
         } catch (\Zend\Ldap\Exception\LdapException $zle) {
             if ($zle->getCode() != \Zend\Ldap\Exception\LdapException::LDAP_NO_SUCH_OBJECT) {
                 throw $zle;
             }
         }
         $acctname = $this->usernameAttribute . '=' . \Zend\Ldap\Filter\AbstractFilter::escapeValue($acctname) . ',' . $baseDn;
     }
     return parent::getAccountDn($acctname);
 }
Example #2
0
File: Ldap.php Project: Rovak/zf2
 /**
  * @param  string $acctname
  * @return string The LDAP search filter for matching directory accounts
  */
 protected function getAccountFilter($acctname)
 {
     $dname = '';
     $aname = '';
     $this->splitName($acctname, $dname, $aname);
     $accountFilterFormat = $this->getAccountFilterFormat();
     $aname = Filter\AbstractFilter::escapeValue($aname);
     if ($accountFilterFormat) {
         return sprintf($accountFilterFormat, $aname);
     }
     if (!$this->getBindRequiresDn()) {
         // is there a better way to detect this?
         return sprintf("(&(objectClass=user)(sAMAccountName=%s))", $aname);
     }
     return sprintf("(&(objectClass=posixAccount)(uid=%s))", $aname);
 }
Example #3
0
 /**
  * Returns a string representation of the filter.
  *
  * @return string
  */
 public function toString()
 {
     return '(!' . $this->_filter->toString() . ')';
 }