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


PHP AuthLdap::getAllUsers方法代碼示例

本文整理匯總了PHP中AuthLdap::getAllUsers方法的典型用法代碼示例。如果您正苦於以下問題:PHP AuthLdap::getAllUsers方法的具體用法?PHP AuthLdap::getAllUsers怎麽用?PHP AuthLdap::getAllUsers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AuthLdap的用法示例。


在下文中一共展示了AuthLdap::getAllUsers方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: import

/**
 * Function to import or synchronise all the users from an ldap directory
 *
 * @param $options   array
**/
function import(array $options)
{
    global $CFG_GLPI;
    $results = array(AuthLDAP::USER_IMPORTED => 0, AuthLDAP::USER_SYNCHRONIZED => 0, AuthLDAP::USER_DELETED_LDAP => 0);
    //The ldap server id is passed in the script url (parameter server_id)
    $limitexceeded = false;
    $actions_to_do = array();
    switch ($options['action']) {
        case AuthLDAP::ACTION_IMPORT:
            $actions_to_do = array(AuthLDAP::ACTION_IMPORT);
            break;
        case AuthLDAP::ACTION_SYNCHRONIZE:
            $actions_to_do = array(AuthLDAP::ACTION_SYNCHRONIZE);
            break;
        case AuthLDAP::ACTION_ALL:
            $actions_to_do = array(AuthLDAP::ACTION_IMPORT, AuthLDAP::ACTION_ALL);
            break;
    }
    foreach ($actions_to_do as $action_to_do) {
        $options['mode'] = $action_to_do;
        $options['authldaps_id'] = $options['ldapservers_id'];
        $users = AuthLdap::getAllUsers($options, $results, $limitexceeded);
        $contact_ok = true;
        if (is_array($users)) {
            foreach ($users as $user) {
                $result = AuthLdap::ldapImportUserByServerId(array('method' => AuthLDAP::IDENTIFIER_LOGIN, 'value' => $user["user"]), $action_to_do, $options['ldapservers_id']);
                if ($result) {
                    $results[$result['action']] += 1;
                }
                echo ".";
            }
        } else {
            if (!$users) {
                $contact_ok = false;
            }
        }
    }
    if ($limitexceeded) {
        echo "\nLDAP Server size limit exceeded";
        if ($CFG_GLPI['user_deleted_ldap']) {
            echo ": user deletion disabled\n";
        }
        echo "\n";
    }
    if ($contact_ok) {
        echo "\nImported: " . $results[AuthLDAP::USER_IMPORTED] . "\n";
        echo "Synchronized: " . $results[AuthLDAP::USER_SYNCHRONIZED] . "\n";
        echo "Deleted from LDAP: " . $results[AuthLDAP::USER_DELETED_LDAP] . "\n";
    } else {
        echo "Cannot contact LDAP server!\n";
    }
    echo "\n\n";
}
開發者ID:jose-martins,項目名稱:glpi,代碼行數:58,代碼來源:ldap_mass_sync.php


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