function pla_rdelete($server_id, $dn)
{
    $children = get_container_contents($server_id, $dn);
    global $ds;
    $ds = pla_ldap_connect($server_id);
    if (!is_array($children) || count($children) == 0) {
        echo "<nobr>Deleting " . htmlspecialchars($dn) . "...";
        flush();
        if (ldap_delete($ds, $dn)) {
            echo " <span style=\"color:green\">Success</span></nobr><br />\n";
            return true;
        } else {
            pla_error("Failed to delete dn: " . htmlspecialchars(utf8_decode($dn)), ldap_error($ds), ldap_errno($ds));
        }
    } else {
        foreach ($children as $child_dn) {
            pla_rdelete($server_id, $child_dn);
        }
        echo "<nobr>Deleting " . htmlspecialchars($dn) . "...";
        flush();
        if (ldap_delete($ds, $dn)) {
            echo " <span style=\"color:green\">Success</span></nobr><br />\n";
            return true;
        } else {
            pla_errror("Failed to delete dn: " . htmlspecialchars(utf8_decode($dn)), ldap_error($ds), ldap_errno($ds));
        }
    }
}
Example #2
0
function pla_rdelete($ldapserver, $dn)
{
    $children = $ldapserver->getContainerContents($dn);
    if (!is_array($children) || count($children) == 0) {
        printf('<nobr>' . _('Deleting %s') . '...', htmlspecialchars($dn));
        flush();
        if (run_hook('pre_entry_delete', array('server_id' => $ldapserver->server_id, 'dn' => $dn))) {
            if ($ldapserver->delete($dn)) {
                run_hook('post_entry_delete', array('server_id' => $ldapserver->server_id, 'dn' => $dn));
                printf(' <span style="color:green">%s</span></nobr><br />', _('Success'));
                return true;
            } else {
                pla_error(sprintf(_('Failed to delete entry %s'), htmlspecialchars($dn)), $ldapserver->error(), $ldapserver->errno());
            }
        }
    } else {
        foreach ($children as $child_dn) {
            pla_rdelete($ldapserver, $child_dn);
        }
        printf('<nobr>' . _('Deleting %s') . '...', htmlspecialchars($dn));
        flush();
        if (run_hook('pre_entry_delete', array('server_id' => $ldapserver->server_id, 'dn' => $dn))) {
            if ($ldapserver->delete($dn)) {
                run_hook('post_entry_delete', array('server_id' => $ldapserver->server_id, 'dn' => $dn));
                printf(' <span style="color:green">%s</span></nobr><br />', _('Success'));
                return true;
            } else {
                pla_error(sprintf(_('Failed to delete entry %s'), htmlspecialchars($dn)), $ldapserver->error(), $ldapserver->errno());
            }
        }
    }
}
/**
 * Check if custom session timeout has been reached for server $ldapserver.
 * If it has:
 * 	- automatically log out user by calling $ldapserver->unsetLoginDN()
 *	- if $server_id is equal to right frame $server_id, load timeout.php page in the right frame
 *	- return true
 *
 * @param object $ldapserver The LDAPServer object of the server which the user has logged in.
 * @return bool true on success, false on failure.
 */
function session_timed_out($ldapserver)
{
    if (DEBUG_ENABLED) {
        debug_log('session_timed_out(): Entered with (%s)', 1, $ldapserver->server_id);
    }
    # If session hasn't expired yet
    if (isset($_SESSION['activity']['server'][$ldapserver->server_id])) {
        # If $session_timeout not defined, use (session_cache_expire() - 1)
        if (!isset($ldapserver->session_timeout)) {
            $session_timeout = session_cache_expire() - 1;
        } else {
            $session_timeout = $ldapserver->session_timeout;
        }
        # Get the $last_activity and $rightframe_server_id value
        $last_activity = $_SESSION['activity']['server'][$ldapserver->server_id];
        # If diff between current time and last activity greater than $session_timeout, log out user
        if (time() - $last_activity > $session_timeout * 60) {
            if (in_array($ldapserver->auth_type, array('cookie', 'session'))) {
                syslog_notice('Logout for ' . $ldapserver->getLoggedInDN());
                $ldapserver->unsetLoginDN() or pla_error(_('Could not logout.'));
            }
            return true;
        } else {
            return false;
        }
    }
}
if (is_server_read_only($server_id)) {
    pla_error("You cannot perform updates while server is in read-only mode");
}
check_server_id($server_id) or pla_error("Bad server_id: " . htmlspecialchars($server_id));
have_auth_info($server_id) or pla_error("Not enough information to login to server. Please check your configuration.");
// special case for binary attributes (like jpegPhoto and userCertificate):
// we must go read the data from the file and override $val with the binary data
if ($is_binary_val) {
    $file = $_FILES['val']['tmp_name'];
    $f = fopen($file, 'r');
    $binary_data = fread($f, filesize($file));
    fclose($f);
    $val = $binary_data;
}
// Automagically hash new userPassword attributes according to the
// chosen in config.php.
if (0 == strcasecmp($attr, 'userpassword')) {
    if ($servers[$server_id]['default_hash'] != '') {
        $enc_type = $servers[$server_id]['default_hash'];
        $new_val = password_hash($new_val, $enc_type);
        $val = $new_val;
    }
}
$ds = pla_ldap_connect($server_id) or pla_error("Could not connect to LDAP server");
$new_entry = array($attr => $val);
$result = @ldap_mod_add($ds, $dn, $new_entry);
if ($result) {
    header("Location: edit.php?server_id={$server_id}&dn={$encoded_dn}&updated_attr={$encoded_attr}");
} else {
    pla_error("Failed to add the attribute.", ldap_error($ds), ldap_errno($ds));
}
    ?>
