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


PHP AuthLdap::sync_users方法代碼示例

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


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

示例1: auth_ldap_sync_users

/**
 * This command line PHP script will attempt to synchronize an institution list of Mahara accounts with an LDAP directory
 *
 * @param string $institutionname Name of the institution to process
 * @param array $onlycontexts Restrict searching in these contexts (override values set in authentication plugin)
 * @param boolean $searchsub search in subcontexts (override values set in authentication plugin)
 * @param string $extrafilterattribute additional LDAP filter to restrict user searching
 * @param boolean $doupdate update existing Mahara accounts with LDAP data (this may be long-running)
 * @param boolean $docreate create new accounts
 * @param string $tousersgonefromldap What to do with Mahara accounts no longer in LDAP. Should be null, 'delete', or 'suspend'
 * @param boolean $dryrun dummy execution. Do not perform any database operations
 * @return boolean
 */
function auth_ldap_sync_users($institutionname, $onlycontexts = null, $searchsub = null, $extrafilterattribute = null, $doupdate = null, $docreate = null, $tousersgonefromldap = null, $dryrun = false)
{
    log_info('---------- started institution user sync for institution "' . $institutionname . '" at ' . date('r', time()) . ' ----------');
    $auths = get_records_select_array('auth_instance', "authname in ('cas', 'ldap') and institution=?", array($institutionname));
    if (get_config('auth_ldap_debug_sync_cron')) {
        log_debug("auths candidates : ");
        var_dump($auths);
    }
    if (count($auths) == 0) {
        log_warn(get_string('nomatchingauths', 'auth.ldap'));
        return false;
    }
    $success = true;
    foreach ($auths as $auth) {
        $instance = new AuthLdap($auth->id);
        // Override the values stored in the auth_instance (i.e., if this is being called from a standalone cron script)
        $instance->set_config('syncuserscron', true);
        if ($onlycontexts !== null) {
            $instance->set_config('contexts', $onlycontexts);
        }
        if ($searchsub !== null) {
            $instance->set_config('search_sub', $searchsub ? 'yes' : 'no');
        }
        if ($extrafilterattribute !== null) {
            $instance->set_config('syncusersextrafilterattribute', $extrafilterattribute);
        }
        if ($doupdate !== null) {
            $instance->set_config('syncusersupdate', $doupdate);
        }
        if ($docreate !== null) {
            $instance->set_config('syncuserscreate', $docreate);
        }
        if ($tousersgonefromldap !== null) {
            $instance->set_config('syncusersgonefromldap', $tousersgonefromldap);
        }
        $success = $success && $instance->sync_users($dryrun);
    }
    log_info('---------- finished institutino user sync at ' . date('r', time()) . ' ----------');
    return $success;
}
開發者ID:vohung96,項目名稱:mahara,代碼行數:53,代碼來源:lib.php


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