Пример #1
0
function install_etape_ldap4_dist()
{
    $adresse_ldap = _request('adresse_ldap');
    $login_ldap = _request('login_ldap');
    $pass_ldap = _request('pass_ldap');
    $port_ldap = _request('port_ldap');
    $base_ldap = _request('base_ldap');
    $base_ldap_text = _request('base_ldap_text');
    if (!$base_ldap) {
        $base_ldap = $base_ldap_text;
    }
    echo install_debut_html();
    $ldap_link = ldap_connect($adresse_ldap, $port_ldap);
    @ldap_bind($ldap_link, $login_ldap, $pass_ldap);
    // Essayer de verifier le chemin fourni
    $r = @ldap_compare($ldap_link, $base_ldap, "objectClass", "");
    $fail = ldap_errno($ldap_link) == 32;
    if ($fail) {
        echo info_etape(_T('info_chemin_acces_annuaire')), info_progression_etape(3, 'etape_ldap', 'install/', true), "<div class='error'><p><b>" . _T('avis_operation_echec') . "</b></p><p>" . _T('avis_chemin_invalide_1'), " (<tt>" . htmlspecialchars($base_ldap) . "</tt>) " . _T('avis_chemin_invalide_2') . "</p></div>";
    } else {
        info_etape(_T('info_reglage_ldap'));
        echo info_progression_etape(4, 'etape_ldap', 'install/');
        $statuts = liste_statuts_ldap();
        $statut_ldap = defined('_INSTALL_STATUT_LDAP') ? _INSTALL_STATUT_LDAP : $GLOBALS['liste_des_statuts']['info_redacteurs'];
        $res = install_propager(array('adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap')) . "<input type='hidden' name='etape' value='ldap5' />" . "<input type='hidden' name='base_ldap' value='" . htmlentities($base_ldap) . "' />" . fieldset(_T('info_statut_utilisateurs_1'), array('statut_ldap' => array('label' => _T('info_statut_utilisateurs_2') . '<br />', 'valeur' => $statut_ldap, 'alternatives' => $statuts))) . install_ldap_correspondances() . bouton_suivant();
        echo generer_form_ecrire('install', $res);
    }
    echo install_fin_html();
}
Пример #2
0
function install_etape_ldap3_dist()
{
    $adresse_ldap = _request('adresse_ldap');
    $login_ldap = _request('login_ldap');
    $pass_ldap = _request('pass_ldap');
    $port_ldap = _request('port_ldap');
    $base_ldap_text = defined('_INSTALL_BASE_LDAP') ? _INSTALL_BASE_LDAP : "ou=users, dc=mon-domaine, dc=com";
    echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"');
    echo info_etape(_T('info_chemin_acces_1'), info_progression_etape(3, 'etape_ldap', 'install/')), _T('info_chemin_acces_2');
    $ldap_link = @ldap_connect("{$adresse_ldap}", "{$port_ldap}");
    if ($ldap_link) {
        @ldap_bind($ldap_link, "{$login_ldap}", "{$pass_ldap}");
        $result = @ldap_read($ldap_link, "", "objectclass=*", array("namingContexts"));
        $info = @ldap_get_entries($ldap_link, $result);
        @ldap_close($ldap_link);
    }
    $checked = false;
    $res = '';
    if (is_array($info) and $info["count"] > 0) {
        $res .= "<p>" . _T('info_selection_chemin_acces') . "</p>";
        $res .= "<ul>";
        $n = 0;
        for ($i = 0; $i < $info["count"]; $i++) {
            $names = $info[$i]["namingcontexts"];
            if (is_array($names)) {
                for ($j = 0; $j < $names["count"]; $j++) {
                    $n++;
                    $res .= "<li><input name=\"base_ldap\" value=\"" . spip_htmlspecialchars($names[$j]) . "\" type='radio' id='tab{$n}'";
                    if (!$checked) {
                        $res .= " checked=\"checked\"";
                        $checked = true;
                    }
                    $res .= " />";
                    $res .= "<label for='tab{$n}'>" . spip_htmlspecialchars($names[$j]) . "</label></li>\n";
                }
            }
        }
        $res .= "</ul>";
        $res .= _T('info_ou') . " ";
    }
    $res .= "<br />\n<input name=\"base_ldap\" value=\"\" type='radio' id='manuel'";
    if (!$checked) {
        $res .= " checked=\"checked\"";
        $checked = true;
    }
    $res .= " />" . "\n<label for='manuel'>" . _T('entree_chemin_acces') . "</label> " . "\n<fieldset>" . "<input type='text' name='base_ldap_text' class='text' value=\"{$base_ldap_text}\" size='40' />" . "\n</fieldset>" . "\n<input type='hidden' name='etape' value='ldap4' />" . install_propager(array('adresse_ldap', 'port_ldap', 'login_ldap', 'pass_ldap', 'protocole_ldap', 'tls_ldap')) . bouton_suivant();
    echo generer_form_ecrire('install', $res);
    echo install_fin_html();
}