</td>
		</td>
	</tr>
	<tr>
		<td colspan="3"><center><br /><input type="submit" value="Proceed &gt;&gt;" /></td>
	</tr>
	</table>
	</center>

<?php 
} elseif ($step == 2) {
    $dc_name = trim($_POST['dc_name']);
    $container = trim($_POST['container']);
    $associateddomain = trim($_POST['associateddomain']);
    dn_exists($server_id, $container) or pla_error("The container you specified (" . htmlspecialchars($container) . ") does not exist. " . "Please go back and try again.");
    ?>
	<form action="create.php" method="post">
	<input type="hidden" name="server_id" value="<?php 
    echo $server_id;
    ?>
" />
	<input type="hidden" name="new_dn" value="<?php 
    echo htmlspecialchars('dc=' . $dc_name . ',' . $container);
    ?>
" />

	<!-- ObjectClasses  -->
	<?php 
    $object_classes = rawurlencode(serialize(array('top', 'dnsdomain', 'domainRelatedObject')));
    ?>
        ?>
</b></td></tr>
	<tr><td class="val"><input type="text" name="new_attrs[<?php 
        echo htmlspecialchars($attr->getName());
        ?>
]" value="" size="40" /></tr>
	<?php 
    }
    ?>

	</table>
	<br />
	<br />
	<center><input type="submit" value="<?php 
    echo _('Add ObjectClass and Attributes');
    ?>
" /></center>
	</form>

	</body>
	</html>

<?php 
} else {
    $add_res = $ldapserver->attrModify($dn, array('objectClass' => $new_oclass));
    if (!$add_res) {
        pla_error("Could not perform ldap_mod_add operation.", $ldapserver->error(), $ldapserver->errno());
    } else {
        header(sprintf('Location: template_engine.php?server_id=%s&dn=%s&modified_attrs[]=objectClass', $ldapserver->server_id, $encoded_dn));
    }
}
Example #7
0
 *
 * Variables that come in via common.php
 *  - server_id
 * Variables that come in via GET variables
 *  - dn (rawurlencoded)
 *
 * @package phpLDAPadmin
 */
/**
 */
