本文整理汇总了PHP中Ldap::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Ldap::getConnection方法的具体用法?PHP Ldap::getConnection怎么用?PHP Ldap::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ldap
的用法示例。
在下文中一共展示了Ldap::getConnection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLdapMemberGroups
public static function getLdapMemberGroups()
{
if (Ldap::getConnection()) {
$query = ldap_search(Ldap::getConnection(), 'CN=groups,' . $GLOBALS['TL_CONFIG']['ldap_base'], "(objectClass=*)", LdapMemberGroup::getAttributes());
if (!$query) {
return false;
}
$found = ldap_get_entries(Ldap::getConnection(), $query);
// groups not found
if (!is_array($found) || count($found) <= 0) {
return false;
}
return $found;
} else {
return false;
}
}
示例2: findLdapMember
public static function findLdapMember($strUsername)
{
if (Ldap::getConnection()) {
$user_name_filter = $GLOBALS['TL_CONFIG']['ldap_uid'] . '=' . $strUsername;
$filter = '(&(' . $user_name_filter . ')' . $GLOBALS['TL_CONFIG']['ldap_filter_person'] . ')';
// search by username
$query = ldap_search(Ldap::getConnection(), $GLOBALS['TL_CONFIG']['ldap_base'], $filter, LdapMember::getAttributes());
if (!$query) {
return null;
}
$found = ldap_get_entries(Ldap::getConnection(), $query);
// user not found
if (!is_array($found) || count($found) <= 0) {
return null;
}
$found = (object) $found[0];
return $found;
} else {
return null;
}
}
示例3: authenticateLdapMember
public static function authenticateLdapMember($strUsername, $strPassword)
{
$objLdapUser = LdapMemberModel::findLdapMember($strUsername);
if ($objLdapUser) {
if (!@ldap_bind(Ldap::getConnection(), $objLdapUser->dn, $strPassword)) {
$errno = ldap_errno(Ldap::getConnection());
switch ($errno) {
case static::LDAP_INVALID_CREDENTIALS:
return false;
}
return false;
}
// ldap account requires an valid email and uid
if ($objLdapUser->uid['count'] == 0 || $objLdapUser->mail['count'] == 0) {
\Message::addError($GLOBALS['TL_LANG']['MSC']['ldap']['emailUidMissing']);
return false;
}
return true;
} else {
return false;
}
}