diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index 3c0dfe2572e3606cb58443bae0bfc1d11335d1df..17ae13ff4071b267c4f606dbe63bf5e69bfc1197 100644 (file)
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
*/
function copy_FAI_resource_recursive($sourcedn,$destinationdn,$destinationName,$type="branch",$is_first = true,$depth=0)
{
*/
function copy_FAI_resource_recursive($sourcedn,$destinationdn,$destinationName,$type="branch",$is_first = true,$depth=0)
{
- error_reporting(E_ALL);
+ error_reporting(E_ALL | E_STRICT);
if($is_first){
echo "<h2>".sprintf(_("Creating copy of %s"),"<i>".@LDAP::fix($sourcedn)."</i>")."</h2>";
if($is_first){
echo "<h2>".sprintf(_("Creating copy of %s"),"<i>".@LDAP::fix($sourcedn)."</i>")."</h2>";
}
if($this->error != "Success"){
}
if($this->error != "Success"){
- /* Some error occured */
+ /* Some error occurred */
print "---------------------------------------------";
print $this->get_error()."<br>";
print $sourcedn."<br>";
print "---------------------------------------------";
print $this->get_error()."<br>";
print $sourcedn."<br>";
{
global $config;
{
global $config;
- /* Ignore create_missing trees if the base equals target */
+ $real_path= substr($target, 0, strlen($target) - strlen($this->basedn) -1 );
+
if ($target == $this->basedn){
if ($target == $this->basedn){
- return;
+ $l= array("dummy");
+ } else {
+ $l= array_reverse(gosa_ldap_explode_dn($real_path));
}
}
-
- $real_path= substr($target, 0, strlen($target) - strlen($this->basedn) -1 );
- $l= array_reverse(gosa_ldap_explode_dn($real_path));
unset($l['count']);
$cdn= $this->basedn;
$tag= "";
/* Load schema if available... */
unset($l['count']);
$cdn= $this->basedn;
$tag= "";
/* Load schema if available... */
- if(isset($config->data['MAIN']['SCHEMA_CHECK'])){
- $classes= $this->get_objectclasses();
- }
+ $classes= $this->get_objectclasses();
foreach ($l as $part){
foreach ($l as $part){
- $cdn= "$part,$cdn";
+ if ($part != "dummy"){
+ $cdn= "$part,$cdn";
+ }
/* Ignore referrals */
$found= false;
/* Ignore referrals */
$found= false;
$na= array();
/* Automatic or traditional? */
$na= array();
/* Automatic or traditional? */
- if(isset($config->data['MAIN']['SCHEMA_CHECK'])){
+ if(count($classes)){
/* Get name of first matching objectClass */
$ocname= "";
/* Get name of first matching objectClass */
$ocname= "";
}
$this->cd($cdn);
$this->add($na);
}
$this->cd($cdn);
$this->add($na);
+
show_ldap_error($this->get_error(), sprintf(_("Creating subtree '%s' failed."),$cdn));
show_ldap_error($this->get_error(), sprintf(_("Creating subtree '%s' failed."),$cdn));
+ if (!preg_match('/success/i', $this->error)){
+ return FALSE;
+ }
}
}
}
}
+
+ return TRUE;
}
}
+
function recursive_remove()
{
$delarray= array();
function recursive_remove()
{
$delarray= array();
$url= preg_replace('!\?\?.*$!', '', $url);
$server= preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', $url);
$url= preg_replace('!\?\?.*$!', '', $url);
$server= preg_replace('!^([^:]+://[^/]+)/.*$!', '\\1', $url);
- if ($referrals == NULL){
+ if ($referrals === NULL){
$referrals= $this->referrals;
}
$referrals= $this->referrals;
}
*/
function import_single_entry($str_attr,$modify,$delete)
{
*/
function import_single_entry($str_attr,$modify,$delete)
{
+ global $config;
+
+ if(!$config){
+ trigger_error("Can't import ldif, can't read config object.");
+ }
+
+
if($this->reconnect) $this->connect();
$ret = false;
if($this->reconnect) $this->connect();
$ret = false;
/* Create missing trees */
$this->cd ($this->basedn);
/* Create missing trees */
$this->cd ($this->basedn);
- $this->create_missing_trees($data['dn']);
+ $this->cd($config->current['BASE']);
+ $this->create_missing_trees(preg_replace("/^[^,]+,/","",$data['dn']));
$this->cd($data['dn']);
$dn = $data['dn'];
$this->cd($data['dn']);
$dn = $data['dn'];
function get_objectclasses()
{
$objectclasses = array();
function get_objectclasses()
{
$objectclasses = array();
-
+ global $config;
+
+ /* Only read schema if it is allowed */
+ if(isset($config) && preg_match("/config/i",get_class($config))){
+ if(!isset($config->data['MAIN']['SCHEMA_CHECK']) || !preg_match("/true/i",$config->data['MAIN']['SCHEMA_CHECK'])){
+ return($objectclasses);
+ }
+ }
+
# Get base to look for schema
$sr = @ldap_read ($this->cid, NULL, "objectClass=*", array("subschemaSubentry"));
if(!$sr){
# Get base to look for schema
$sr = @ldap_read ($this->cid, NULL, "objectClass=*", array("subschemaSubentry"));
if(!$sr){
}
}
}
}
-
return $objectclasses;
}
return $objectclasses;
}
}
}
}
}
+
function get_naming_contexts($server, $admin= "", $password= "")
{
/* Build LDAP connection */
function get_naming_contexts($server, $admin= "", $password= "")
{
/* Build LDAP connection */
$r= ldap_bind ($ds, $admin, $password);
/* Get base to look for naming contexts */
$r= ldap_bind ($ds, $admin, $password);
/* Get base to look for naming contexts */
- $sr = @ldap_read ($ds, "", "objectClass=*", array("namingContexts"));
+ $sr = @ldap_read ($ds, "", "objectClass=*", array("+"));
$attr= @ldap_get_entries($ds,$sr);
$attr= @ldap_get_entries($ds,$sr);
-
+
return ($attr[0]['namingcontexts']);
}
return ($attr[0]['namingcontexts']);
}
+ function get_root_dse($server, $admin= "", $password= "")
+ {
+ /* Build LDAP connection */
+ $ds= ldap_connect ($server);
+ if (!$ds) {
+ die ("Can't bind to LDAP. No check possible!");
+ }
+ ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
+ $r= ldap_bind ($ds, $admin, $password);
+
+ /* Get base to look for naming contexts */
+ $sr = @ldap_read ($ds, "", "objectClass=*", array("+"));
+ $attr= @ldap_get_entries($ds,$sr);
+
+ /* Return empty array, if nothing was set */
+ if (!isset($attr[0])){
+ return array();
+ }
+
+ /* Rework array... */
+ $result= array();
+ for ($i= 0; $i<$attr[0]['count']; $i++){
+ $result[$attr[0][$i]]= $attr[0][$attr[0][$i]];
+ unset($result[$attr[0][$i]]['count']);
+ }
+
+ return ($result);
+ }
+
+
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: