當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Ldap::ldap_status方法代碼示例

本文整理匯總了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));
    }
}
開發者ID:kvakanet,項目名稱:ldap_login,代碼行數:22,代碼來源:main.inc.php

示例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'];
                }
            }
開發者ID:kvakanet,項目名稱:ldap_login,代碼行數:31,代碼來源:configuration.php


注:本文中的Ldap::ldap_status方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。