/** * 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); }
/** * @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); }
/** * Returns a string representation of the filter. * * @return string */ public function toString() { return '(!' . $this->_filter->toString() . ')'; }