コード例 #1
0
ファイル: admin_ocf_ldap.php プロジェクト: erico-deh/ocPortal
 /**
  * The UI for LDAP synchronisation.
  *
  * @return tempcode		The UI
  */
 function gui()
 {
     $title = get_page_title('LDAP_SYNC');
     $groups_add = new ocp_tempcode();
     $groups_delete = new ocp_tempcode();
     $members_delete = new ocp_tempcode();
     $all_ldap_groups = ocf_get_all_ldap_groups();
     foreach ($all_ldap_groups as $group) {
         if (is_null(ocf_group_ldapcn_to_ocfid($group))) {
             $_group = str_replace(' ', '_space_', $group);
             $tpl = do_template('OCF_LDAP_LIST_ENTRY', array('_GUID' => '99aa6dd1a7a4caafd0199f8b5512cf29', 'NAME' => 'add_group_' . $_group, 'NICE_NAME' => $group));
             $groups_add->attach($tpl);
         }
     }
     $all_ocp_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list();
     foreach ($all_ocp_groups as $id => $group) {
         if (!in_array($group, $all_ldap_groups) && $id != db_get_first_id() + 0 && $id != db_get_first_id() + 1 && $id != db_get_first_id() + 8) {
             $tpl = do_template('OCF_LDAP_LIST_ENTRY', array('_GUID' => '48de4d176157941a0ce7caa7a1c395fb', 'NAME' => 'delete_group_' . strval($id), 'NICE_NAME' => $group));
             $groups_delete->attach($tpl);
         }
     }
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     $start = 0;
     do {
         $all_ldap_members = $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_username'), array('m_password_compat_scheme' => 'ldap'), '', 400, $start);
         foreach ($all_ldap_members as $row) {
             $id = $row['id'];
             $username = $row['m_username'];
             if (!ocf_is_ldap_member_potential($username)) {
                 $tpl = do_template('OCF_LDAP_LIST_ENTRY', array('_GUID' => '572c0f1e87a2dbe6cdf31d97fd71d3a4', 'NAME' => 'delete_member_' . strval($id), 'NICE_NAME' => $username));
                 $members_delete->attach($tpl);
             }
         }
         $start += 400;
     } while (array_key_exists(0, $all_ldap_members));
     $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF');
     return do_template('OCF_LDAP_SYNC_SCREEN', array('_GUID' => '38c608ce56cf3dbafb1dd1446c65d592', 'URL' => $post_url, 'TITLE' => $title, 'MEMBERS_DELETE' => $members_delete, 'GROUPS_DELETE' => $groups_delete, 'GROUPS_ADD' => $groups_add));
 }
コード例 #2
0
ファイル: ocf_ldap.php プロジェクト: erico-deh/ocPortal
/**
 * Find the ocPortal-ID for an LDAP usergroup-ID. POSIX Only.
 *
 * @param  integer	The LDAP ID.
 * @return ?GROUP		The ocPortal-ID (NULL: could not find).
 */
function ocf_group_ldapgid_to_ocfid($gid)
{
    global $LDAP_CONNECTION;
    $results = ldap_search($LDAP_CONNECTION, group_search_qualifier() . get_option('ldap_base_dn'), '(&(objectclass=' . get_group_class() . ')(gidnumber=' . ocp_ldap_escape(strval($gid)) . '))', array(group_property()), 1);
    $entries = ldap_get_entries($LDAP_CONNECTION, $results);
    if (!array_key_exists(0, $entries)) {
        return NULL;
    }
    if (array_key_exists(0, $entries[0][group_property()])) {
        $long_cn = $entries[0][group_property()][0];
        $cn = ocf_long_cn_to_short_cn($long_cn, group_property());
    } else {
        $long_cn = $entries[0]['dn'];
        // Might come out as DN
        $cn = ocf_long_cn_to_short_cn($long_cn, 'dn');
    }
    return ocf_group_ldapcn_to_ocfid($cn);
}