require './common.php';
if ($ldapserver->isReadOnly()) {
    pla_error(_('You cannot perform updates while server is in read-only mode'));
}
if (!$ldapserver->haveAuthInfo()) {
    pla_error(_('Not enough information to login to server. Please check your configuration.'));
}
$dn = $_GET['dn'];
$rdn = get_rdn($dn);
$attrs = $ldapserver->getDNAttrs($dn);
$select_server_html = server_select_list($ldapserver->server_id, true, 'dest_server_id');
$children = $ldapserver->getContainerContents($dn);
include './header.php';
# Draw some javaScrpt to enable/disable the filter field if this may be a recursive copy
if (is_array($children) && count($children) > 0) {
    ?>

	<script type="text/javascript" language="javascript">
	//<!--
	function toggle_disable_filter_field(recursive_checkbox)
	{
Example #8
0
                }
                echo '</td>';
                echo '<td width="50%">';
                if (count($oclass->getMayAttrs($schema_oclasses)) > 0) {
                    echo '<ul class="schema">';
                    foreach ($oclass->getMayAttrs($schema_oclasses) as $attr) {
                        echo '<li>';
                        printf('<a href="?server_id=%s&amp;view=attributes&amp;viewvalue=%s">%s</a>', $ldapserver->server_id, rawurlencode(strtolower($attr->getName())), htmlspecialchars($attr->getName()));
                        if ($attr->getSource() != $oclass->getName()) {
                            echo '<br />';
                            printf('<small>&nbsp;&nbsp; (%s <a href="?server_id=%s&amp;view=objectClasses&amp;viewvalue=%s">%s</a>)</small>', _('Inherited from'), $ldapserver->server_id, strtolower($attr->getSource()), $attr->getSource());
                        }
                        echo '</li>';
                    }
                    echo '</ul>';
                } else {
                    printf('<center>(%s)</center>', _('none'));
                }
                echo '</td>';
                echo '</tr>';
                echo '</table>';
            }
        }
        /* End foreach objectClass */
        break;
}
if (!is_null($viewvalue) && !$viewed) {
    pla_error(sprintf(_('No such schema item: "%s"'), htmlspecialchars($viewvalue)));
}
echo '</body>';
echo '</html>';
Example #9
0
function copy_dn($ldapserver_src, $ldapserver_dst, $dn_src, $dn_dst)
{
    if (DEBUG_ENABLED) {
        debug_log('copy_dn: Entered with (%s,%s,%s,%s)', 17, $ldapserver_src->server_id, $ldapserver_dst->server_id, $dn_src, $dn_dst);
    }
    $new_entry = $ldapserver_src->getDNAttrs($dn_src);
    # modify the prefix-value (ie "bob" in cn=bob) to match the destination DN's value.
    $rdn_attr = substr($dn_dst, 0, strpos($dn_dst, '='));
    $rdn_value = get_rdn($dn_dst);
    $rdn_value = substr($rdn_value, strpos($rdn_value, '=') + 1);
    $new_entry[$rdn_attr] = $rdn_value;
    # don't need a dn attribute in the new entry
    unset($new_entry['dn']);
    # Check the user-defined custom call back first
    if (run_hook('pre_entry_create', array('server_id' => $ldapserver_dst->server_id, 'dn' => $dn_dst, 'attrs' => $new_entry))) {
        $add_result = $ldapserver_dst->add($dn_dst, $new_entry);
        if (!$add_result) {
            run_hook('post_entry_create', array('server_id' => $ldapserver_dst->server_id, 'dn' => $dn_dst, 'attrs' => $new_entry));
            echo '</small><br /><br />';
            pla_error(_('Failed to copy DN: ') . $dn_dst, $ldapserver_dst->error(), $ldapserver_dst->errno());
        }
        return $add_result;
    } else {
        return false;
    }
}
Example #10
0
    pla_error(_('You cannot perform updates while server is in read-only mode'));
}
if (!$ldapserver->haveAuthInfo()) {
    pla_error(_('Not enough information to login to server. Please check your configuration.'));
}
$dn = $_POST['dn'];
if (is_null($dn)) {
    pla_error(_('You must specify a DN'));
}
if (!$ldapserver->dnExists($dn)) {
    pla_error(sprintf(_('No such entry: %s'), '<b>' . pretty_print_dn($dn) . '</b>'));
}
# Check the user-defined custom callback first.
if (run_hook('pre_entry_delete', array('server_id' => $ldapserver->server_id, 'dn' => $dn))) {
    $del_result = $ldapserver->delete($dn);
} else {
    pla_error(sprintf(_('Could not delete the entry: %s'), '<b>' . pretty_print_dn($dn) . '</b>'));
}
if ($del_result) {
    # Custom callback
    run_hook('post_entry_delete', array('server_id' => $ldapserver->server_id, 'dn' => $dn));
    include './header.php';
    echo '<body>';
    echo '<script type="text/javascript" language="javascript">parent.left_frame.location.reload();</script>';
    echo '<br /><br />';
    printf('<center>' . _('Entry %s deleted successfully.') . '</center>', '<b>' . pretty_print_dn($dn) . '</b>');
    echo '</body>';
} else {
    pla_error(sprintf(_('Could not delete the entry: %s'), '<b>' . pretty_print_dn($dn) . '</b>'), $ldapserver->error(), $ldapserver->errno());
}
echo '</html>';
require 'common.php';
$container = isset($_GET['container']) ? rawurldecode($_GET['container']) : false;
$server_id = isset($_GET['server_id']) ? $_GET['server_id'] : false;
$return_form_element = $_GET['form_element'];
include "header.php";
echo "<h3 class=\"subtitle\">Automagic Entry Chooser</h3>\n";
if ($container) {
    echo "Server: <b>" . htmlspecialchars($servers[$server_id]['name']) . "</b><br />\n";
    echo "Looking in: <b>" . htmlspecialchars($container) . "</b><br />\n";
}
/* Has the use already begun to descend into a specific server tree? */
if ($server_id !== false && $container !== false) {
    check_server_id($server_id) or pla_error("Bad server_id: " . htmlspecialchars($server_id));
    have_auth_info($server_id) or pla_error("Not enough information to login to server. " . "Please check your configuration.");
    pla_ldap_connect($server_id) or pla_error("Coult not connect to LDAP server.");
    $dn_list = get_container_contents($server_id, $container);
    $base_dn = $servers[$server_id]['base'];
    if (!$base_dn) {
        $base_dn = try_to_get_root_dn($server_id);
    }
    if ($container == $base_dn) {
        $parent_container = false;
        $up_href = "entry_chooser.php?form_element={$return_form_element}";
    } else {
        $parent_container = get_container($container);
        $up_href = "entry_chooser.php?form_element={$return_form_element}&amp;server_id={$server_id}&amp;container=" . rawurlencode($parent_container);
    }
    echo "&nbsp;<a href=\"{$up_href}\" style=\"text-decoration:none\">" . "<img src=\"images/up.png\"> Back Up...</a><br />\n";
    if (count($dn_list) == 0) {
        echo "&nbsp;&nbsp;&nbsp;(no entries)<br />\n";
Example #12
0
/**
 * Return the default format for search results.
 *
 * @return string The format to use.
 */
function get_default_search_display()
{
    if (DEBUG_ENABLED) {
        debug_log('get_default_search_display(): Entered with ()', 1);
    }
    global $default_search_display;
    if (!isset($default_search_display) || is_null($default_search_display)) {
        return 'list';
    } elseif (0 == strcasecmp($default_search_display, 'list')) {
        return 'list';
    } elseif (0 == strcasecmp($default_search_display, 'table')) {
        return 'table';
    } else {
        pla_error(sprintf(_('Your config.php specifies an invalid value for $default_search_display: %s. Please fix it'), htmlspecialchars($default_search_display)));
    }
}
$dn = rawurldecode($_POST['dn']);
$encoded_dn = rawurlencode($dn);
$update_array = $_POST['update_array'];
check_server_id($server_id) or pla_error("Bad server_id: " . htmlspecialchars($server_id));
have_auth_info($server_id) or pla_error("Not enough information to login to server. Please check your configuration.");
is_array($update_array) or pla_error("update_array is malformed. This might be a phpLDAPadmin bug. Please report it.");
// check for delete attributes (indicated by the attribute entry appearing like this: attr => ''
foreach ($update_array as $attr => $val) {
    if (!is_array($val)) {
        if ($val == '') {
            $update_array[$attr] = array();
        } else {
            $update_array[$attr] = $val;
        }
    } else {
        foreach ($val as $i => $v) {
            $update_array[$attr][$i] = $v;
        }
    }
}
$ds = pla_ldap_connect($server_id);
$res = @ldap_modify($ds, $dn, $update_array);
if ($res) {
    $redirect_url = "edit.php?server_id={$server_id}&dn={$encoded_dn}";
    foreach ($update_array as $attr => $junk) {
        $redirect_url .= "&modified_attrs[]={$attr}";
    }
    header("Location: {$redirect_url}");
} else {
    pla_error("Could not perform ldap_modify operation.", ldap_error($ds), ldap_errno($ds));
}
 function SetValue($server_id, $key, $index, $value)
 {
     if (defined('DEBUG_ENABLED') && DEBUG_ENABLED) {
         debug_log('%s::SetValue(): Entered with (%s,%s,%s,%s)', 3, get_class($this), $server_id, $key, $index, $value);
     }
     if (!isset($this->default->{$key})) {
         pla_error("ERROR: Setting a key [{$key}] that isnt predefined.");
     } else {
         $default = $this->default->{$key};
     }
     if (!isset($default[$index])) {
         pla_error("ERROR: Setting a index [{$index}] that isnt predefined.");
     } else {
         $default = $default[$index];
     }
     # Test if its should be an array or not.
     if (is_array($default['default']) && !is_array($value)) {
         pla_error("Error in configuration file, {$key}['{$index}'] SHOULD be an array of values.");
     }
     if (!is_array($default['default']) && is_array($value)) {
         pla_error("Error in configuration file, {$key}['{$index}'] should NOT be an array of values.");
     }
     # Some special processing.
     if ($key == 'server') {
         switch ($index) {
             case 'host':
                 if (strstr($value, "ldapi://")) {
                     $this->_ldapservers[$server_id][$key]['port'] = false;
                 }
                 break;
         }
     }
     $this->_ldapservers[$server_id][$key][$index] = $value;
 }
Example #15
0
$decoded_dn = rawurldecode($dn);
$encoded_dn = rawurlencode($decoded_dn);
$modified_attrs = isset($_GET['modified_attrs']) ? $_GET['modified_attrs'] : false;
$server_id = $_GET['server_id'];
$show_internal_attrs = isset($_GET['show_internal_attrs']) ? true : false;
$rdn = pla_explode_dn($dn);
$rdn = $rdn[0];
check_server_id($server_id) or pla_error("Bad server_id: " . htmlspecialchars($server_id));
have_auth_info($server_id) or pla_error("Not enough information to login to server. Please check your configuration.");
pla_ldap_connect($server_id) or pla_error("Coult not connect to LDAP server.");
$friendly_attrs = process_friendly_attr_table();
$attrs = get_object_attrs($server_id, $dn);
pla_ldap_connect($server_id) or pla_error("Could not connect to LDAP server");
$system_attrs = get_entry_system_attrs($server_id, $dn);
if (!$attrs) {
    pla_error("No such dn, " . htmlspecialchars(utf8_decode($dn)));
}
$server_name = $servers[$server_id]['name'];
// build a list of attributes available for this object based on its objectClasses
$oclasses = get_object_attr($server_id, $dn, 'objectClass');
if (!is_array($oclasses)) {
    $oclasses = array($oclasses);
}
$avail_attrs = array();
$schema_oclasses = get_schema_objectclasses($server_id, true);
$schema_attrs = get_schema_attributes($server_id);
foreach ($oclasses as $oclass) {
    $avail_attrs = array_merge($schema_oclasses[strtolower($oclass)]['must_attrs'], $schema_oclasses[strtolower($oclass)]['may_attrs'], $avail_attrs);
}
$avail_attrs = array_unique($avail_attrs);
$avail_attrs = array_filter($avail_attrs, "not_an_attr");
<?php 
} elseif ($step == 2) {
    $common_name = trim($_POST['common_name']);
    $first_name = trim($_POST['first_name']);
    $last_name = trim($_POST['last_name']);
    $organization = trim($_POST['organization']);
    $city = trim($_POST['city']);
    $postal_code = trim($_POST['postal_code']);
    $street = trim($_POST['street']);
    $telephone_number = trim($_POST['telephone_number']);
    $fax_number = trim($_POST['fax_number']);
    $mobile_number = trim($_POST['mobile_number']);
    $email_address = trim($_POST['email_address']);
    $container = trim($_POST['container']);
    /* Critical assertions */
    0 != strlen($common_name) or pla_error("You cannot leave the Common Name blank. Please go back and try again.");
    ?>
	<center><h3>Confirm entry creation:</h3></center>

	<form action="create.php" method="post">
	<input type="hidden" name="server_id" value="<?php 
    echo $server_id;
    ?>
" />
	<input type="hidden" name="new_dn" value="<?php 
    echo htmlspecialchars('cn=' . $common_name . ',' . $container);
    ?>
" />

	<!-- ObjectClasses  -->
	<?php 
                    break;
                case 'ends with':
                    // to fix bug 789113
                    if ($filter == "*") {
                        $filter = "";
                    }
                    $filter = "({$attr}=*{$filter})";
                    break;
                case 'equals':
                    $filter = "({$attr}={$filter})";
                    break;
                case 'sounds like':
                    $filter = "({$attr}~={$filter})";
                    break;
                default:
                    pla_error("Unrecognized criteria option: " . htmlspecialchars($criterion) . "If you want to add your own criteria to the list. Be sure to edit " . "search.php to handle them. Quitting.");
            }
        }
        $time_start = utime();
        $results = pla_ldap_search($server_id, $filter, $base_dn, $search_result_attributes, $scope);
        $time_end = utime();
        $time_elapsed = round($time_end - $time_start, 2);
        $count = count($results);
        ?>

		<br />
		<center>Found <b><?php 
        echo $count;
        ?>
