phpldapadmin/add_oclass.php

71 lines
2.0 KiB
PHP
Raw Normal View History

2009-06-30 08:05:37 +00:00
<?php
2009-06-30 09:22:30 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/add_oclass.php,v 1.11 2004/08/15 17:39:20 uugdave Exp $
2009-06-30 08:05:37 +00:00
/*
* add_oclass.php
* Adds an objectClass to the specified dn.
* Variables that come in as POST vars:
*
* Note, this does not do any schema violation checking. That is
* performed in add_oclass_form.php.
*
* Vars that come in as POST:
* - dn (rawurlencoded)
* - server_id
* - new_oclass
* - new_attrs (array, if any)
*/
2009-06-30 09:22:30 +00:00
require './common.php';
2009-06-30 08:05:37 +00:00
2009-06-30 08:07:14 +00:00
$dn = rawurldecode( $_POST['dn'] );
2009-06-30 08:05:37 +00:00
$encoded_dn = rawurlencode( $dn );
2009-06-30 08:07:14 +00:00
$new_oclass = $_POST['new_oclass'];
2009-06-30 08:05:37 +00:00
$server_id = $_POST['server_id'];
$new_attrs = $_POST['new_attrs'];
2009-06-30 09:22:30 +00:00
if( is_attr_read_only( $server_id, 'objectClass' ) )
pla_error( "ObjectClasses are flagged as read only in the phpLDAPadmin configuration." );
2009-06-30 08:07:14 +00:00
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'] );
2009-06-30 08:05:37 +00:00
$new_entry = array();
$new_entry['objectClass'] = $new_oclass;
$new_attrs_entry = array();
$new_oclass_entry = array( 'objectClass' => $new_oclass );
if( is_array( $new_attrs ) && count( $new_attrs ) > 0 )
2009-06-30 09:22:30 +00:00
foreach( $new_attrs as $attr => $val ) {
// Check to see if this is a unique Attribute
if( $badattr = checkUniqueAttr( $server_id, $dn, $attr, array($val) ) ) {
$search_href='search.php?search=true&form=advanced&server_id=' . $server_id . '&filter=' . $attr . '=' . $badattr;
pla_error(sprintf( $lang['unique_attr_failed'] , $attr,$badattr,$dn,$search_href ) );
}
2009-06-30 08:05:37 +00:00
$new_entry[ $attr ] = $val;
2009-06-30 09:22:30 +00:00
}
2009-06-30 08:05:37 +00:00
//echo "<pre>";
//print_r( $new_entry );
//exit;
2009-06-30 09:22:30 +00:00
$ds = pla_ldap_connect( $server_id );
pla_ldap_connection_is_error( $ds );
2009-06-30 08:05:37 +00:00
$add_res = @ldap_mod_add( $ds, $dn, $new_entry );
if( ! $add_res )
{
2009-06-30 08:07:14 +00:00
pla_error( $lang['could_not_perform_ldap_mod_add'], ldap_error( $ds ), ldap_errno( $ds ) );
2009-06-30 08:05:37 +00:00
}
else
{
2009-06-30 09:22:30 +00:00
header( "Location: edit.php?server_id=$server_id&dn=$encoded_dn&modified_attrs[]=objectclass" );
2009-06-30 08:05:37 +00:00
}
?>