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