</b> <?php 
        echo $count == 1 ? 'entry' : 'entries';
Example #18
0
$encoded_dn_dst = rawurlencode($dn_dst);
$server_id_src = isset($_POST['server_id_src']) ? $_POST['server_id_src'] : '';
$server_id_dst = isset($_POST['server_id_dst']) ? $_POST['server_id_dst'] : '';
$ldapserver_src = $ldapservers->Instance($server_id_src);
if (!$ldapserver_src->haveAuthInfo()) {
    pla_error(_('Not enough information to login to server. Please check your configuration.'));
}
$ldapserver_dst = $ldapservers->Instance($server_id_dst);
if (!$ldapserver_src->haveAuthInfo()) {
    pla_error(_('Not enough information to login to server. Please check your configuration.'));
}
if (!$ldapserver_src->dnExists($dn_src)) {
    pla_error(sprintf(_('No such entry: %s'), pretty_print_dn($dn_src)));
}
if (!$ldapserver_dst->dnExists($dn_dst)) {
    pla_error(sprintf(_('No such entry: %s'), pretty_print_dn($dn_dst)));
}
$friendly_attrs = process_friendly_attr_table();
$attrs_src = $ldapserver_src->getDNAttrs($dn_src, false, $config->GetValue('deref', 'view'));
$attrs_dst = $ldapserver_dst->getDNAttrs($dn_dst, false, $config->GetValue('deref', 'view'));
# Get a list of all attributes.
$attrs_all = array_keys($attrs_src);
foreach ($attrs_dst as $key => $val) {
    if (!in_array($key, $attrs_all)) {
        $attrs_all[] = $key;
    }
}
include './header.php';
?>

