summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6add11d)
raw | patch | inline | side by side (parent: 6add11d)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 15 Mar 2006 08:01:06 +0000 (08:01 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 15 Mar 2006 08:01:06 +0000 (08:01 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2841 594d385d-05f5-0310-b6e9-bd551577e9d8
index 644c1abe25098ffe913b46460ddae67ee8cca239..a876012c44dc99e782d5cc963aa125498dc8c839 100644 (file)
$this->RecordTypes['mDRecord'] = "mDRecord"; // ok
$this->RecordTypes['mXRecord'] = "mXRecord"; // ok
$this->RecordTypes['nSRecord'] = "nSRecord"; // ok
- $this->RecordTypes['pTRRecord'] = "relativeDomainName";// ok
$this->RecordTypes['hInfoRecord'] = "hInfoRecord"; // ok
$this->RecordTypes['mInfoRecord'] = "mInfoRecord"; // ok
- $this->RecordTypes['tXTRecord'] = "tXTRecord"; // ok
+// $this->RecordTypes['tXTRecord'] = "tXTRecord"; // ok
$this->RecordTypes['aFSDBRecord'] = "aFSDBRecord"; // ok
$this->RecordTypes['SigRecord'] = "SigRecord"; // ok
$this->RecordTypes['KeyRecord'] = "KeyRecord"; // ok
/* Get all records */
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->dn);
- $ldap->search("(&(objectClass=dNSZone)(relativeDomainName=@))",array("*"));
+ $ldap->ls("(&(objectClass=dNSZone)(relativeDomainName=@))",$dn,array("*"));
while($attrs = $ldap->fetch()){
+
/* If relative domainname
* Try to read dnsclass / TTl / zone
*/
$types[$zoneName]['ReverseDN'] = $attrs['dn'];
}else{
- /* Generate SOA entry */
+ /* Generate SOA entry
+ */
if(isset($attrs['sOARecord'][0])){
$tmp = split("\ ",$attrs['sOARecord'][0]) ;
$tmp2 = array();
}
}
- /* Set dns Class*/
+ /* Set dns Class
+ */
if(isset($attrs['dNSClass'][0])){
$types[$attrs['zoneName'][0]]['dNSClass'] = $attrs['dNSClass'][0];
}
- /* Set zone Name */
+ /* Set zone Name
+ */
if(isset($attrs['zoneName'][0])){
$types[$attrs['zoneName'][0]]['zoneName'] = $attrs['zoneName'][0];
}
- /* Create list with all used records */
+ /* Create list with all used records
+ */
foreach($this->RecordTypes as $name => $value){
- /* If there is a record attribute */
+ /* If there is a record attribute
+ */
if(isset($attrs[$name])){
- /* get all entries */
+ /* get all entries
+ */
for($i = 0 ; $i < $attrs[$value]['count']; $i ++){
$types[$attrs['zoneName'][0]]['Records'][] =array("type" =>$name,
"inittype" =>$name,
}
}
- /* If there is at least one entry in this -> types, we have DNS enabled */
+ /* If there is at least one entry in this -> types, we have DNS enabled
+ */
$this->Zones = $types;
if(count($this->Zones) == 0){
$this->is_account = false;
$this->is_account = true;
}
- /* Store initally account settings */
+ /* Store initally account settings
+ */
$this->DNSinitially_was_account = $this->is_account;
}
function execute()
{
- /* Call parent execute */
+ /* Call parent execute
+ */
plugin::execute();
- /* Fill templating stuff */
+ /* Fill templating stuff
+ */
$smarty= get_smarty();
$display= "";
- /* Do we need to flip is_account state? */
+ /* Do we need to flip is_account state?
+ */
if (isset($_POST['modify_state'])){
$this->is_account= !$this->is_account;
}
- /* Show tab dialog headers */
+ /* Show tab dialog headers
+ */
if ($this->is_account){
$display= $this->show_header(_("Remove DNS service"),
_("This server has DNS features enabled. You can disable them by clicking below."));
return ($display);
}
- /* Edited or Added zone hould be saved saved */
+ /* Edited or Added zone hould be saved saved
+ */
if(isset($_POST['SaveZoneChanges'])){
$this->dialog->save_object();
- /* Check if noting went wrong */
+ /* Check if noting went wrong
+ */
if(count($this->dialog->check())){
foreach($this->dialog->check() as $msgs){
print_red($msgs);
}
}else{
- /* add new/edited zone */
+ /* add new/edited zone
+ */
$ret = $this->dialog->save();
+ $ret['InitialzoneName']= $this->dialog->InitiallyZoneName;
+ $ret['InitialreverseZone']= $this->dialog->InitiallyReverseZone;
unset($this->Zones[$this->dialog->InitiallyZoneName]);
$this->Zones[$ret['zoneName']] = $ret;
$this->dialog = NULL;
}
}
- /* Cancel zone edit / new */
+ /* Cancel zone edit / new
+ */
if(isset($_POST['CancelZoneChanges'])){
$this->dialog = NULL;
}
- /* Add empty new zone */
+ /* Add empty new zone
+ */
if(isset($_POST['AddZone'])){
$this->dialog = new servdnseditZone($this->config,$this->dn,$this->RecordTypes);
}
- /* Check for edit zone request */
+ /* Check for edit zone request
+ */
$once = false;
foreach( $_POST as $name => $value){
- /* check all post for edit request */
+ /* check all post for edit request
+ */
if(preg_match("/^editZone_/",$name)&&!$once){
$once =true;
$tmp = preg_replace("/^editZone_/","",$name);
$this->dialog= new servdnseditZone($this->config,$this->dn,$this->RecordTypes,$this->Zones[$tmp]);
}
- /* check posts for delete zone */
+ /* check posts for delete zone
+ */
if(preg_match("/^delZone_/",$name)&&!$once){
-
-
$once =true;
$tmp = preg_replace("/^delZone_/","",$name);
$tmp = base64_decode(preg_replace("/_.*$/","",$tmp));
}
}
- /* Show dialog */
+ /* Show dialog
+ */
if($this->dialog!= NULL){
$this->dialog->save_object();
$this->dialog->parent = $this;
return($this->dialog->execute());
}
- /* Create Listbox with existing Zones */
+ /* Create Listbox with existing Zones
+ */
$ZoneList = new divSelectBox("dNSZones");
$ZoneList -> SetHeight(254);
- /* Add entries to divlist*/
+ /* Add entries to divlist
+ */
$editImg = "<input type='image' src='images/edit.png' name='editZone_%s'>
<input type='image' src='images/edittrash.png' name='delZone_%s'>";
foreach($this->Zones as $zone => $values ){
));
}
- /* Display tempalte */
+ /* Display tempalte
+ */
$smarty->assign("ZoneList",$ZoneList->DrawList());
$display.= $smarty->fetch(get_template_path('servdns.tpl', TRUE));
return($display);
}
- /* This funtion returns all used Zonenames */
+ /* This funtion returns all used Zonenames
+ */
function getUsedZoneNames()
{
$ret = array();
}
- /* Remove dns service */
+ /* Remove dns service
+ */
function remove_from_parent()
{
if(!$this->DNSinitially_was_account){
/* Save to LDAP */
function save()
{
- /* Ldap conenction / var initialization */
+ /* Ldap conenction / var initialization
+ */
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
$actions =array("update"=>array(),"add"=>array(),"delete"=>array());
- /* Generate entries for all zones, and check if they must be updated deleted added */
- foreach($this->Zones as $zone){
+ /* Generate entries for all zones, and check if they must be updated deleted added
+ */
+ foreach($this->Zones as $key => $zone){
+ if(isset($zone['InitialzoneName']) && ($zone['zoneName'] != $zone['InitialzoneName'])){
+ $dst = "zoneName=".$zone['zoneName'].",".$this->dn;
+ $src = "zoneName=".$zone['InitialzoneName'].",".$this->dn;
+ $this->recursive_move($src,$dst);
+
+ $tmp['zoneName'] = $zone['zoneName'];
+ $ldap->search ("(&(objectClass=dNSZone)(zoneName=".$zone['InitialzoneName']."))",array("relativeDomainName"));
+ while($attrs = $ldap->fetch()){
+ $ldap->cd($attrs['dn']);
+ $ldap->modify($tmp);
+ show_ldap_error($ldap->get_error());
+ }
+ }
+ if(isset($zone['InitialreverseZone']) &&($zone['InitialreverseZone'] != $zone['ReverseZone'])){
+ $dst = "zoneName=".$zone['ReverseZone'].",".$this->dn;
+ $src = "zoneName=".$zone['InitialreverseZone'].",".$this->dn;
+ $this->recursive_move($src,$dst);
+
+ $tmp['zoneName'] = $zone['zoneName'];
+ $ldap->search ("(&(objectClass=dNSZone)(zoneName=".$zone['InitialzoneName']."))",array("relativeDomainName"));
+ while($attrs = $ldap->fetch()){
+ $ldap->cd($attrs['dn']);
+ $ldap->modify($tmp);
+ show_ldap_error($ldap->get_error());
+ }
+ }
- /* Get ldap syntax */
+
+ /* Get ldap syntax
+ */
$tmp = $this->generate_LDAP_entries($zone);
- /* Check if dn is new, or if entry was edited */
+ /* Check if dn is new, or if entry was edited
+ */
foreach($tmp as $key => $values){
if(isset($this->usedDNS[$key])){
$actions['update'][$key]=$values;
}
}
- /* Check which dns are not used anymore ...*/
+ /* Check which dns are not used anymore ...
+ */
foreach($this->usedDNS as $key => $values){
$actions['delete'][$key] = $values;
}
- /* Remove deleted zones */
+ /* Remove deleted zones
+ */
foreach($actions['delete'] as $dn => $attrs){
$ldap->cd($dn);
$ldap->rmdir_recursive($dn);
}
- /* Add new zones */
+ /* Add new zones
+ */
foreach($actions['add'] as $dn => $attrs){
$ldap->cd($this->config->current['BASE']);
- // $ldap->create_missing_trees($dn);
$ldap->cd($dn);
$ldap->add($attrs);
}
- /* Update existing entries */
+ /* Update existing entries
+ */
foreach($actions['update'] as $dn => $attrs){
$ldap->cd($dn);
- //$this->cleanup();
$ldap->modify ($attrs);
}
+
show_ldap_error($ldap->get_error());
}
$tmp['sOARecord'] = $str;
- /* Generate Record entries */
+ /* Generate Record entries
+ */
$arr = array("aRecord","SigRecord","KeyRecord","aAAARecord","nSRecord","iaFSDBRecord","mInfoRecord","hInfoRecord","mXRecord","mDRecord","tXTRecord",
"LocRecord","nXTRecord","sRVRecord","nAPTRRecord","kXRecord","certRecord","a6Record","dSRecord","sSHFPRecord","rRSIGRecord","nSECRecord");
$aRecords = array();
}
}
/* Check if there are records removed,
- if there are some removed records, the append an array
+ if there are some removed records, then append an array
to ensure that these record types are deleted
*/
if((isset($zone['Records']))&&(is_array($zone['Records']))){
}
}
- /* generate forward entry */
+ /* generate forward entry
+ */
$dn = "zoneName=".$zone['zoneName'].",".$this->dn;
$tmp2[$dn] = $tmp;
$tmp2[$dn]['zoneName'] = $zone['zoneName'];
- /* generate reverse entry */
+ /* generate reverse entry
+ */
$dn = "zoneName=".$this->FlipIp($zone['ReverseZone']).".in-addr.arpa,".$this->dn;
$tmp2[$dn] = $tmp;
$tmp2[$dn]['tXTRecord'] ="zoneName=".$zone['zoneName'];
return($tmp2);
}
-
-
-
}
-
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>
diff --git a/plugins/admin/systems/class_servDNSeditZone.inc b/plugins/admin/systems/class_servDNSeditZone.inc
index d563fc30256bedcf818f08f4ec2031733426e4fa..2ab894396a8d66bfd86ade6d1b46c51cf0f3f481 100644 (file)
foreach($this->Records as $key => $rec){
if($rec['type'] == "mXRecord"){
$tmp = split(" ",$rec['value']);
- $rec['value'] = $tmp[0];
- $tmp2[$tmp[1]] = $rec;
+ $rec['value'] = $tmp[1];
+ $tmp2[$tmp[0]] = $rec;
unset($this->Records[$key]);
}
}
$this->mXRecords = array();
$this->Records = array();
}
+
$str = date("Ymd");
if(preg_match("/^".$str."/",$this->sOAserial)){
$this->sOAserial = $this->sOAserial + 1;
/* Open Zone Entry Edit Dialog
*/
if(isset($_POST['EditZoneEntries'])){
- $this->dialog= new servDNSeditZoneEntries($this->config,$this->dn,$this->zoneName,$this->FlipIp($this->ReverseZone),$this->RecordTypes);
+ $this->dialog= new servDNSeditZoneEntries($this->config,$this->dn,$this->InitiallyZoneName,$this->FlipIp($this->InitiallyReverseZone),$this->RecordTypes);
}
/* Save Zone Entry Edit Dialog
/* Assign records list */
-
- if($this->dn != "new"){
- $smarty->assign("NotNew", true);
- }else{
$smarty->assign("NotNew", false);
- }
$smarty->assign("Mxrecords", $div->DrawList());
$smarty->assign("records" , $this->generateRecordsList());
$ret[$name] = $this->$name;
}
+ /* Create mx records
+ */
foreach($this->mXRecords as $key => $rec){
- $rec['value'].= " ".$key;
+ $rec['value']= $key." ".$rec['value'];
$this->Records [] = $rec;
}
diff --git a/plugins/admin/systems/class_servDNSeditZoneEntries.inc b/plugins/admin/systems/class_servDNSeditZoneEntries.inc
index 35b2143c12cb74743152c18e957844b611ad98aa..f1f0d16e773fd8c6d58a65e73420a165fe213e01 100644 (file)
var $attributes= array("zoneName");
var $objectclasses= array("whatever");
- var $Devices = array();
- var $InitDevices = array();
- var $zoneName = "";
- var $reverseName = "";
- var $RecordTypes= array();
+ var $Devices = array();
+ var $InitDevices = array();
+
+ var $FreeHosts = array();
+ var $InitFreeHosts= array();
+
+ var $zoneName = ""; // ZoneName of currently edited Zone
+ var $reverseName = ""; // ReverseZone of the currently edited Zone
+
+ var $RecordTypes= array(); // Possible record type. They will be set in contrucktor
+ // and some types will be added later (cName/Ptr)
function servDNSeditZoneEntries ($config, $dn= NULL,$zoneName,$reverseName,$RTypes)
{
plugin::plugin ($config, $dn);
+ /* Initialise class
+ */
$this->zoneName = $zoneName;
$this->reverseName = $reverseName;
$this->RecordTypes = $RTypes;
+
+ /* Add records types which are not allowed in zones
+ */
$this->RecordTypes['cNAMERecord'] = "relativeDomainName";
-
+ $this->RecordTypes['pTRRecord'] = "relativeDomainName";
+ $this->RecordTypes['tXTRecord'] = "tXTRecord";
+ /* Get ldap connection
+ */
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->config->current['BASE']);
- /* Get all objects it this zone ...
+ /* Get all objects using this zone
+ * Workstations / Terminals
*/
$res = $ldap->search("(&(objectClass=dNSZone)(|(zoneName=".$zoneName.")(zoneName=".$reverseName.".in-addr.arpa))(!(relativeDomainName=@)))");
while($attrs = $ldap->fetch($res)){
+ if(preg_match("/zoneName=/",$attrs['dn'])) continue;
foreach($this->RecordTypes as $atr => $val){
if((isset($attrs[$atr])) && (is_array($attrs[$atr]))){
unset($attrs[$val]['count']);
$dn = preg_replace("/^.*,cn/","cn",$attrs['dn']);
$this->Devices[$dn]['RECORDS'][$atr] = $attrs[$val];
+ $this->Devices[$dn]['Type'] = "Exists";
}
}
}
-
+
/* Add additional informations
- to all catched objects
+ to all catched objects ( ObjectInformations)
*/
foreach($this->Devices as $dn => $Recs){
- $this->Devices[$dn]['OBJECT'] = $ldap->fetch($ldap->cat($dn,array("objectClass","cn")));
+ $attrs = $ldap->fetch($ldap->cat($dn,array("objectClass","cn")));
+ $this->Devices[$dn]['OBJECT'] = $attrs;
+ $this->Devices[$dn]['OrigCn'] = $attrs['cn'][0];
}
+ /* Add Free Hand entries
+ * Free hand entries are entries which are not directly assigned
+ * to an existing network object like a WS or a Terminal.
+ * They will be found in a subtree within this zone.
+ * For example :
+ * The object name is FreeHand1,
+ * zoneName=test.de,cn=server ...
+ * // ObjectContainer
+ * relativeDomainName=FreeHand1,zoneName=....
+ * // Dns entry
+ * relativeDomainName=FreeHand1, relativeDomainName=FreeHand1,zoneName=....
+ * // cName entry ....
+ * relativeDomainName=terminal12, relativeDomainName=FreeHand1,zone...
+ */
+ $ldap->cd ("zoneName=".$this->zoneName.",".$this->dn);
+ $ldap->ls ("(&(objectClass=dNSZone)(!(relativeDomainName=@)))","zoneName=".$this->zoneName.",".$this->dn,array("*"));
+
+ $GetSubInformations = array();
+ while($attrs = $ldap->fetch()){
+
+ unset($attrs[$val]['count']);
+
+ $dn = $attrs['dn'];
+
+ /* Split dn into relativeDomainNames
+ */
+ $tmp = split("relativeDomainName=",trim(preg_replace("/,zoneName=.*$/","\\1",$dn)));
+ $tmp2 = array();
+ foreach($tmp as $t){
+ if(empty($t)) continue;
+ $tmp2[] = preg_replace("/,$/","",$t);
+ }
+
+ /* Set object Name
+ */
+ $cn = $tmp2[0];
+ $dn = "relativeDomainName=".$cn.",zoneName=".$this->zoneName.",".$this->dn;
+
+ /* Create entry
+ */
+ $this->Devices[$dn]['OBJECT'] = $attrs;
+ $this->Devices[$dn]['OBJECT']['cn'][0] = $cn;//attrs['relativeDomainName'];
+ $this->Devices[$dn]['OBJECT']['OrigCn'] = $cn;//attrs['relativeDomainName'][0];
+ $this->Devices[$dn]['Type'] = "Free";
+
+ $GetSubInformations [] = $dn;
+ }
+
+ /* Get sub informations
+ CName or pTR records are stored in a sub entry.
+
+ // The base entry with aRecords/tXTrecords/....
+ relativeDomainName=Keks, relativeDomainName=Keks, zoneName=....
+
+ // And the sub entries like this one
+ relativeDomainName=10.2.64.in-addr.arpa, relativeDomainName=Keks, zoneName =...
+ ( They can't be stored in a single entry, so i decided to store them this way ).
+ */
+ foreach($GetSubInformations as $dn){
+ $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$dn,array("*"));
+ while($attrs= $ldap->fetch()){
+ foreach($this->RecordTypes as $atr => $val){
+ if((isset($attrs[$atr])) && (is_array($attrs[$atr]))){
+ unset($attrs[$val]['count']);
+ $this->Devices[$dn]['RECORDS'][$atr] = $attrs[$val];
+ }
+ }
+ }
+ }
+
$this->Devices;
$this->InitDevices = $this->Devices;
}
$record = $tmp2[1];
$numrec = $tmp2[2];
- unset($this->Devices[$dn]['RECORDS'][$record][$numrec]);
+ unset($this->Devices[$dn]['RECORDS'][$record][$numrec]);
+
+ if(count($this->Devices[$dn]['RECORDS'][$record]) == 0){
+ unset($this->Devices[$dn]['RECORDS'][$record]);
+ if(count($this->Devices[$dn]['RECORDS']) ==0){
+ unset($this->Devices[$dn]);
+ }
+ }
+
}
/* Don't know how i should implement this ...
*/
if((preg_match("/^UserRecord_/",$name)) && ($once)){
- $once = false;
- $tmp = preg_replace("/^UserRecord_/","",$name);
- $tmp = preg_replace("/_.*$/","",$tmp);
- $tmp2 = split("\|",$tmp);
-
- $dn = base64_decode($tmp2[0]);
- $record = $tmp2[1];
- $numrec = $tmp2[2];
-
- $this->FreeDevices[$dn]['RECORDS']['User'][$numrec] = "";
+ $once = false;
+ $tmp['RECORDS']['aRecord'][0] = 'empty';
+ $tmp['Type'] = 'Free';
+ $tmp['OBJECT']['cn'][0] = 'Free';
+ $this->Devices[] = $tmp;
}
}
-
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
$display.= $smarty->fetch(get_template_path('servDNSeditZoneEntries.tpl', TRUE));
return($display);
}
+
/* Create html table out of given entry
*/
$obj = $this->Devices[$obj_dn];
$objectName = $obj['OBJECT']['cn'][0];
- // set title
- $str = "<h3>".sprintf(_("Settings for '%s'"),$obj_dn)." : </h3>";
-
+ /* Set title
+ */
+ if($obj['Type'] == "Free"){
+ $str = "<h3>".sprintf(_("Settings for free host entry # %s"),($obj_dn +1))." : </h3>";
+ }else{
+ $str = "<h3>".sprintf(_("Settings for '%s'"),$obj_dn)." : </h3>";
+ }
+
+ $hostNameOnce = true;
/* Walk through all defined records
*/
+ $str.= "<table cellspacing='0' cellpadding='0'>";
foreach($obj['RECORDS'] as $id => $types){
/* Create table
*/
- $str.= "<table cellspacing='0' cellpadding='0'>";
foreach($types as $key => $type){
/* Create unique post name
$name = base64_encode($obj_dn)."|".$id."|".$key;
$str .= "<tr>
- <td style='width:80px;'>
- ".$objectName."
+ <td style='width:80px;'>";
+
+ if($hostNameOnce){
+ $hostNameOnce = false;
+ $str .="<input type='text' name='RenameHost_".$name."' value='".$objectName."'>";
+ }else{
+ $str .=$objectName;
+ }
+
+ $str .="
</td>
<td style='width:80px;'>
".$this->createRecordTypeSelection($id,$name)."
</td>
</tr>";
}
- $str .="</table>";
}
+ $str .="</table>";
return($str);
}
/* Create selectbox with all available option types
*/
- function createRecordTypeSelection($id,$refID){
- $str = "\n<select name='RecordTypeSelection_".$refID."'>";
+ function createRecordTypeSelection($id,$refID,$isFreeRecord =false){
+ if(!$isFreeRecord){
+ $str = "\n<select name='RecordTypeSelection_".$refID."'>";
+ }else{
+ $str = "\n<select name='FreeRecordTypeSelection_".$refID."'>";
+ }
foreach($this->RecordTypes as $type => $atr) {
if($id == $type){
$str .="\n<option value='".$type."' selected >".strtoupper(preg_replace("/record/i","",$type))."</option>";
{
/* Save all form fields
*/
-
+
/* Possible attributes posted
*/
- $arr = array("RecordTypeSelection_","ValueSelection_");
-
+ $actions = array("RenameHost_","ValueSelection_");
foreach($_POST as $name=>$value){
-
- foreach($arr as $type)
-
+
+ foreach($actions as $act){
/* Check if attribute was posted
*/
- if(preg_match("/".$type."/",$name)){
-
+ if(preg_match("/".$act."/",$name)){
+
/* Extract informations out of postname
*/
- $action = $type;
+ $action = $act;
$tmp = preg_replace("/^".$action."/","",$name);
$tmp = preg_replace("/_.*$/","",$tmp);
$tmp2 = split("\|",$tmp);
$record = $tmp2[1];
$numrec = $tmp2[2];
- /* Check which type of post was posted
- */
-
- // checkbox was posted
- if($action == "RecordTypeSelection_"){
- if($record != $value){
- $str = $this->Devices[$dn]['RECORDS'][$record][$numrec];
- unset($this->Devices[$dn]['RECORDS'][$record][$numrec]);
- $this->Devices[$dn]['RECORDS'][$value][] = $str;
- }
- }
-
- // entry value was psoted
- if($action == "ValueSelection_"){
+ // entry value was psoted
+ if($act == "ValueSelection_"){
$this->Devices[$dn]['RECORDS'][$record][$numrec] = $value;
+ }elseif($act == "RenameHost_"){
+ $tmp = array();
+ foreach($this->Devices as $dnn => $dev){
+ if($dn == $dnn){
+ continue;
+ }
+ if(isset($dev['OrigCn'])){
+ $n1 = strtolower($dev['OrigCn']);
+ $tmp[$n1] = $n1;
+ }
+ $n2 = strtolower($dev['OBJECT']['cn'][0]);
+ $tmp[$n2] = $n2;
+ }
+
+ if(!isset($tmp[strtolower($value)])){
+ $this->Devices[$dn]['OBJECT']['cn'][0] = $value;
+ }
}
}
+ }
+ }
+ foreach($_POST as $name => $value){
+
+ /* Check if attribute was posted
+ */
+ if(preg_match("/^RecordTypeSelection_/",$name)){
+
+ /* Extract informations out of postname
+ */
+ $action = "RecordTypeSelection_";
+ $tmp = preg_replace("/^".$action."/","",$name);
+ $tmp = preg_replace("/_.*$/","",$tmp);
+ $tmp2 = split("\|",$tmp);
+
+ $dn = base64_decode($tmp2[0]);
+ $record = $tmp2[1];
+ $numrec = $tmp2[2];
+
+ if($record != $value){
+ $str = $this->Devices[$dn]['RECORDS'][$record][$numrec];
+ unset($this->Devices[$dn]['RECORDS'][$record][$numrec]);
+ $this->Devices[$dn]['RECORDS'][$value][] = $str;
+ }
+ }
}
}
function check()
{
$message= array();
- // Nothing right now
+
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd($this->config->current['BASE']);
+
+ foreach($this->Devices as $devDN => $device){
+
+ /* check: if given name for Free Hand entry is valid.
+ * cn exists ? invalid characters ? ...
+ */
+ if($device['Type'] == "Free"){
+ $cn = $device['OBJECT']['cn'][0];
+
+ $ldap->search("(cn=".$cn.")",array("cn"));
+ if($ldap->count()){
+ $message[] = sprintf(_("The name '%s' can't be used as free hand entry, the name is already used in this ldap tree."),$cn);
+ }
+ }
+
+ /* Checking entry name
+ */
+ if(!is_uid($device['OBJECT']['cn'][0])){
+ $message[] = sprintf(_("Entry name '%s' contians invalid characters."), $device['OBJECT']['cn'][0]);
+
+ }
+
+ /* Check if we have renamed the server, hich we are currently editing.
+ * reset the value and display a message.
+ */
+ if(strcmp($devDN,$this->dn) ==0 ){
+ $new = $device['OBJECT']['cn'][0];
+ $old = $this->InitDevices[$devDN]['OBJECT']['cn'][0];
+
+ if($new != $old){
+ $message[] = sprintf(_("Can't rename the server '%s' to '%s', the server contains this zone."),$old,$new);
+ }
+ }
+
+
+ /* Renaming check for existing devices
+ */
+ if(($device['Type'] == "Exists") && ($device['OrigCn'] != $device['OBJECT']['cn'][0])){
+ $cn = $device['OBJECT']['cn'][0];
+
+ $ldap->search("(cn=".$cn.")",array("cn"));
+ if($ldap->count()){
+ $message[] = sprintf(_("Can't rename '%s' to '%s',the destination name already exists."),$device['OrigCn'],$cn);
+ }
+
+ if(!is_uid($cn)){
+ $message[] = sprintf(_("Can't rename '%s' to '%s',the destination name contains invalid characters."),$device['OrigCn'],$cn);
+ }
+ }
+
+ /* Check records
+ */
+ $singleEntries = array("cNAMERecord","pTRRecord");
+
+ $tmp2 = array();
+ foreach($device['RECORDS'] as $type => $entries){
+
+ /* Check for multiple use of unique record types
+ */
+ if((in_array($type,$singleEntries)) && (count($entries) > 1)){
+ $message[] = sprintf(_("The record type '%s' is a unique type and can't be defined twice."),$type);
+ }
+
+ /* Check for empty / duplicate entries in record array
+ */
+ $tmp = array();
+ foreach($entries as $entry){
+
+ /* Check for empty records
+ */
+ if(empty($entry)){
+ $message[] = sprintf(_("There is an empty '%s' for host '%s'."),$type,$device['OBJECT']['cn'][0]);
+ }
+
+ /* Check for duplicate record entries
+ */
+ if(!isset($tmp[$entry])){
+ $tmp[$entry]= 'test';
+ }else{
+ $message[] = sprintf(_("There is a duplicate entry in '%s' for '%s'."),$type,$device['OBJECT']['cn'][0]);
+ }
+ }
+ }
+ }
return ($message);
}
{
/* Set all initial records to array()
This means they will be removed from the entry
+ if they won't be overwritten
*/
foreach($this->InitDevices as $dn => $obj){
$attrs[$dn]= array();
/* Delete all objects which should be delted
*/
foreach($tmp['del'] as $key => $ntr){
- $ldap->rmdir($key);
+ $ldap->rmdir_recursive($key);
}
/* Add append new / updated entries
$ldap->cd($key);
$ldap->add($attrs);
}
-
+
/* Display errors ...
*/
if($ldap->error != "Success"){
echo "<br>".$ldap->error."<br>";
print_a($attrs);
+ echo $key;
}
}
+
+ /* Rename entries
+ !! Terminals / WS / etc will be renamed too
+ */
+ foreach($tmp['rename'] as $old => $new){
+ $ldap->cat($old);
+ $this->recursive_move($old,$new);
+ }
}
+ /* This function creates an array with following indexs
+ * 'delete' for all dns which should be deleted recursivly
+ * 'addupdated' Contains all entries which should be written
+ * 'rename' Contains all dns which should be renamed
+ */
function generate_LDAP_entries($objs)
{
+
$entries = array();
$delete = array();
+ $rename = array();
+
+ $ldap = $this->config->get_ldap_link();
+ $ldap->cd ($this->config->current['BASE']);
/* these entries are added to base object ...
*/
/* Create t odo
*/
foreach($objs as $dn => $recs){
-
+
+ /* Check if object must be renamed
+ */
+ if(isset($this->Devices[$dn]['OrigCn'])){
+ if($this->Devices[$dn]['OBJECT']['cn'][0] != $this->Devices[$dn]['OrigCn']){
+ $newdn = str_replace("cn=".$this->Devices[$dn]['OrigCn'], "cn=".$this->Devices[$dn]['OBJECT']['cn'][0],$this->Devices[$dn]['OBJECT']['dn']);
+ $rename[$this->Devices[$dn]['OBJECT']['dn']] = $newdn;
+ $rename["relativeDomainName=".$this->Devices[$dn]['OrigCn'].",".$newdn] = "relativeDomainName=".$this->Devices[$dn]['OBJECT']['cn'][0].",".$newdn;
+ }
+ }
+
/* Get basic info
*/
- $obj = $this->Devices[$dn];
- $objectName = $obj['OBJECT']['cn'][0];
+ if(isset($this->Devices[$dn])){
+ $obj = $this->Devices[$dn];
+ }else{
+ $obj = NULL;
+ }
- /* Calculate records ...
+ /* If is valid entry
*/
- foreach($recs as $type => $rec){
+ if($obj != NULL){
+
+ /* Both type must be handled different
+ * Free / Exists
+ */
+ if($obj["Type"] == "Free"){
+ $objectName = $obj['OBJECT']['cn'][0];
+ }else{
+ $objectName = $obj['OrigCn'];
+ }
+
- /* Simply add normal entries
+ /* If type is Free, check
*/
- if(in_array($type,$normal)){
- $entries['relativeDomainName='.$objectName.','.$dn][$type] = $rec ;
+ if($obj['Type'] == "Free"){
+
+ /* Remove entry, if it was renamed
+ */
+ if(isset($obj['OBJECT']['OrigCn'])){
+ if($obj['OBJECT']['cn'][0] != $obj['OBJECT']['OrigCn']){
+ $delete["relativeDomainName=".$obj['OBJECT']['OrigCn'].",zoneName=".$this->zoneName.",".$this->dn]="";
+ }
+ }
+
+ /* Add new entry
+ */
+ $dn = "relativeDomainName=".$objectName.",zoneName=".$this->zoneName.",".$this->dn;
+ $dn2 = $dn;
+
+ $ldap->cat($dn);
+ if($ldap->count() == 0){
+ $entries[$dn]['objectClass'] = array("top","dNSZone");
+ $entries[$dn]['zoneName'] = $this->zoneName;
+ $entries[$dn]['relativeDomainName'] = $objectName;
+ }
}
+ }
+
+ /* Calculate records ...
+ */
+ foreach($recs as $type => $rec){
- /* Special handling for cNAMERecords
+ /* Simply add normal entries
*/
- if($type == "cNAMERecord"){
- if(isset($this->InitDevices[$dn]['RECORDS']['cNAMERecord'])){
- foreach($this->InitDevices[$dn]['RECORDS']['cNAMERecord'] as $warmal){
- $delete['relativeDomainName='.$warmal.','.$dn] = "";
+ if($obj != NULL){
+ if(in_array($type,$normal)){
+ $ldap->cat('relativeDomainName='.$objectName.','.$dn);
+
+ /* Append objectFrame if object doesn't exists in ldap
+ */
+ if($ldap->count() == 0) {
+ $entries['relativeDomainName='.$objectName.','.$dn]['objectClass'] = array("top","dNSZone");
+ $entries['relativeDomainName='.$objectName.','.$dn]['zoneName'] = $this->zoneName;
+ $entries['relativeDomainName='.$objectName.','.$dn]['relativeDomainName'] = $objectName;
}
+ $entries['relativeDomainName='.$objectName.','.$dn][$type] = $rec ;
}
- foreach($rec as $r){
- if(!empty($r)){
- $entries['relativeDomainName='.$r.','.$dn]['cNAMERecord'] = $objectName;
- $entries['relativeDomainName='.$r.','.$dn]['relativeDomainName'] = $r;
- $entries['relativeDomainName='.$r.','.$dn]['objectClass'] = array("top","dNSZone");
- $entries['relativeDomainName='.$r.','.$dn]['zoneName'] = $this->zoneName;
+
+ /* Special handling for cNAMERecords
+ */
+ if($type == "cNAMERecord"){
+
+ $useDn = $dn;
+ if($obj['Type'] == "Free"){
+ $useDn = $dn2;
+ }
+
+ if(isset($this->InitDevices[$useDn]['RECORDS']['cNAMERecord'])){
+ foreach($this->InitDevices[$useDn]['RECORDS']['cNAMERecord'] as $warmal){
+ $delete['relativeDomainName='.$warmal.','.$useDn] = "";
+ }
+ }
+ foreach($rec as $r){
+ if(!empty($r)){
+ $entries['relativeDomainName='.$r.','.$useDn]['objectClass'] = array("top","dNSZone");
+ $entries['relativeDomainName='.$r.','.$useDn]['zoneName'] = $this->zoneName;
+ $entries['relativeDomainName='.$r.','.$useDn]['cNAMERecord'] = $objectName;
+ $entries['relativeDomainName='.$r.','.$useDn]['relativeDomainName'] = $r;
+ }
}
}
- }
- /* Special handling for ptrrecord
- */
- if($type == "pTRRecord"){
- if(isset($this->InitDevices[$dn]['RECORDS']['pTRRecord'])){
- foreach($this->InitDevices[$dn]['RECORDS']['pTRRecord'] as $warmal){
- $delete['relativeDomainName='.$warmal.','.$dn] = "";
+ /* Special handling for ptrrecord
+ */
+ if($type == "pTRRecord"){
+
+ $useDn = $dn;
+ if($obj['Type'] == "Free"){
+ $useDn = $dn2;
+ }
+
+ if(isset($this->InitDevices[$dn]['RECORDS']['pTRRecord'])){
+ foreach($this->InitDevices[$dn]['RECORDS']['pTRRecord'] as $warmal){
+ $delete['relativeDomainName='.$warmal.','.$useDn] = "";
+ }
+ }
+ foreach($rec as $r){
+ if(!empty($r)){
+ $entries['relativeDomainName='.$r.','.$useDn]['pTRRecord'] = $objectName;
+ $entries['relativeDomainName='.$r.','.$useDn]['zoneName'] = $this->reverseName.".in-addr.arpa";
+ $entries['relativeDomainName='.$r.','.$useDn]['relativeDomainName'] = $r;
+ $entries['relativeDomainName='.$r.','.$useDn]['objectClass'] = array("top","dNSZone");
+ }
}
}
- foreach($rec as $r){
- if(!empty($r)){
- $entries['relativeDomainName='.$r.','.$dn]['pTRRecord'] = $objectName;
- $entries['relativeDomainName='.$r.','.$dn]['zoneName'] = $this->reverseName.".in-addr.arpa";
- $entries['relativeDomainName='.$r.','.$dn]['relativeDomainName'] = $r;
- $entries['relativeDomainName='.$r.','.$dn]['objectClass'] = array("top","dNSZone");
+ }
+ if($obj == NULL){
+ $obj = $this->InitDevices[$dn];
+ if($obj['Type'] == "Free"){
+ $delete['relativeDomainName='.$objectName.','.$dn] = "";
+ }else{
+ $ldap->cd($dn);
+ $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$dn,array("relativeDomainName"));
+ while($attrs = $ldap->fetch()){
+ $delete[$attrs['dn']] = "";
}
}
- }
+ }
+
}
}
-
- return(array("del"=> $delete , "addupdate"=> $entries));
+ $ret = array("del"=> $delete , "addupdate"=> $entries, "rename"=> $rename);
+ return($ret);
}
}
index b35c9c70f8768e17d56a4d9a7c47d8fc38992e7e..12f9c211e3850b87a6e76bfe995efa8841f70eb8 100644 (file)
/* Get all records */
$ldap = $this->config->get_ldap_link();
$ldap->cd($this->dn);
- $ldap->search("(&(objectClass=dNSZone)(zoneName=*)(!(relativeDomainName=@)))",array("*"));
+ $ldap->ls("(&(objectClass=dNSZone)(zoneName=*)(!(relativeDomainName=@)))",$this->dn,array("*"));
+
+ $found = false;
while($attrs = $ldap->fetch()){
/* If relative domainname == cn
* Try to read dnsclass / TTl / zone
*/
+
if($attrs['relativeDomainName'][0] == $this->cn){
/* Get class */
if(isset($attrs['dNSClass'][0])){
$this->dNSClass = $attrs['dNSClass'][0];
+ $found = true;
}
/* Get Zone*/
if(isset($attrs['zoneName'][0])){
$this->zoneName = $attrs['zoneName'][0];
+ $found = true;
}
/* Get ttl */
if(isset($attrs['dNSTTL'][0])){
$this->dNSTTL = $attrs['dNSTTL'][0];
+ $found = true;
}
}
/* If there is at least one entry in this -> types, we have DNS enabled */
$this->types = $types;
- if(count($this->types) == 0){
+ if((count($this->types) == 0) &&($found == false)){
$this->DNS_is_account = false;
}else{
$this->DNS_is_account = true;
/* only perfrom this checks if this is a valid DNS account */
if($this->DNS_is_account){
+
+ $checkArray = array();
+ $onlyOnce = array();
+ $onlyOnce['cNAMERecord'] = 0;
+
foreach($this->types as $name => $values){
+ if(!isset($checkArray[$values['type']][$values['value']])){
+ $checkArray[$values['type']][$values['value']] = 0;
+ }else{
+ $message[] = sprintf(_("Found duplicate value for record type '%s'."),$values['type']);
+ }
+
+ if(isset($onlyOnce[$values['type']])){
+ $onlyOnce[$values['type']] ++;
+ if($onlyOnce[$values['type']] > 1){
+ $message[] = sprintf(_("Found more than one entry for the uniqe record type '%s'."),$values['type']);
+ }
+ }
+
if($values['type'] == "tXTRecord") continue;
/* Check if there is an aRecord defined which uses the same IP as used in IPhostAddress */
}
}
}
-
return ($message);
}
if(!$this->DNS_is_account){
if($this->DNSinitially_was_account){
$tmp = array();
- foreach($this->types as $type){
- $dn = $type['dn'];
- if(!isset($tmp[$dn])) {
- $ldap->cd($dn);
- $ldap->rmDir($dn);
- }
- $tmp[$dn]=$dn;
+
+ $ldap->ls("(&(objectClass=dNSZone)(!(relativeDomainName=@)))",$this->dn,array("relativeDomainName"));
+ while($attrs = $ldap->fetch()){
+ $dn=$attrs['dn'];
+ $ldap->cd($dn);
+ $ldap->rmdir_recursive($dn);
}
}
}else{
while($at = $ldap->fetch()){
if(preg_match("/\.in\-addr\.arpa/",$at['zoneName'][0])){
- $ret[$at['relativeDomainName'][0]]['addr']= $at['zoneName'][0];
+ $name = preg_replace("/^zoneName=/","",$at['tXTRecord'][0]);
+ $ret[$name]['addr']= $at['zoneName'][0];
}else{
- $ret[$at['relativeDomainName'][0]]['name']= $at['zoneName'][0];
+ $name = $at['zoneName'][0];
+ $ret[$name]['name']= $at['zoneName'][0];
}
}
index 0ac0890921e4198caa87cc9e2e92084d18956ebd..dbe85d9bf3ae1a75bbcdd5b9db3c9ad7a7a951c3 100644 (file)
<td><LABEL for="zoneName">{t}Zone{/t}</LABEL></td>
<td>
<select name="zoneName" id="zoneName" {if $DNSAccount == false} disabled {/if}>
- {html_options values=$ZoneKeys output=$Zones}
+ {html_options values=$ZoneKeys output=$Zones selected=$zoneName}
</select>
</td>
</tr>
diff --git a/plugins/admin/systems/servDNSeditZoneEntries.tpl b/plugins/admin/systems/servDNSeditZoneEntries.tpl
index 2ab4f2aa40f6596060bfceb9ad641ce6b31eb0e7..a16f4f017605e2cac7fdc79daf2ecce4ccea5129 100644 (file)
-<h2>{t}This dialog allows you to configure all components of this DNS zone on a single list.{/t}<h2>
+<h2>{t}This dialog allows you to configure all components of this DNS zone on a single list.{/t}</h2>
+{t}Be carefull editing record types with this dialog. All changes will be saved immediately when using the save button.{/t}
+<br>
+<br>
+<p class="seperator"> </p>
{$table}
-
-
-
<p class="seperator"> </p>
<div style="text-algin:right;" align="right">
<p>