コード例 #1
0
/** If an entry has more children than this, stop searching and display this amount with a '+' */
$max_children = 100;
require 'common.php';
$dn = $_GET['dn'];
$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) {
コード例 #2
0
 *  - new_oclass
 */
require 'common.php';
$dn = rawurldecode($_POST['dn']);
$encoded_dn = rawurlencode($dn);
$new_oclass = $_POST['new_oclass'];
$server_id = $_POST['server_id'];
if (is_server_read_only($server_id)) {
    pla_error($lang['no_updates_in_read_only_mode']);
}
check_server_id($server_id) or pla_error($lang['bad_server_id']);
have_auth_info($server_id) or pla_error($lang['not_enough_login_info']);
/* Ensure that the object has defined all MUST attrs for this objectClass.
 * If it hasn't, present a form to have the user enter values for all the
 * newly required attrs. */
$entry = get_object_attrs($server_id, $dn, true);
$current_attrs = array();
foreach ($entry as $attr => $junk) {
    $current_attrs[] = strtolower($attr);
}
// grab the required attributes for the new objectClass
$must_attrs = get_schema_objectclasses($server_id);
$must_attrs = $must_attrs[strtolower($new_oclass)]['must_attrs'];
sort($must_attrs);
// build a list of the attributes that this new objectClass requires,
// but that the object does not currently contain
$needed_attrs = array();
foreach ($must_attrs as $attr) {
    if (!in_array(strtolower($attr), $current_attrs)) {
        $needed_attrs[] = $attr;
    }
コード例 #3
0
function copy_dn($source_server_id, $source_dn, $dest_server_id, $dest_dn)
{
    global $ds;
    $ds = pla_ldap_connect($dest_server_id) or pla_error("Could not connect to LDAP server");
    $attrs = get_object_attrs($source_server_id, $source_dn);
    $new_entry = $attrs;
    // modify the prefix-value (ie "bob" in cn=bob) to match the destination DN's value.
    $rdn_attr = substr($dest_dn, 0, strpos($dest_dn, '='));
    $rdn_value = get_rdn($dest_dn);
    $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']);
    $add_result = @ldap_add($ds, $dest_dn, $new_entry);
    if (!$add_result) {
        echo "</small><br /><br />";
        pla_error("Failed to copy {$source_dn} (server: {$source_server_id}) to " . "{$dest_dn} (server: {$dest_server_id})", ldap_error($ds), ldap_errno($ds));
    }
    return $add_result;
}
コード例 #4
0
function get_object_attr($server_id, $dn, $attr)
{
    $attr = strtolower($attr);
    $attrs = get_object_attrs($server_id, $dn, true);
    if (isset($attrs[$attr])) {
        return $attrs[$attr];
    } else {
        return false;
    }
}