<body>
<?php

/*
 * login_form.php
 * Displays the login form for a server for users who specify
 * 'form' for their auth_type.
 *
 * Variables that come in as GET vars:
 *  - server_id
 */
require 'common.php';
$server_id = $_GET['server_id'];
$server = $servers[$server_id];
check_server_id($server_id) or pla_error("Bad server_id: " . htmlspecialchars($server_id));
?>

<?php 
include 'header.php';
?>
<body>

<script language="javascript">
<!--
	function toggle_disable_login_fields( anon_checkbox )
	{
		if( anon_checkbox.checked) {
			anon_checkbox.form.login_dn.disabled = true;
			anon_checkbox.form.login_pass.disabled = true;
		} else {
			anon_checkbox.form.login_dn.disabled = false;
			anon_checkbox.form.login_pass.disabled = false;
 * Variables that come in as GET vars:
 *  - dn (rawurlencoded)
 *  - server_id
 */
require 'common.php';
$dn = $_GET['dn'];
$encoded_dn = rawurlencode($dn);
$server_id = $_GET['server_id'];
$rdn = pla_explode_dn($dn);
$rdn = $rdn[0];
$server_name = $servers[$server_id]['name'];
if (is_server_read_only($server_id)) {
    pla_error("You cannot perform updates while server is in read-only mode");
}
check_server_id($server_id) or pla_error("Bad server_id: " . htmlspecialchars($server_id));
have_auth_info($server_id) or pla_error("Not enough information to login to server. Please check your configuration.");
$children = get_container_contents($server_id, $dn);
$has_children = count($children) > 0 ? true : false;
?>

<?php 
include 'header.php';
?>
<body>

<h3 class="title">Delete <b><?php 
echo htmlspecialchars(utf8_decode($rdn));
?>
</b></h3>
<h3 class="subtitle">Server: <b><?php 
echo $server_name;
    // refresh the tree viewer frame (left_frame)
    session_start();
    if (session_is_registered('tree')) {
        $tree = $_SESSION['tree'];
        // does it have children? (it shouldn't, but hey, you never know)
        if (isset($tree[$server_id][$dn])) {
            unset($tree[$server_id][$dn]);
        }
        // search and destroy
        foreach ($tree[$server_id] as $tree_dn => $subtree) {
            foreach ($subtree as $key => $sub_tree_dn) {
                if (0 == strcasecmp($sub_tree_dn, $dn)) {
                    unset($tree[$server_id][$tree_dn][$key]);
                }
            }
        }
    }
    $_SESSION['tree'] = $tree;
    session_write_close();
    ?>

	<script language="javascript">
		parent.left_frame.location.reload();
	</script>

	Object deleted successfully.

	<?php 
} else {
    pla_error("Could not delete the object: " . htmlspecialchars(utf8_decode($dn)), ldap_error($ds), ldap_errno($ds));
}
 * we present a confirmation table to the user outlining the changes they
 * are about to make. That form submits directly to update.php, which 
 * makes the change.
 *
 */
require 'common.php';
include 'header.php';
$server_id = $_POST['server_id'];
$encoded_dn = $_POST['dn'];
$dn = rawurldecode($encoded_dn);
$rdn = get_rdn($dn);
$old_values = $_POST['old_values'];
$new_values = $_POST['new_values'];
$update_array = array();
if (is_server_read_only($server_id)) {
    pla_error("You cannot perform updates while server is in read-only mode");
}
?>

<body>

<h3 class="title"><?php 
echo htmlspecialchars(utf8_decode($rdn));
?>
</h3>
<h3 class="subtitle">Server: <b><?php 
echo $server_name;
?>
</b> &nbsp;&nbsp;&nbsp; Distinguished Name: <b><?php 
echo htmlspecialchars(utf8_decode($dn));
?>
 /**
  * Function to check and warn about any unusual defined variables.
  */
 function CheckCustom()
 {
     if (isset($this->custom)) {
         foreach ($this->custom as $masterkey => $masterdetails) {
             if (isset($this->default->{$masterkey})) {
                 if (!is_array($masterdetails)) {
                     pla_error("Error in configuration file, [{$masterdetails}] should be an ARRAY.");
                 }
                 foreach ($masterdetails as $key => $value) {
                     # Test that the key is correct.
                     if (!in_array($key, array_keys($this->default->{$masterkey}))) {
                         pla_error("Error in configuration file, [{$key}] has not been defined as a PLA configurable variable.");
                     }
                     # Test if its should be an array or not.
                     if (is_array($this->default->{$masterkey}[$key]['default']) && !is_array($value)) {
                         pla_error("Error in configuration file, {$masterkey}['{$key}'] SHOULD be an array of values.");
                     }
                     if (!is_array($this->default->{$masterkey}[$key]['default']) && is_array($value)) {
                         pla_error("Error in configuration file, {$masterkey}['{$key}'] should NOT be an array of values.");
                     }
                 }
             } else {
                 pla_error("Error in configuration file, [{$masterkey}] has not been defined as a PLA MASTER configurable variable.");
             }
         }
     }
 }
Example #24
0
                    $query_string .= '&page=' . ($page + 1);
                    $pager_html .= "<a title=\"" . sprintf(_('Page %d'), $page + 2) . "\" href=\"search.php?{$query_string}\">&rsaquo;&rsaquo;</a>";
                } else {
                    $pager_html .= "&rsaquo;&rsaquo;";
                }
            }
            if (0 == $count) {
                printf('<center><h2>%s</h2></center>', _('The search found no results.'));
            } else {
                if (trim($pager_html)) {
                    printf('<center>%s</center>', $pager_html);
                }
                echo '<br />';
                flush();
                if ($format == 'list') {
                    require LIBDIR . 'search_results_list.php';
                } elseif ($format == 'table') {
                    require LIBDIR . 'search_results_table.php';
                } else {
                    pla_error(sprintf(_('Unrecognized search result format: %s'), htmlspecialchars($format)));
                }
                echo '<br />';
                if (trim($pager_html)) {
                    printf('<center>%s</center>', $pager_html);
                }
            }
        }
        printf('<br /><br /><div class="search_result"><center><small><span style="font-weight:normal;font-size:75%%;">%s <b>%s</b> %s.</span></small></center></div>', _('Search performed by phpLDAPadmin in'), $time_elapsed, _('seconds'));
    }
}
echo '</body></html>';
 /**
  * Create a PlaLdapExporter object.
  * @param int $server_id the server id
  * @param String $queryFilter the queryFilter for the export
  * @param String $base_dn the base_dn for the data to export
  * @param String $scope the scope for export
  */
 function PlaLdapExporter($server_id, $queryFilter, $base_dn, $scope, $attributes)
 {
     global $config;
     $this->scope = $scope;
     $this->base_dn = $base_dn;
     $this->server_id = $server_id;
     $this->queryFilter = $queryFilter;
     $this->attributes = $attributes;
     # infos for the server
     $this->ldap_info = new LdapExportInfo($server_id, $base_dn, $queryFilter, $scope);
     # get the data to be exported
     $this->results = $this->ldap_info->ldapserver->search(null, $this->base_dn, $this->queryFilter, $this->attributes, $this->scope, true, $config->GetValue('deref', 'export'));
     # if no result, there is a something wrong
     if (!$this->results && $this->ldap_info->ldapserver->errno()) {
         pla_error(_('Encountered an error while performing search.'), $this->ldap_info->ldapserver->error(), $this->ldap_info->ldapserver->errno());
     }
     usort($this->results, 'pla_compare_dns');
     $this->num_entries = count($this->results);
 }
