本文整理汇总了PHP中Zend_Ldap::searchEntries方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Ldap::searchEntries方法的具体用法?PHP Zend_Ldap::searchEntries怎么用?PHP Zend_Ldap::searchEntries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Ldap
的用法示例。
在下文中一共展示了Zend_Ldap::searchEntries方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkDomain
public function checkDomain($params)
{
foreach ($params as $param) {
$data[$param['name']] = $param['value'];
}
if (empty($data['toCheck'])) {
throw new Exception('Podaj login zgłaszającego!');
}
$logic = new Logic_Validate_LdapLogin();
$config = Zend_Registry::get('config');
$servers = $config['ldap'];
foreach ($servers as $server) {
$ldap = new Zend_Ldap($server);
$ldap->bind($data['login'], $data['password']);
$ldapEntry = $ldap->searchEntries(Zend_Ldap_Filter::equals('samaccountname', $data['toCheck']));
if (!empty($ldapEntry)) {
break;
}
}
if (!empty($ldapEntry)) {
$ret['pm_name'] = $ldapEntry[0]['displayname'][0];
$ret['pm_email'] = $ldapEntry[0]['userprincipalname'][0];
return $ret;
} else {
throw new Exception('Nie znaleziono użytkownika w domenie!');
}
}
示例2: isValid
public function isValid($value)
{
$request = Zend_Controller_Front::getInstance()->getRequest();
$fields = $request->getParams();
$config = Zend_Registry::get('config');
$servers = $config['ldap'];
$valid = false;
foreach ($servers as $server) {
try {
$ldap = new Zend_Ldap($server);
$ldap->bind($fields['ldapUser'], $fields['ldapPassword']);
$ldapEntry = $ldap->searchEntries(Zend_Ldap_Filter::equals('samaccountname', $value));
if (!empty($ldapEntry)) {
$valid |= true;
}
} catch (Exception $e) {
$valid |= false;
}
}
if (!$valid) {
$this->_error(self::NOT_EXISTS);
return false;
}
return true;
}
示例3: getLdapData
/**
* Metoda pobierająca dane użytkownika o podanym loginie z domeny
* @param string $login
* @return array|boolean
*/
public function getLdapData($login, $ldapPwd)
{
$login = strtolower($login);
$config = Zend_Registry::get('config');
$identity = Zend_Auth::getInstance()->getIdentity();
$ldapServers = $config['ldap'];
foreach ($ldapServers as $server) {
try {
$ldap = new Zend_Ldap($server);
$ldap->bind($identity->login, $ldapPwd);
$ldapEntry = $ldap->searchEntries(Zend_Ldap_Filter::equals('samaccountname', $login));
if (!empty($ldapEntry)) {
return array_shift($ldapEntry);
}
} catch (Exception $e) {
// pusty catch - obsługa braku dostępu do wybranej domeny
// na podstawie danych zalogowanego użytkownika
}
}
return false;
}