当前位置: 首页>>代码示例>>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;未经允许,请勿转载。