<?php

// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/view_jpeg_photo.php,v 1.9.4.2 2005/12/08 11:58:14 wurley Exp $
/**
 * @package phpLDAPadmin
 */
/**
 */
require './common.php';
$file = $_GET['file'];
/* Security check (we don't want anyone tryting to get at /etc/passwd or something)
   Slashes and dots are not permitted in these names.*/
if (!preg_match('/^pla/', $file) || preg_match('/[\\.\\/\\\\]/', $file)) {
    pla_error(sprintf('%s %s', _('Unsafe file name: '), htmlspecialchars($file)));
}
/* Little security measure here (prevents users from accessing
   files, like /etc/passwd for example).*/
$file = basename(addcslashes($file, '/\\'));
$file = sprintf('%s/%s', $config->GetValue('jpeg', 'tmpdir'), $file);
if (!file_exists($file)) {
    pla_error(sprintf('%s %s', _('No such file: '), htmlspecialchars($_GET['file'])));
}
$f = fopen($file, 'r');
$jpeg = fread($f, filesize($file));
fclose($f);
Header('Content-type: image/jpeg');
Header('Content-disposition: inline; filename=jpeg_photo.jpg');
echo $jpeg;
Example #27
0
/**
 */
require './common.php';
if (!$ldapserver->haveAuthInfo()) {
    pla_error(_('No one is logged in to that server.'));
}
if (in_array($ldapserver->auth_type, array('cookie', 'session'))) {
    syslog_notice(sprintf('Logout for %s', $ldapserver->getLoggedInDN()));
    $ldapserver->unsetLoginDN() or pla_error(_('Could not logout.'));
    unset_lastactivity($ldapserver);
    if (isset($_SESSION['cache'][$ldapserver->server_id]['tree'])) {
        unset($_SESSION['cache'][$ldapserver->server_id]['tree']);
    }
    pla_session_close();
} else {
    pla_error(sprintf(_('Unknown auth_type: %s'), htmlspecialchars($ldapserver->auth_type)));
}
include './header.php';
?>

