Example #1
0
$ldap['SRC'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_src'));
$ldap['DST'] = $_SESSION[APPCONFIG]->getServer(get_request('server_id_dst'));
# Error checking
if (!trim($request['dnDST'])) {
    error(_('You left the destination DN blank.'), 'error', 'index.php');
}
if ($ldap['DST']->isReadOnly()) {
    error(_('Destination server is currently READ-ONLY.'), 'error', 'index.php');
}
if ($ldap['DST']->dnExists($request['dnDST'])) {
    error(sprintf(_('The destination entry (%s) already exists.'), pretty_print_dn($request['dnDST'])), 'error', 'index.php');
}
if (!$ldap['DST']->dnExists($ldap['DST']->getContainer($request['dnDST']))) {
    error(sprintf(_('The destination container (%s) does not exist.'), pretty_print_dn($ldap['DST']->getContainer($request['dnDST']))), 'error', 'index.php');
}
if (pla_compare_dns($request['dnSRC'], $request['dnDST']) == 0 && $ldap['SRC']->getIndex() == $ldap['DST']->getIndex()) {
    error(_('The source and destination DN are the same.'), 'error', 'index.php');
}
$request['recursive'] = get_request('recursive') == 'on' ? true : false;
$request['remove'] = get_request('remove') == 'yes' ? true : false;
if ($request['recursive']) {
    $filter = get_request('filter', 'POST', false, '(objectClass=*)');
    # Build a tree similar to that of the tree browser to give to r_copy_dn
    $ldap['tree'] = array();
    printf('<h3 class="title">%s%s</h3>', _('Copying '), $request['dnSRC']);
    printf('<h3 class="subtitle">%s</h3>', _('Recursive copy progress'));
    print '<br /><br />';
    print '<small>';
    printf('%s...', _('Building snapshot of tree to copy'));
    $ldap['tree'] = build_tree($ldap['SRC'], $request['dnSRC'], array(), $filter);
    printf('<span style="color:green">%s</span><br />', _('Success'));
Example #2
0
if ($ldapserver_dst->isReadOnly()) {
    pla_error(_('Destination server is currently READ-ONLY.'));
}
if (!$ldapserver_src->haveAuthInfo() || !$ldapserver_dst->haveAuthInfo()) {
    pla_error(_('Not enough information to login to server. Please check your configuration.'));
}
$dn_src = $_POST['old_dn'];
$dn_dst = $_POST['new_dn'];
$do_recursive = isset($_POST['recursive']) && $_POST['recursive'] == 'on' ? true : false;
$do_remove = isset($_POST['remove']) && $_POST['remove'] == 'yes' ? true : false;
include './header.php';
# Error checking
if (0 == strlen(trim($dn_dst))) {
    pla_error(_('You left the destination DN blank.'));
}
if (pla_compare_dns($dn_src, $dn_dst) == 0 && $server_id_src == $server_id_dst) {
    pla_error(_('The source and destination DN are the same.'));
}
if ($ldapserver_dst->dnExists($dn_dst)) {
    pla_error(sprintf(_('The destination entry (%s) already exists.'), pretty_print_dn($dn_dst)));
}
if (!$ldapserver_dst->dnExists(get_container($dn_dst))) {
    pla_error(sprintf(_('The destination container (%s) does not exist.'), pretty_print_dn(get_container($dn_dst))));
}
if ($do_recursive) {
    $filter = isset($_POST['filter']) ? $_POST['filter'] : '(objectClass=*)';
    # Build a tree similar to that of the tree browser to give to r_copy_dn
    $snapshot_tree = array();
    print '<body>';
    printf('<h3 class="title">%s%s</h3>', _('Copying '), htmlspecialchars($dn_src));
    printf('<h3 class="subtitle">%s</h3>', _('Recursive copy progress'));
Example #3
0
echo '</script>';
echo '<table class="forminput" width=100% border=0>';
if ($request['container']) {
    printf('<tr><td class="heading" colspan=3>%s:</td><td>%s</td></tr>', _('Server'), $app['server']->getName());
    printf('<tr><td class="heading" colspan=3>%s:</td><td>%s</td></tr>', _('Looking in'), $request['container']);
    echo '<tr><td class="blank" colspan=4>&nbsp;</td></tr>';
}
# Has the user already begun to descend into a specific server tree?
if (isset($app['server']) && !is_null($request['container'])) {
    $request['children'] = $app['server']->getContainerContents($request['container'], null, 0, '(objectClass=*)', $_SESSION[APPCONFIG]->getValue('deref', 'tree'));
    sort($request['children']);
    foreach ($app['server']->getBaseDN() as $base) {
        if (DEBUG_ENABLED) {
            debug_log('Comparing BaseDN [%s] with container [%s]', 64, 0, __FILE__, __LINE__, __METHOD__, $base, $request['container']);
        }
        if (!pla_compare_dns($request['container'], $base)) {
            $parent_container = false;
            $href['up'] = sprintf('entry_chooser.php?form_element=%s&rdn=%s', $request['element'], rawurlencode($request['rdn']));
            break;
        } else {
            $parent_container = $app['server']->getContainer($request['container']);
            $href['up'] = sprintf('entry_chooser.php?form_element=%s&rdn=%s&server_id=%s&container=%s', $request['element'], $request['rdn'], $app['server']->getIndex(), rawurlencode($parent_container));
        }
    }
    echo '<tr>';
    echo '<td class="blank">&nbsp;</td>';
    printf('<td class="icon"><a href="%s"><img src="%s/up.png" alt="Up" /></a></td>', $href['up'], IMGDIR);
    printf('<td colspan=2><a href="%s">%s...</a></td>', $href['up'], _('Back Up'));
    echo '</tr>';
    if (!count($request['children'])) {
        printf('<td class="blank" colspan=2>&nbsp;</td><td colspan=2">(%s)</td>', _('no entries'));
Example #4
0
    error(sprintf(_('The entry (%s) does not exist.'), $request['dn']), 'error', 'index.php');
}
$request['page'] = new PageRender($app['server']->getIndex(), get_request('template', 'REQUEST', false, 'none'));
$request['page']->setDN($request['dn']);
$request['page']->accept();
$request['template'] = $request['page']->getTemplate();
# Perform the modification
$result = $app['server']->modify($request['dn'], $request['template']->getLDAPmodify());
if ($result) {
    # Fire the post modification event to the user's custom callback function.
    $mustRelogin = false;
    foreach ($request['template']->getLDAPmodify() as $attr_name => $val) {
        /* Was this a user's password modification who is currently
         * logged in? If so, they need to logout and log back in
         * with the new password. */
        if ($attr_name == 'userpassword' && in_array($app['server']->getValue('login', 'auth_type'), array('cookie', 'session')) && pla_compare_dns($app['server']->getLogin(), $request['dn']) === 0) {
            $mustRelogin = true;
        }
    }
    # If the user password was changed, not tell the to relogin.
    if ($mustRelogin) {
        $app['server']->logout('user');
        unset($_SESSION['ACTIVITY'][$app['server']->getIndex()]);
        system_message(array('title' => _('Modification successful!'), 'body' => _('Since you changed your password, you must now login again with your new password.'), 'type' => 'info'), sprintf('cmd.php?cmd=login_form&server_id=%s', $app['server']->getIndex()));
        exit;
    }
    $redirect_url = sprintf('cmd.php?cmd=template_engine&server_id=%s&dn=%s', $app['server']->getIndex(), rawurlencode($request['dn']));
    foreach ($request['template']->getLDAPmodify() as $attr => $junk) {
        $redirect_url .= sprintf('&modified_attrs[]=%s', $attr);
    }
    header("Location: {$redirect_url}");
Example #5
0
    }
}
// tests pla_compare_dns()
if (false) {
    echo "Should all be 0:<br>";
    $dns1 = array('cn=joe,dc=example,dc=com', 'cn=joe,dc=example,dc=com', 'cn = bob, dc= example,dc =com');
    $dns2 = array('cn=joe,dc=example,dc=com', 'CN =joe,dc=Example,dc =com', 'cn= bob, dc= example,dc =com');
    for ($i = 0; $i < count($dns1); $i++) {
        var_dump(pla_compare_dns($dns1[$i], $dns2[$i]));
        echo "\n";
    }
    echo "Should all be ! 0:<br>";
    $dns1 = array('dc=test,dc=example,dc=com', 'cn=Fred,cn=joe,dc=example,dc=com', 'cn=joe2,dc=example,dc=com', 'cn = bob, dc= example,dc =com');
    $dns2 = array('dc=example, dc=com', 'cn=joe,dc=example,dc=com', 'CN =joe,dc=Example2,dc =com', 'cn= 2bob, dc= example,dc =com');
    for ($i = 0; $i < count($dns1); $i++) {
        var_dump(pla_compare_dns($dns1[$i], $dns2[$i]));
        echo "\n";
    }
}
// testing get_rdn()
if (false) {
    echo "Should be uid=bäb: ";
    echo get_rdn("uid=bäb,ou=People-copy1,ou=People-copy2,ou=People2,dc=example,dc=com");
    echo "<br>\n";
    echo "Should be dc=com: ";
    echo get_rdn("dc=com");
    echo "<br>\n";
    echo "Should be Fred: ";
    echo get_rdn("Fred");
    echo "<br>\n";
}
    echo '<br />';
    printf('%s<b>%s</b>', _('Looking in: '), htmlspecialchars($container));
    echo '<br />';
}
/* Has the use already begun to descend into a specific server tree? */
if (isset($ldapserver) && $container !== false) {
    if (!$ldapserver->haveAuthInfo()) {
        pla_error(_('Not enough information to login to server. Please check your configuration.'));
    }
    $dn_list = $ldapserver->getContainerContents($container, 0, '(objectClass=*)', $config->GetValue('deref', 'tree'));
    sort($dn_list);
    foreach ($ldapserver->getBaseDN() as $base_dn) {
        if (DEBUG_ENABLED) {
            debug_log('entry_chooser.php: Comparing BaseDN [%s] with container [%s]', 64, $base_dn, $container);
        }
        if (!pla_compare_dns($container, $base_dn)) {
            $parent_container = false;
            $up_href = sprintf('entry_chooser.php?form_element=%s&amp;rdn=%s', $return_form_element, $rdn);
            break;
        } else {
            $parent_container = get_container($container);
            $up_href = sprintf('entry_chooser.php?form_element=%s&amp;rdn=%s&amp;server_id=%s&amp;container=%s', $return_form_element, $rdn, $ldapserver->server_id, rawurlencode($parent_container));
        }
    }
    echo '&nbsp;';
    printf('<a href="%s" style="text-decoration:none"><img src="images/up.png" /> %s</a>', $up_href, _('Back Up...'));
    echo '<br />';
    if (!count($dn_list)) {
        printf('&nbsp;&nbsp;&nbsp;(%s)<br />', _('no entries'));
    } else {
        foreach ($dn_list as $dn) {
Example #7
0
        $failed_attrs[$attr_name] = $val;
    } elseif ($ldapserver->isAttrReadOnly($attr)) {
        pla_error(sprintf(_('The attribute "%s" is flagged as read-only in the phpLDAPadmin configuration.'), htmlspecialchars($attr_name)));
    }
}
# Perform the modification
$res = $ldapserver->modify($dn, $update_array);
if ($res) {
    # Fire the post modification event to the user's custom callback function.
    $mustRelogin = false;
    foreach ($update_array as $attr_name => $val) {
        run_hook('post_attr_modify', array('server_id' => $ldapserver->server_id, 'dn' => $dn, 'attr_name' => $attr_name, 'new_value' => $val));
        /* Was this a user's password modification who is currently
           logged in? If so, they need to logout and log back in
           with the new password. */
        if (0 === strcasecmp($attr_name, 'userPassword') && in_array($ldapserver->auth_type, array('cookie', 'session')) && pla_compare_dns($ldapserver->getLoggedInDN(), $dn) === 0) {
            $mustRelogin = true;
        }
    }
    run_hook('post_update', array('server_id' => $ldapserver->server_id, 'dn' => $dn, 'update_array' => $update_array));
    # If the user password was changed, not tell the to relogin.
    if ($mustRelogin) {
        $ldapserver->unsetLoginDN();
        unset_lastactivity($ldapserver);
        include './header.php';
        echo '<body>';
        echo '<script type="text/javascript" language="javascript">';
        echo 'parent.left_frame.location.reload();';
        echo '</script>' . "\n\n";
        echo '<br />';
        echo '<center>';