本文整理汇总了PHP中Ldap::ldap_status方法的典型用法代码示例。如果您正苦于以下问题:PHP Ldap::ldap_status方法的具体用法?PHP Ldap::ldap_status怎么用?PHP Ldap::ldap_status使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ldap
的用法示例。
在下文中一共展示了Ldap::ldap_status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_user
function update_user($username, $id)
{
$up = new Ldap();
$up->load_config();
$up->ldap_conn() or error_log("Unable to connect LDAP server : " . $up->getErrorString());
// update user piwigo rights / access according to ldap. Only if it's webmaster / admin, so no normal !
if ($up->ldap_status($username) != 'normal') {
single_update(USER_INFOS_TABLE, array('status' => $up->ldap_status($username)), array('user_id' => $id));
}
// search groups
$group_query = 'SELECT name, id FROM ' . GROUPS_TABLE . ';';
$result = pwg_query($group_query);
$inserts = array();
while ($row = pwg_db_fetch_assoc($result)) {
if ($up->user_membership($username, $up->ldap_group($row['name']))) {
$inserts[] = array('user_id' => $id, 'group_id' => $row['id']);
}
}
if (count($inserts) > 0) {
mass_inserts(USER_GROUP_TABLE, array('user_id', 'group_id'), $inserts, array('ignore' => true));
}
}
示例2: foreach
// Check LDAP configuration
// the user need to have saved his config to do that.
if (isset($_POST['check_ldap'])) {
if ($me->config['users_group']) {
if ($me->user_membership($_POST['USERNAME'], $me->ldap_group($me->config['users_group']))) {
if ($me->ldap_bind_as($_POST['USERNAME'], $_POST['PASSWORD'])) {
// search groups
$group_query = 'SELECT name, id FROM ' . GROUPS_TABLE . ';';
$groups = pwg_query($group_query);
$sentence = '';
foreach ($groups as $group) {
if ($me->user_membership($_POST['USERNAME'], $me->ldap_group($group['name']))) {
$sentence = $sentence . ', ' . $group['name'];
}
}
$template->assign('LD_CHECK_LDAP', '<p style="color:green;">Configuration LDAP OK : ' . $_POST['USERNAME'] . ' is in users' . $sentence . ' group(s) and can auth. He is a ' . $me->ldap_status($_POST['USERNAME']) . ' user according to the plugin.</p>');
} else {
$template->assign('LD_CHECK_LDAP', '<p style="color:red;">Error : test ' . $me->config['uri'] . ' ' . $me->ldap_name($_POST['USERNAME']) . '</p>');
}
}
} else {
if ($me->ldap_bind_as($_POST['USERNAME'], $_POST['PASSWORD'])) {
// search groups
$group_query = 'SELECT name, id FROM ' . GROUPS_TABLE . ';';
$groups = pwg_query($group_query);
$sentence = '';
foreach ($groups as $group) {
if ($me->user_membership($_POST['USERNAME'], $me->ldap_group($group['name']))) {
$sentence = $sentence . ', ' . $group['name'];
}
}