<body>
<script type="text/javascript" language="javascript">
	parent.left_frame.location.reload();
</script>

	<center>
	<br />
	<br />
	<?php 
echo sprintf(_('Logged out successfully from server <b>%s</b>'), htmlspecialchars($ldapserver->name));
?>
Example #28
0
$confirmed = isset($_POST['confirmed']) ? true : false;
isset($_POST['mass_delete']) or pla_error(_('Error calling mass_delete.php. Missing mass_delete in POST vars.'));
$mass_delete = $_POST['mass_delete'];
is_array($mass_delete) or pla_error(_('mass_delete POST var is not an array.'));
$ldapserver->isMassDeleteEnabled() or pla_error(_('Mass deletion is not enabled. Please enable it in config.php before proceeding.'));
require './header.php';
echo '<body>';
printf('<h3 class="title">%s</h3>', _('Mass Deleting'));
if ($confirmed == true) {
    printf('<h3 class="subtitle">' . _('Deletion progress on server "%s"') . '</h3>', $ldapserver->name);
    echo '<blockquote>';
    echo '<small>';
    $successfully_delete_dns = array();
    $failed_dns = array();
    if (!is_array($mass_delete)) {
        pla_error(_('Malformed mass_delete array.'));
    }
    if (count($mass_delete) == 0) {
        echo '<br />';
        printf('<center>%s</center>', _('You did not select any entries to delete.'));
        die;
    }
    // @todo: Should sort these entries, so that they are deleted in order, if a user selects children.
    foreach ($mass_delete as $dn => $junk) {
        printf(_('Deleting %s'), htmlspecialchars($dn));
        flush();
        if (run_hook('pre_entry_delete', array('server_id' => $ldapserver->server_id, 'dn' => $dn))) {
            $success = $ldapserver->delete($dn);
            if ($success) {
                run_hook('post_entry_delete', array('server_id' => $ldapserver->server_id, 'dn' => $dn));
                printf(' <span style="color:green">%s</span>.<br />', _('Success'));
<?php

/* 
 * server_info.php
 * Fetches and displays all information that it can from the specified server
 * 
 * Variables that come in as GET vars:
 *  - server_id
 */
require 'common.php';
$server_id = $_GET['server_id'];
$server_name = $servers[$server_id]['name'];
$ds = pla_ldap_connect($server_id) or pla_error("Could not connect or authenticate to LDAP server");
$r = @ldap_read($ds, '', 'objectClass=*', array('+'));
if (!$r) {
    pla_error("Could not fetch any information from the server");
}
$entry = @ldap_first_entry($ds, $r);
$attrs = @ldap_get_attributes($ds, $entry);
$count = @ldap_count_entries($ds, $r);
//echo "<pre>"; print_r( $attrs ); echo "</pre>";
include 'header.php';
?>

<h3 class="title">Server info for <?php 
echo htmlspecialchars($server_name);
?>
</h3>
<h3 class="subtitle">Server reports the following information about itself</h3>

<?php 
Example #30
0
        $enc_type = $ldapserver->default_hash;
        $val = password_hash($val, $enc_type);
    }
} elseif (strcasecmp($attr, 'sambaNTPassword') == 0) {
    $sambapassword = new smbHash();
    $val = $sambapassword->nthash($val);
} elseif (strcasecmp($attr, 'sambaLMPassword') == 0) {
    $sambapassword = new smbHash();
    $val = $sambapassword->lmhash($val);
}
$new_entry = array($attr => $val);
$result = $ldapserver->attrModify($dn, $new_entry);
if ($result) {
    header(sprintf('Location: template_engine.php?server_id=%s&dn=%s&modified_attrs[]=%s', $ldapserver->server_id, $encoded_dn, $encoded_attr));
} else {
    pla_error(_('Failed to add the attribute.'), $ldapserver->error(), $ldapserver->errno());
}
/**
 * Check if we need to append the ;binary option to the name
 * of some binary attribute
 *
 * @param object $ldapserver Server Object that the attribute is in.
 * @param attr $attr Attribute to test to see if it requires ;binary added to it.
 * @return bool
 */
function is_binary_option_required($ldapserver, $attr)
{
    // list of the binary attributes which need the ";binary" option
    $binary_attributes_with_options = array('1.3.6.1.4.1.1466.115.121.1.8' => "userCertificate", '1.3.6.1.4.1.1466.115.121.1.8' => "caCertificate", '1.3.6.1.4.1.1466.115.121.1.10' => "crossCertificatePair", '1.3.6.1.4.1.1466.115.121.1.9' => "certificateRevocationList", '1.3.6.1.4.1.1466.115.121.1.9' => "authorityRevocationList", '2.16.840.1.113730.3.1.40' => "userSMIMECertificate");
    // quick check by attr name (short circuits the schema check if possible)
    //foreach( $binary_attributes_with_options as $oid => $name )