summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f452930)
raw | patch | inline | side by side (parent: f452930)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 30 Jan 2006 13:06:02 +0000 (13:06 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 30 Jan 2006 13:06:02 +0000 (13:06 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2598 594d385d-05f5-0310-b6e9-bd551577e9d8
13 files changed:
index f91dd2a549e7ecf31a22af9fd813e515f9bd6e0a..b2125dbe51c974904bfa8a2ebfe839a0da7daf13 100644 (file)
--- a/include/class_config.inc
+++ b/include/class_config.inc
unset($entries['SUB']);
}
+ /* Fix name, if it contains a replace tag */
+ $name= preg_replace('/###GOSAREPLACED###/', ',', $name);
+
/* Check if current name is too long, then cut it */
if(strlen($name)> $max_size){
$name = substr($name,0,($max_size-3))." ...";
diff --git a/include/class_ldap.inc b/include/class_ldap.inc
index 20ff04037656c808190024ed349790aedc04d7b2..8d4d06aef576e62556a9818eb963a9dfb0db83dc 100644 (file)
--- a/include/class_ldap.inc
+++ b/include/class_ldap.inc
define("ALREADY_EXISTING_ENTRY",-10001);
define("UNKNOWN_TOKEN_IN_LDIF_FILE",-10002);
define("NO_FILE_UPLOADED",10003);
-
-
define("INSERT_OK",10000);
-
-
+define("COLON_OVERRIDE", TRUE);
class LDAP{
{
$this->follow_referral= $follow_referral;
$this->tls=$tls;
- $this->binddn=$binddn;
+ $this->binddn=$this->convert($binddn);
+
$this->bindpw=$bindpw;
$this->hostname=$hostname;
$this->connect();
}
+
+ function convert($dn)
+ {
+ if (COLON_OVERRIDE == TRUE){
+ $res= preg_replace("/\\\\,/", '###GOSAREPLACED###', $dn);
+ $res= preg_replace("/\\\\2C/", '###GOSAREPLACED###', $res);
+ #if ($dn != $res){
+ # echo "Conversation from '$dn' to '$res'<br>";
+ #}
+ return ($res);
+ } else {
+ return ($dn);
+ }
+ }
+
+
+ function fix($dn)
+ {
+ if (COLON_OVERRIDE == TRUE){
+ $res= preg_replace("/###GOSAREPLACED###/", '\,', $dn);
+ #if ($dn != $res){
+ # echo "Fix from '$dn' to '$res'<br>";
+ #}
+ return ($res);
+ } else {
+ return ($dn);
+ }
+ }
+
+
function connect()
{
$this->hascon=false;
}
$this->error = "No Error";
- if ($bid = @ldap_bind($this->cid, $this->binddn, $this->bindpw)) {
+ if ($bid = @ldap_bind($this->cid, $this->fix($this->binddn), $this->bindpw)) {
$this->error = "Success";
$this->hascon=true;
} else {
function rebind($ldap, $referral)
{
$credentials= $this->get_credentials($referral);
- if (@ldap_bind($ldap, $credentials['ADMIN'], $credentials['PASSWORD'])) {
+ if (@ldap_bind($ldap, $this->fix($credentials['ADMIN']), $credentials['PASSWORD'])) {
$this->error = "Success";
$this->hascon=true;
$this->reconnect= true;
if ($dir == "..")
$this->basedn = $this->getParentDir();
else
- $this->basedn = $dir;
+ $this->basedn = $this->convert($dir);
}
function getParentDir($basedn = "")
{
if ($basedn=="")
$basedn = $this->basedn;
+ else
+ $basedn = $this-convert($this->basedn);
return(ereg_replace("[^,]*[,]*[ ]*(.*)", "\\1", $basedn));
}
if($this->hascon){
if ($this->reconnect) $this->connect();
$this->clearResult();
- $this->sr = @ldap_search($this->cid, $this->basedn, $filter, $attrs);
+ $this->sr = @ldap_search($this->cid, $this->fix($this->basedn), $filter, $attrs);
$this->error = @ldap_error($this->cid);
$this->resetResult();
$this->hasres=true;
$this->clearResult();
if ($basedn == "")
$basedn = $this->basedn;
- $this->sr = @ldap_list($this->cid, $basedn, $filter,$attrs);
+ else
+ $basedn= $this->convert($basedn);
+ $this->sr = @ldap_list($this->cid, $this->fix($basedn), $filter,$attrs);
$this->error = @ldap_error($this->cid);
$this->resetResult();
$this->hasres=true;
if ($this->reconnect) $this->connect();
$this->clearResult();
$filter = "(objectclass=*)";
- $this->sr = @ldap_read($this->cid, $dn, $filter);
+ $this->sr = @ldap_read($this->cid, $this->fix($dn), $filter);
$this->error = @ldap_error($this->cid);
$this->resetResult();
$this->hasres=true;
if ($this->re)
{
$att= @ldap_get_attributes($this->cid, $this->re);
- $att['dn']= @ldap_get_dn($this->cid, $this->re);
+ $att['dn']= $this->convert(@ldap_get_dn($this->cid, $this->re));
}
$this->error = @ldap_error($this->cid);
if (!isset($att)){
$rv = @ldap_get_dn($this->cid, $this->re);
$this->error = @ldap_error($this->cid);
- $rv= clean_dn($rv);
- return($rv);
+ return($this->convert($rv));
}
}else{
$this->error = "Perform a Fetch with no Search";
if ($dn == "")
$dn = $this->basedn;
- $r = @ldap_mod_del($this->cid, $dn, $attrs);
+ $r = @ldap_mod_del($this->cid, $this->fix($dn), $attrs);
$this->error = @ldap_error($this->cid);
return($r);
}else{
if ($dn == "")
$dn = $this->basedn;
- $r = @ldap_mod_replace($this->cid, $dn, $attrs);
+ $r = @ldap_mod_replace($this->cid, $this->fix($dn), $attrs);
$this->error = @ldap_error($this->cid);
return($r);
}else{
{
if($this->hascon){
if ($this->reconnect) $this->connect();
- $r = @ldap_delete($this->cid, $deletedn);
+ $r = @ldap_delete($this->cid, $this->fix($deletedn));
$this->error = @ldap_error($this->cid);
return($r ? $r : 0);
}else{
}
/* Finally Delete own Node */
- $r = @ldap_delete($this->cid, $deletedn);
+ $r = @ldap_delete($this->cid, $this->fix($deletedn));
$this->error = @ldap_error($this->cid);
return($r ? $r : 0);
}else{
/* check if this is a department */
if(in_array("organizationalUnit",$attr['objectClass'])){
- $attr['dn'] = $destinationdn;
+ $attr['dn'] = $this->convert($destinationdn);
$this->cd($basedn);
$this->create_missing_trees($destinationdn);
$this->cd($destinationdn);
{
if($this->hascon){
if ($this->reconnect) $this->connect();
- $r = @ldap_modify($this->cid, $this->basedn, $attrs);
+ $r = @ldap_modify($this->cid, $this->fix($this->basedn), $attrs);
$this->error = @ldap_error($this->cid);
return($r ? $r : 0);
}else{
{
if($this->hascon){
if ($this->reconnect) $this->connect();
- $r = @ldap_add($this->cid, $this->basedn, $attrs);
+ $r = @ldap_add($this->cid, $this->fix($this->basedn), $attrs);
$this->error = @ldap_error($this->cid);
return($r ? $r : 0);
}else{
{
$data= "";
if ($this->reconnect) $this->connect();
- $sr= @ldap_read($this->cid, $dn, "objectClass=*", array("$name"));
+ $sr= @ldap_read($this->cid, $this->fix($dn), "objectClass=*", array("$name"));
/* fill data from LDAP */
if ($sr) {
if (isset($referrals[$server])){
return ($referrals[$server]);
} else {
- $ret['ADMIN']= $this->binddn;
+ $ret['ADMIN']= $this->fix($this->binddn);
$ret['PASSWORD']= $this->bindpw;
}
@@ -725,7 +756,7 @@ function gen_xls ($dn, $filter= "(objectClass=*)", $attributes= array('*'), $rec
}
/* Searching Ldap Tree */
- $sr= @ldap_read($this->cid, $dn, $filter, $name);
+ $sr= @ldap_read($this->cid, $this->fix($dn), $filter, $name);
/* Get the first entry */
$entry= @ldap_first_entry($this->cid, $sr);
@@ -769,7 +800,7 @@ function gen_xls ($dn, $filter= "(objectClass=*)", $attributes= array('*'), $rec
function dn_exists($dn)
{
- return @ldap_list($this->cid, $dn, "(objectClass=*)", array("objectClass"));
+ return @ldap_list($this->cid, $this->fix($dn), "(objectClass=*)", array("objectClass"));
}
diff --git a/include/functions.inc b/include/functions.inc
index 339a3ef72d94cfcdcd6371783f59fd09aeac1fd9..57ded91d438c11c7c317763fa8eb4c68d15f5df6 100644 (file)
--- a/include/functions.inc
+++ b/include/functions.inc
@@ -509,7 +509,7 @@ function get_list2($subtreeACL, $filter, $subsearch= TRUE, $base="", $attrs= arr
/* Crawl through reslut entries and perform the migration to the
result array */
while($attrs = $ldap->fetch()) {
- $dn= clean_dn($ldap->getDN());
+ $dn= $ldap->getDN();
foreach ($subtreeACL as $key => $value){
if (preg_match("/$key/", $dn)){
$attrs["dn"]= convert_department_dn($dn);
@@ -554,7 +554,7 @@ function get_list($subtreeACL, $filter, $subsearch= TRUE, $base="", $attrs= arra
result array */
$result= array();
while($attrs = $ldap->fetch()) {
- $dn= clean_dn($ldap->getDN());
+ $dn= $ldap->getDN();
foreach ($subtreeACL as $key => $value){
if (preg_match("/$key/", $dn)){
$attrs["dn"]= $dn;
/* Build a sub-directory style list of the tree level
specified in $dn */
- foreach (dn_split ($dn) as $val){
+ foreach (split (',', $dn) as $val){
/* We're only interested in organizational units... */
if (preg_match ("/ou=/", $val)){
}
}
+ /* Fix name, if it contains a replace tag */
+ $dep= preg_replace('/###GOSAREPLACED###/', ',', $dep);
+
/* Return and remove accidently trailing slashes */
return rtrim($dep, "/");
}
if(isset($deps[$dn])){
$dn= $deps[$dn];
- $tmp = dn_split ($dn);
- $dep = preg_replace("/^.*=/","",$tmp[0]);
+ $dep = preg_replace("/^.*=/","",$dn);
}else{
- $tmp = dn_split ($dn);
- $dep= preg_replace("%^.*/([^/]+)$%", "\\1", $tmp[0]);
+ $dep= preg_replace("%^.*/([^/]+)$%", "\\1", $dn);
}
/* Return and remove accidently trailing slashes */
return ("");
}
-
-function dn_split($dn)
-{
- $ret= array();
- $tmp_dn= preg_replace('/\\\\,/', '##', $dn);
- if (!preg_match('/,/', $tmp_dn)){
- $ret[]= $dn;
- return $ret;
- }
-
- while (1){
-
- # Get next position of comma, exit if there
- # are none left
- $pos= strpos($tmp_dn, ',');
- if ($pos === false){
- break;
- }
-
- # Assign element
- $ret[]= substr($dn, 0, $pos);
- $tmp_dn= substr($tmp_dn, $pos + 1);
- $dn= substr($dn, $pos + 1);
- }
-
- return ($ret);
-}
-
-
-function clean_dn($dn)
-{
- $tmp_dn= preg_replace('/\\\\,/', '<GOSA#REPLACED#KOMMA>', $dn);
- $tmp_dn= preg_replace('/[ ]*,[ ]*/', ",", $tmp_dn);
- $tmp_dn= preg_replace('/\<GOSA#REPLACED#KOMMA\>/', '\\,', $tmp_dn);
- return ($tmp_dn);
-}
-
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
index b9cb808c190d3f1a028874dd5c0eb4f6e6275d00..b444b72454528ae06bd9e4809c748373191f406c 100644 (file)
default:
if ($this->_compile_compiler_tag($tag_command, $tag_args, $output)) {
return $output;
- } else if ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) {
+ } else if (@$this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) {
return $output;
- } else if ($this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) {
+ } else if (@$this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) {
return $output;
} else {
$this->_syntax_error("unrecognized tag '$tag_command'", E_USER_ERROR, __FILE__, __LINE__);
diff --git a/plugins/admin/applications/class_applicationManagement.inc b/plugins/admin/applications/class_applicationManagement.inc
index d67167befdc16ea8e49fcc1fc6aaddc96e0e5026..261b19617f614da68115c5b7f14f0cf29721c093 100644 (file)
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
$smarty= get_smarty();
- $smarty->assign("intro", sprintf(_("You're about to delete the application '%s'."), $this->dn));
+ $smarty->assign("intro", sprintf(_("You're about to delete the application '%s'."), LDAP::fix($this->dn)));
return($smarty->fetch (get_template_path('remove.tpl', TRUE)));
} else {
diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc
index afa6e2744fa614fa12cdeccee17141b40c69b41e..5dbb830c8b0424ba3145a5ecf900b36e959a9174 100644 (file)
$message[]= _("The field 'Name' contains the reserved word 'incoming'.".
" Please choose another name.");
}
- if (preg_match ('/[,#+:=>\\\\\/]/', $this->ou)){
+ if (preg_match ('/[#+:=>\\\\\/]/', $this->ou)){
$message[]= _("The field 'Name' contains invalid characters.");
}
if (!is_phone_nr($this->telephoneNumber)){
diff --git a/plugins/admin/departments/class_departmentManagement.inc b/plugins/admin/departments/class_departmentManagement.inc
index 6e2fe7950c1b3124fbbaf307894c2daf7797d2de..39c5eb93c860eeb24bc7028727470367a3d1484d 100644 (file)
return(gen_locked_message($user, $this->dn));
} else {
add_lock ($this->dn, $this->ui->dn);
- $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), $this->dn));
+ $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), LDAP::fix($this->dn)));
$display.= $smarty->fetch (get_template_path('remove.tpl', TRUE));
return ($display);
}
diff --git a/plugins/admin/departments/tabs_department.inc b/plugins/admin/departments/tabs_department.inc
index 25cb791ebcb05dc544eeb42e6bd21315a573fa98..1bcb786411c13aace1def936ae14a9119b0b653d 100644 (file)
function save()
{
$baseobject= $this->by_object['department'];
- $new_dn= 'ou='.$baseobject->ou.','.$baseobject->base;
+ $new_dn= 'ou='.preg_replace('/,/', '\\\\2C', $baseobject->ou).','.$baseobject->base;
+ echo $new_dn."<br>";
+ echo $baseobject->ou;
if ($this->dn != $new_dn && $this->dn != "new"){
index d540e03c27b30e0fb2ecc4f49ba777c589bf8470..a55ebc356efe257c0b1a6a9f58a2b4fdda9ab6d2 100644 (file)
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
- $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), $this->dn));
+ $smarty->assign("warning", sprintf(_("You're about to delete all information about the FAI class at '%s'."), LDAP::fix($this->dn)));
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
} else {
diff --git a/plugins/admin/groups/class_groupManagement.inc b/plugins/admin/groups/class_groupManagement.inc
index 003cb10acda1df598414151f615a10dee715b9c8..5ce272b32f181f4eca2f30a1241109dff2fe294d 100644 (file)
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
- $smarty->assign("info", sprintf(_("You're about to delete the group '%s'."), $this->dn));
+ $smarty->assign("info", sprintf(_("You're about to delete the group '%s'."), LDAP::fix($this->dn)));
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
} else {
diff --git a/plugins/admin/ogroups/class_ogroupManagement.inc b/plugins/admin/ogroups/class_ogroupManagement.inc
index f13a3108f5a40d949059027d62f0caf7cc26ea60..d848dd856069dc554ec9a0cf7dba60fe7588f8e4 100644 (file)
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
- $smarty->assign("info", sprintf(_("You're about to delete the object group '%s'."), $this->dn));
+ $smarty->assign("info", sprintf(_("You're about to delete the object group '%s'."), LDAP::fix($this->dn)));
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
} else {
diff --git a/plugins/admin/systems/class_systemManagement.inc b/plugins/admin/systems/class_systemManagement.inc
index 782a3ed7e05f16ceb58dac03844b3000093173aa..dd5a89608449e52a3d650058de7d515987908b3f 100644 (file)
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
- $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), $this->dn));
+ $smarty->assign("warning", sprintf(_("You're about to delete all information about the component at '%s'."), LDAP::fix($this->dn)));
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
} else {
diff --git a/plugins/admin/users/class_userManagement.inc b/plugins/admin/users/class_userManagement.inc
index 857488dc67dedb344d27199fddfd73ff8ec2f482..88936bd503a44fca137274790f3a877074bdd5c7 100644 (file)
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
- $smarty->assign("info", sprintf(_("You're about to delete the user %s."), $this->dn));
+ $smarty->assign("info", sprintf(_("You're about to delete the user %s."), LDAP::fix($this->dn)));
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
} else {