diff options
author | Tarik Gasmi | 2007-07-31 09:29:53 +0200 |
---|---|---|
committer | Tarik Gasmi | 2007-07-31 09:29:53 +0200 |
commit | c7b4e4a81d7f38c0f1f927f6804ef281c4f67dcd (patch) | |
tree | 974eb0c95d0ff2678439b161246433cde972564d /ldap-site-mngmt | |
parent | * more work towards Debian & Ubuntu support, Debian-4.0, Ubuntu-6.10 (diff) | |
download | core-c7b4e4a81d7f38c0f1f927f6804ef281c4f67dcd.tar.gz core-c7b4e4a81d7f38c0f1f927f6804ef281c4f67dcd.tar.xz core-c7b4e4a81d7f38c0f1f927f6804ef281c4f67dcd.zip |
Actualized LDAP SiteManagement Code - Web Interface, DHCP Generationscript
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1284 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'ldap-site-mngmt')
45 files changed, 1572 insertions, 387 deletions
diff --git a/ldap-site-mngmt/generation-scripts/dhcp_generate.pl b/ldap-site-mngmt/generation-scripts/dhcp_generate.pl index 13969f34..f8c2cfb6 100644 --- a/ldap-site-mngmt/generation-scripts/dhcp_generate.pl +++ b/ldap-site-mngmt/generation-scripts/dhcp_generate.pl @@ -2,12 +2,12 @@ # Generate ISC DHCP Configuration File # -# generates an include file "dhcp.master.inc" included in dhcpd.conf -# with: +# Reads DHCP Config Data form LDAP Directory and generates an +# include file "dhcp.master.inc" included in dhcpd.conf with: # - Definitions of User-defined DHCP Options # - DHCP Service Global Options -# - DHCP Subnet Deklarations and Options -# - DHCP Host Deklarations and Options +# - DHCP Subnet Declarations, Options and Dynamic Pools +# - DHCP Host Declarations and Options use strict; @@ -17,13 +17,13 @@ use warnings; use Net::LDAP; use Net::LDAP::LDIF; +# Configuration Variables for Perl-Script our ( $ldaphost, $basedn, $userdn, $passwd, $dhcpdn, $dhcpdconfpath, $dhcpdconffile ); -my ( $ldap, $mesg ); - -# Read Configuration Variables for LDAP/ +# Read Configuration Variables ... require "dhcpgen.conf.pl"; #use dhcpgenconfig; +my ( $ldap, $mesg, $mesg2 ); # Bind with LDAP Server $ldap = Net::LDAP->new( $ldaphost ) or die "$@"; @@ -67,10 +67,17 @@ if ($dhcpsrventry->exists( 'OptionDefinition' )) { printf DATEI "%s\n", $optdef; } } +# Failover Information of DHCP Service +my $failoverpeer; +if ($dhcpsrventry->exists( 'dhcpFailoverPeer' )) { + $failoverpeer = $dhcpsrventry->get_value( 'dhcpFailoverPeer' ); +} + +my $indent = ""; printf DATEI "\n\n######################\n# Global Options\n######################\n\n"; # write DHCP Options in global Scope -dhcpoptions( $dhcpsrventry ); +dhcpoptions( $dhcpsrventry, $indent ); printf DATEI "\n"; @@ -95,13 +102,36 @@ foreach my $subnetentry ( @subnets ) { my $netmask = $subnetentry->get_value( 'dhcpoptnetmask' ); printf DATEI "subnet %s netmask %s {\n", $subnet, $netmask; # write DHCP Options in Subnet Scope - dhcpoptions($subnetentry); - # Range - if ($subnetentry->exists( 'dhcpRange' )) { - my @range = split /_/,$subnetentry->get_value( 'dhcpRange' ); - printf DATEI " range %s %s;\n", $range[0], $range[1]; + my $optindent = " "; + dhcpoptions($subnetentry,$optindent); + + # write Pool Declarations in Subnet Declaration + # ldapsearch on Pool Objects referencing to DHCP Subnet Object + $mesg2 = $ldap->search(base=>$basedn, + scope => 'sub', + filter => '(&(objectclass=dhcpPool)(dhcphlpcont:dn:='.$subnetdn.'))'); + #Net::LDAP::LDIF->new( \*STDOUT,"w" )->write( $mesg->entries ); + $mesg2->code && die $mesg2->error; + my @pools = $mesg2->sorted('cn'); + + foreach my $poolentry ( @pools ) { + printf DATEI "%spool {\n", $optindent; + # write DHCP Options in Pool Scope + my $poolindent = " "; + if ( $failoverpeer ){ + printf DATEI "%sfailover peer \"%s\";\n", $poolindent, $failoverpeer; + printf DATEI "%sdeny dynamic bootp clients;\n", $poolindent; + } + if ($poolentry->exists( 'dhcpRange' )) { + #foreach my $ranges ( @) { + my @range = split /_/,$poolentry->get_value( 'dhcpRange' ); + printf DATEI "%srange %s %s;\n", $poolindent, $range[0], $range[1]; + } + dhcpoptions($poolentry,$poolindent); + printf DATEI "%s}\n", $optindent; } - + + # close Subnet Declaration printf DATEI "}\n\n"; } @@ -130,7 +160,7 @@ foreach my $hostentry ( @hosts ) { my @auarray = split /=/,$dnarray[2]; my $hostauactual = $auarray[1]; if ( $hostau ne $hostauactual) { - # hier neues handle und pfad falls eigene includedatei ... + # hier neues Datei Handle und neuer Pfad falls eigene includedatei ... printf DATEI "\n################################################\n# AU: %s \n", $hostauactual; $hostau = $hostauactual; } @@ -138,6 +168,7 @@ foreach my $hostentry ( @hosts ) { dhcphost($hostentry); } + close DATEI; # LDAP unbind @@ -153,6 +184,7 @@ exit (0); # write DHCP Options, Parameter: DHCP Object LDAP Entry sub dhcpoptions { my $entry = shift; + my $indent = shift; my @atts = $entry->attributes; # DHCP Optionen mit 'option' vorne dran @@ -163,9 +195,9 @@ sub dhcpoptions { my $value = $entry->get_value( $option ); $option =~ s/dhcpopt//; if ( $option eq "Domain-name"){ - printf DATEI " option %s \"%s\";\n", lc($option), $value; + printf DATEI "%soption %s \"%s\";\n", $indent, lc($option), $value; }else{ - printf DATEI " option %s %s;\n", lc($option), $value; + printf DATEI "%soption %s %s;\n", $indent, lc($option), $value; } } } @@ -177,9 +209,9 @@ sub dhcpoptions { my $value = $entry->get_value( $option ); $option =~ s/dhcpOpt//; if ( $option eq "Filename"){ - printf DATEI " %s \"%s\";\n", lc($option), $value; + printf DATEI "%s%s \"%s\";\n", $indent, lc($option), $value; }else{ - printf DATEI " %s %s;\n", lc($option), $value; + printf DATEI "%s%s %s;\n", $indent, lc($option), $value; } } } @@ -210,6 +242,7 @@ sub dhcphost { printf DATEI " option %s \"%s\";\n", lc($hwoption), $entry->get_value($hwoption); } # remaining DHCP Options - dhcpoptions ($entry); + my $optindent = " "; + dhcpoptions ($entry, $optindent); printf DATEI "}\n"; }
\ No newline at end of file diff --git a/ldap-site-mngmt/webinterface/computers/dhcphost_change.php b/ldap-site-mngmt/webinterface/computers/dhcphost_change.php index 96bbb715..a35a29cb 100644 --- a/ldap-site-mngmt/webinterface/computers/dhcphost_change.php +++ b/ldap-site-mngmt/webinterface/computers/dhcphost_change.php @@ -27,7 +27,7 @@ echo "Host DN:"; print_r($hostDN); echo "<br>"; echo "submenuNR:"; print_r($sbmnr); echo "<br><br>";*/ -$seconds = 40; +$seconds = 2; $url = 'dhcphost.php?dn='.$hostDN.'&sbmnr='.$sbmnr; echo " @@ -53,6 +53,7 @@ if ($dhcp != "none" && $dhcp != $olddhcp){ if ($olddhcp != ""){ echo "DHCP replace "; print_r($olddhcp); echo " with "; print_r($entrydhcp); echo "<br>"; if ($result = ldap_mod_replace($ds,$hostDN,$entrydhcp)){ + update_dhcpmtime(); $mesg = "Rechner erfolgreich in DHCP <b>".$dhcpcn." [Abt.: ".$dhcpau."]</b> angemeldet<br><br>"; }else{ $mesg = "Fehler beim ändern des DHCP Dienstes zu <b>".$dhcpcn."</b>!<br><br>"; @@ -63,6 +64,7 @@ if ($dhcp != "none" && $dhcp != $olddhcp){ } echo "DHCP add "; print_r($entrydhcp); echo "<br>"; if ($result = ldap_mod_add($ds,$hostDN,$entrydhcp)){ + update_dhcpmtime(); $mesg = "Rechner erfolgreich in DHCP <b>".$dhcpcn." [Abt.: ".$dhcpau."]</b> angemeldet<br><br>"; }else{ $mesg = "Fehler beim ändern des DHCP Dienstes zu <b>".$dhcpcn."</b>!<br><br>"; @@ -78,6 +80,7 @@ if ($dhcp != "none" && $dhcp != $olddhcp){ #} echo "DHCP delete "; echo "<br>"; if ($result = ldap_mod_del($ds,$hostDN,$entrydhcp)){ + update_dhcpmtime(); $mesg = "Rechner erfolgreich aus DHCP gelöscht<br><br>"; }else{ $mesg = "Fehler beim löschen aus DHCP Dienst!<br><br>"; @@ -96,6 +99,7 @@ if ($fixedaddress != "none" && $fixedaddress != $oldfixedaddress){ if ($oldfixedaddress != ""){ echo "Fixed Address ändern"; echo "<br>"; if ($result = ldap_mod_replace($ds,$hostDN,$entryfixadd)){ + update_dhcpmtime(); $mesg = "Option Fixed-Address erfolgreich auf <b>".$fixedaddress."</b> geändert<br><br>"; }else{ $mesg = "Fehler beim ändern der Option Fixed-Address auf <b>".$fixedaddress."</b>!<br><br>"; @@ -103,6 +107,7 @@ if ($fixedaddress != "none" && $fixedaddress != $oldfixedaddress){ }else{ echo "Fixed Address auf IP Adresse setzen"; echo "<br>"; if ($result = ldap_mod_add($ds,$hostDN,$entryfixadd)){ + update_dhcpmtime(); $mesg = "Option Fixed-Address erfolgreich auf <b>".$fixedaddress."</b> gesetzt<br><br>"; }else{ $mesg = "Fehler beim setzen der Option Fixed-Address auf <b>".$fixedaddress."</b>!<br><br>"; @@ -112,6 +117,7 @@ if ($fixedaddress != "none" && $fixedaddress != $oldfixedaddress){ $entryfixadd ['dhcpoptfixed-address'] = array(); echo "No Fixed Address"; echo "<br>"; if ($result = ldap_mod_del($ds,$hostDN,$entryfixadd)){ + update_dhcpmtime(); $mesg = "Option Fixed-Address erfolgreich gelöscht<br><br>"; }else{ $mesg = "Fehler beim löschen der Option Fixed-Address!<br><br>"; diff --git a/ldap-site-mngmt/webinterface/computers/host_change.php b/ldap-site-mngmt/webinterface/computers/host_change.php index f54e149d..a0e149b7 100644 --- a/ldap-site-mngmt/webinterface/computers/host_change.php +++ b/ldap-site-mngmt/webinterface/computers/host_change.php @@ -57,7 +57,7 @@ echo "Host DN:"; print_r($hostDN); echo "<br>"; echo "submenuNR:"; print_r($submenu); echo "<br><br>"; */ -$seconds = 2; +$seconds = 200; $url = 'host.php?dn='.$hostDN.'&sbmnr='.$sbmnr; echo " @@ -255,6 +255,7 @@ if ( $oldip != "" && $ip != "" && $oldip != $ip ){ if ($dhcptype == "subnet"){ adjust_hostip_dhcpsubnet($ip,$hostDN,$dhcphlpcont); } + adjust_hostip_tftpserverip($oldip,$ip); }else{ $mesg = "Fehler beim aendern der IP<br><br>"; # oldip die schon gelöscht wurde wieder einfügen @@ -269,6 +270,7 @@ if ( $oldip != "" && $ip == "" ){ if(delete_ip_host($hostDN,$auDN)){ $mesg = "IP erfolgreich geloescht<br><br>"; + adjust_hostip_tftpserverip($oldip,""); }else{ $mesg = "Fehler beim loeschen der IP<br><br>"; } @@ -388,6 +390,7 @@ if (count($entrydel) != 0 ){ */ +update_dhcpmtime(); $mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br> Falls nicht, klicken Sie hier <a href=".$url." style='publink'>back</a>"; diff --git a/ldap-site-mngmt/webinterface/computers/host_delete.php b/ldap-site-mngmt/webinterface/computers/host_delete.php index bcfa0add..0470ed91 100644 --- a/ldap-site-mngmt/webinterface/computers/host_delete.php +++ b/ldap-site-mngmt/webinterface/computers/host_delete.php @@ -28,6 +28,7 @@ echo " if ( $hostDN != ""){ if ( delete_host($hostDN) ){ + update_dhcpmtime(); $mesg = "Rechner <b>".$hostname."</b> erfolgreich gelöscht!<br><br>"; } else{ diff --git a/ldap-site-mngmt/webinterface/computers/hwhost_change.php b/ldap-site-mngmt/webinterface/computers/hwhost_change.php index 7b93f7c9..678471a4 100644 --- a/ldap-site-mngmt/webinterface/computers/hwhost_change.php +++ b/ldap-site-mngmt/webinterface/computers/hwhost_change.php @@ -22,21 +22,9 @@ if (count($oldattribs) != 0){ } #print_r($oldatts); echo "<br><br>"; -/* -echo "new hostname:"; print_r($hostname); echo "<br>"; -echo "old hostname:"; print_r($oldhostname); echo "<br>"; -echo "new mac:"; print_r($mac); echo "<br>"; -echo "old mac:"; print_r($oldmac); echo "<br>"; -echo "new ip:"; print_r($ip); echo "<br>"; -echo "old ip:"; print_r($oldip); echo "<br>"; -echo "new desc:"; print_r($desc); echo "<br>"; -echo "old desc:"; print_r($olddesc); echo "<br><br>"; -echo "Host DN:"; print_r($hostDN); echo "<br>"; -echo "submenuNR:"; print_r($submenu); echo "<br><br>"; -*/ $seconds = 2; -$url = 'host.php?dn='.$hostDN.'&sbmnr='.$sbmnr; +$url = 'hwhost.php?dn='.$hostDN.'&sbmnr='.$sbmnr; echo " <html> @@ -116,6 +104,7 @@ if (count($entrydel) != 0 ){ } } +update_dhcpmtime(); $mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br> diff --git a/ldap-site-mngmt/webinterface/computers/rbshost_change.php b/ldap-site-mngmt/webinterface/computers/rbshost_change.php index 3a812931..edff80bc 100644 --- a/ldap-site-mngmt/webinterface/computers/rbshost_change.php +++ b/ldap-site-mngmt/webinterface/computers/rbshost_change.php @@ -23,7 +23,7 @@ echo "Host DN:"; print_r($hostDN); echo "<br>"; echo "submenuNR:"; print_r($sbmnr); echo "<br><br>";*/ -$seconds = 40; +$seconds = 2; $url = 'rbshost.php?dn='.$hostDN.'&sbmnr='.$sbmnr; echo " @@ -53,6 +53,7 @@ if ($rbs != "none" && $rbs != $oldrbs){ if ($oldrbs != ""){ echo "RBS replace "; print_r($oldrbs); echo " with "; print_r($entryrbs); echo "<br>"; if ($result = ldap_mod_replace($ds,$hostDN,$entryrbs)){ + update_dhcpmtime(); rbs_adjust_host($hostDN, $rbs); $mesg = "Remote Boot Service erfolgreich zu <b>".$rbscn." [Abt.: ".$rbsau."]</b> geändert<br><br>"; }else{ @@ -61,6 +62,7 @@ if ($rbs != "none" && $rbs != $oldrbs){ }else{ echo "RBS add "; print_r($entryrbs); echo "<br>"; if ($result = ldap_mod_add($ds,$hostDN,$entryrbs)){ + update_dhcpmtime(); rbs_adjust_host($hostDN, $rbs); $mesg = "Remote Boot Service erfolgreich zu <b>".$rbscn." [Abt.: ".$rbsau."]</b> geändert<br><br>"; }else{ @@ -73,6 +75,7 @@ if ($rbs != "none" && $rbs != $oldrbs){ $entryrbs ['dhcpoptfilename'] = array(); echo "RBS delete "; echo "<br>"; if ($result = ldap_mod_del($ds,$hostDN,$entryrbs)){ + update_dhcpmtime(); $mesg = "Rechner erfolgreich aus RBS gelöscht<br><br>"; }else{ $mesg = "Fehler beim löschen aus RBS!<br><br>"; diff --git a/ldap-site-mngmt/webinterface/dhcp/delete_confirm.php b/ldap-site-mngmt/webinterface/dhcp/delete_confirm.php index 62225afc..3bb798b2 100644 --- a/ldap-site-mngmt/webinterface/dhcp/delete_confirm.php +++ b/ldap-site-mngmt/webinterface/dhcp/delete_confirm.php @@ -6,6 +6,7 @@ $name = $_POST['name']; $delurl = $_POST['delurl']; $backurl = $_POST['backurl']; $successurl = $_POST['successurl']; +$mnr = $_POST['mnr']; echo " <html> @@ -23,6 +24,7 @@ echo " <input type='hidden' name='dn' value='".$dn."'> <input type='hidden' name='name' value='".$name."'> <input type='hidden' name='successurl' value='".$successurl."'> + <input type='hidden' name='mnr' value='".$mnr."'> <input type='Submit' name='apply' value='löschen' class='small_loginform_button'><br><br> </form> <form action='".$backurl."' method='post'> diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcp.dwt b/ldap-site-mngmt/webinterface/dhcp/dhcp.dwt index 4aadeba5..0a79961c 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcp.dwt +++ b/ldap-site-mngmt/webinterface/dhcp/dhcp.dwt @@ -52,11 +52,20 @@ <tr valign='top' height='100%'> <td width='28%'> <table cellpadding='5' cellspacing='0' border='0' width='100%'> - <tr><td> + <tr> + <td> - {NAVIGATION} + {NAVIGATION} - </td></tr> + </td> + </tr> + <tr> + <td> + + {IPBLOCKS} + + </td> + </tr> </table> </td> diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcp.php b/ldap-site-mngmt/webinterface/dhcp/dhcp.php index d757ba3b..bd30ba4f 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcp.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcp.php @@ -20,6 +20,8 @@ include('dhcp_header.inc.php'); createMainMenu($rollen, $mainnr); createDhcpMenu($rollen, $mnr, $auDN, $sbmnr); +include("ip_blocks.inc.php"); + ################################################################################### include("dhcp_footer.inc.php"); diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcp_footer.inc.php b/ldap-site-mngmt/webinterface/dhcp/dhcp_footer.inc.php index 311721c5..7849823e 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcp_footer.inc.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcp_footer.inc.php @@ -6,6 +6,7 @@ $template->assign(array("PFAD" => $START_PATH)); $template->parse("LOGIN", "Login"); $template->parse("MAINMENU", "Mmenu"); $template->parse("NAVIGATION", "Menu"); +$template->parse("IPBLOCKS", "IPBlocks"); $template->parse("HAUPTFENSTER", "Webseite"); $template->parse("PAGE", "Vorlage"); diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcp_header.inc.php b/ldap-site-mngmt/webinterface/dhcp/dhcp_header.inc.php index 9eaac019..783c86e6 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcp_header.inc.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcp_header.inc.php @@ -8,6 +8,7 @@ $definedTemplates = array("Vorlage" => "dhcp.dwt", "Login" => "../logout_form.inc.dwt", "Mmenu" => "../hauptmenue.dwt", "Menu" => "menu.dwt", + "IPBlocks" => "ipblocks.dwt", "Webseite" => $webseite); if (isset($additionalTemplates)) { foreach ($additionalTemplates as $templateKey => $templateFile) { diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcp_menu.php b/ldap-site-mngmt/webinterface/dhcp/dhcp_menu.php index f9a6fae6..3e9638ed 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcp_menu.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcp_menu.php @@ -1,57 +1,72 @@ <?php function createDhcpMenu($rollen , $mnr, $auDN, $sbmnr) { - global $template; - global $START_PATH; - # falls keine kompletten Netze delegiert, dann keine DHCP Service und Subnet Links - if (!( check_if_max_networks() )){ - $hauptmenu = array(array("link" => "no_dhcp.php", + global $template, $START_PATH, $rootAU; + + $mipbs = get_maxipblocks_au($auDN); + #echo "MIPB: "; print_r ($mipbs); echo "<br>"; + if ($mipbs[0] != ""){ + $hauptmenu = array(array("link" => "dhcp.php", "text" => "Übersicht", "zugriff" => "alle")); - $submenu = array(array()); }else{ - # DHCP Services (momentan nur für einen DHCP konzipiert) - $dhcpservice_array = get_dhcpservices($auDN,array("dn","cn")); + $hauptmenu = array(array("link" => "no_dhcp.php", + "text" => "Übersicht", + "zugriff" => "alle")); + } + $i=1; + if ( $auDN == $rootAU ) { + $dhcpservice_array = get_dhcpservices($auDN,array("dn","cn")); if (count($dhcpservice_array) == 0){ $dhcpsvlink = "new_dhcpservice.php?mnr=1"; } else { $dhcpsvlink = "dhcpservice.php?mnr=1"; } - $dhcpsubnet_array = get_dhcpsubnets($auDN,array("dn","cn")); - - # Struktur der Registerkartenleiste - $hauptmenu = array(array("link" => "dhcp.php", - "text" => "Übersicht", - "zugriff" => "alle"), - array("link" => $dhcpsvlink, + $hauptmenu []= array("link" => $dhcpsvlink, "text" => "DHCP Service", - "zugriff" => array("MainAdmin","DhcpAdmin")), - array("link" => "dhcpsubnets.php?mnr=2", - "text" => "DHCP Subnets", - "zugriff" => array("MainAdmin","DhcpAdmin"))); - - # DHCP Subnets - $subnets = array(); - for ($i=0;$i<count($dhcpsubnet_array);$i++){ - $subnets[] = array("link" => "dhcpsubnet.php?dn=".$dhcpsubnet_array[$i]['dn']."&mnr=2&sbmnr=".$i, - "text" => $dhcpsubnet_array[$i]['cn'], - "zugriff" => array("MainAdmin","DhcpAdmin")); - } - + "zugriff" => array("MainAdmin","DhcpAdmin")); + $i++; + } + if ($mipbs[0] != ""){ + if ( check_if_max_networks() ){ + $hauptmenu [] = array("link" => "dhcpsubnets.php?mnr=".$i, + "text" => "DHCP Subnets", + "zugriff" => array("MainAdmin","DhcpAdmin")); + + $subnets = array(); # falls komplette Netze verfügbar, link zum Neuanlegen if ( check_if_free_networks() ){ - $subnets[] = array("link" => "new_dhcpsubnet.php?mnr=2&sbmnr=".$i, - "text" => "Neues DHCP Subnet", + #$dhcpsubnet_array = get_dhcpsubnets($auDN,array("dn","cn")); + /*for ($j=0;$j<count($dhcpsubnet_array);$j++){ + $subnets[] = array("link" => "dhcpsubnet.php?dn=".$dhcpsubnet_array[$j]['dn']."&mnr=".$i."&sbmnr=".$j, + "text" => $dhcpsubnet_array[$j]['cn'], + "zugriff" => array("MainAdmin","DhcpAdmin")); + }*/ + $subnets[] = array("link" => "new_dhcpsubnet.php?mnr=".$i."&sbmnr=0", + "text" => "Neues DHCP Subnet anlegen", "zugriff" => array("MainAdmin","DhcpAdmin")); - } - $submenu = array(array(), - array(), - $subnets); - - } - # $rollen = array_keys($roles); + } + $i++; + $hauptmenu [] = array("link" => "dhcppool.php?mnr=".$i, + "text" => "Dynamische DHCP Pools", + "zugriff" => "alle"); + + $submenu = array(array(), + $subnets, + array()); + + }else{ + $hauptmenu [] = array("link" => "dhcppool.php?mnr=".$i, + "text" => "Dynamische DHCP Pools", + "zugriff" => "alle"); + } + } + + #print_r ($hauptmenu);cho "<br>"; + #print_r ($submenu); + #$rollen = array_keys($roles); # Zusammenstellen der Menuleiste $template->define_dynamic("Hauptmenu", "Menu"); @@ -80,29 +95,29 @@ function createDhcpMenu($rollen , $mnr, $auDN, $sbmnr) { else{ if ($j==0) { if ($sbmnr==0) { - if($maxsub == 1){$zwisch="branchbottom2";} - else {$zwisch="branch2";} + if($maxsub == 1){$zwisch="";} + else {$zwisch="";} $lastaktive=true; $farb="#505050"; } else{ - if($maxsub == 1){$zwisch="branchbottom2";} - else {$zwisch="branch2";} + if($maxsub == 1){$zwisch="";} + else {$zwisch="";} $farb="#A0A0A0"; $lastaktive=false; } } else { if ($sbmnr==$j) { - if($maxsub == $j+1){$zwisch="branchbottom2";} - else {$zwisch="branch2";} + if($maxsub == $j+1){$zwisch="";} + else {$zwisch="";} $lastaktive=true; $farb="#505050"; } else { $farb="#A0A0A0"; - if($maxsub == $j+1){$zwisch="branchbottom2";} - else {$zwisch="branch2";} + if($maxsub == $j+1){$zwisch="";} + else {$zwisch="";} # if ($lastaktive) {$zwisch="branch";} # else {$zwisch="branch";} $lastaktive=false; @@ -110,12 +125,12 @@ function createDhcpMenu($rollen , $mnr, $auDN, $sbmnr) { } $htmlcode= " <tr height='4'> - <td></td><td align='right'><img src='../pics/line2.gif' height='4'></td><td></td><td></td> + <td></td><td></td><td></td><td></td> </tr> <tr> <td width='8%'> </td> - <td width='8%' align='right'><img src='../pics/".$zwisch.".gif'></td>
- <td width='74%' align='left' style='border-width:1 1 1 1;border-color:#000000;border-style:solid;padding:2;padding-left:30px;background-color:{FARBE_S}'> + <td width='8%' align='right'>".$zwisch."</td>
+ <td width='74%' align='left' style='border-width:1 1 1 1;border-color:#000000;border-style:solid;padding:2;padding-left:15px;background-color:{FARBE_S}'> <a href='".$item2['link']."' style='text-decoration:none'><b class='standard_schrift'>".$item2['text']."</b></a></td> <td width='10%'> </td> </tr> diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcp_start.dwt b/ldap-site-mngmt/webinterface/dhcp/dhcp_start.dwt index 2e1c0f02..a80c77d7 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcp_start.dwt +++ b/ldap-site-mngmt/webinterface/dhcp/dhcp_start.dwt @@ -7,20 +7,25 @@ </tr> <tr> <td> - <p>Dieses Modul dient der Verwaltung eines DHCP Dienstes und DHCP Subnets, Classes <br> + <p>Modul zur Verwaltung von DHCP Subnets, dynamischen Pools und Classes <br> Benutzen Sie die Navigation links, um die einzelnen Verwaltungsbereiche anzusteuern:</p> <ul> - <li><p><b>DHCP Service</b></p> - ... + <li><p><b>DHCP Subnets</b><br> + Verwalten Sie ihre Subnetze ... </p> </li> - <li><p><b>DHCP Subnets</b></p> - ... + <li><p><b>DHCP Pools</b><br> + Weisen Sie ihren DHCP Subnets IP Ranges zur dynamischen Adressvergabe zu ... </p> </li> - <li><p><b>DHCP Classes</b></p> - ... + <li><p><b>DHCP Classes</b><br> + Verwalten Sie Klassen von DHCP Objekten ...</p> </li> </ul> + <br> + <p>Die Verwaltung von DHCP Hosts, etwa das Eintragen ihrer Rechner im zentralen DHCP Dienst, erfolgt über das<br> + Modul <a class='headerlink' href='../computers/computers.php' >Rechner Management</a>. + + </p> </td> </tr> diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcppool.dwt b/ldap-site-mngmt/webinterface/dhcp/dhcppool.dwt new file mode 100644 index 00000000..0d6a8684 --- /dev/null +++ b/ldap-site-mngmt/webinterface/dhcp/dhcppool.dwt @@ -0,0 +1,106 @@ +<table border='0' cellpadding='5' cellspacing='0' width='100%'> + <tr> + <td colspan='2'><h3>Dynamische DHCP Pools </h3></td> + </tr> + + <tr><td> + <table cellpadding='7' cellspacing='0' border='1' align='left' width='90%' style='border-width: 0 0 0 0;'> + + <form action='dhcppools_change.php' method='post'> + + <tr> + <td width='30%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Subnetz</b></td> + <td width='50%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>IP Ranges (innerhalb Subnetz)</b></td> + <td width='20%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Unknown Clients</b></td> + </tr> + + <!-- BEGIN DYNAMIC BLOCK: Dhcppools --> + <tr height='50' valign='top'> + <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'><b>{SUBNET}/24</b><br><br> + <input type='checkbox' name='delpool[]' value='{POOLDN}' size='10' class='medium_form_field'> + Pool löschen (Häkchen setzen)</td> + + <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> + <!-- BEGIN DYNAMIC BLOCK: Dhcpranges --> + <input type='Text' name='range1[]' value='{RANGE1}' size='15' maxlength='15' class='medium_form_field'> + - + <input type='Text' name='range2[]' value='{RANGE2}' size='15' maxlength='15' class='medium_form_field'> + <input type='hidden' name='oldrange1[]' value='{RANGE1}'> + <input type='hidden' name='oldrange2[]' value='{RANGE2}'><br> + <input type='hidden' name='rangepooldn[]' value='{RPOOLDN}'> + <!-- END DYNAMIC BLOCK: Dhcpranges --> + + <input type='Text' name='addrange1[]' value='' size='15' maxlength='15' class='medium_form_field'> + - + <input type='Text' name='addrange2[]' value='' size='15' maxlength='15' class='medium_form_field'> + </td> + + <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> + <select name='unknownclients[]' size='3' class='small_form_selectbox'> + {UCSELECT} + </select> + <input type='hidden' name='olduc[]' value='{UCNOW}'> + </td> + </tr> + <!--<tr> + <td colspan='3' style='border-color: black; border-style: solid; border-width: 0 0 1 0;'><input type='checkbox' name='delpool[]' value='{POOLDN}' size='10' class='medium_form_field'> + Pool löschen (Häkchen setzen)</td> + </tr>--> + + <input type='hidden' name='pooldn[]' value='{POOLDN}'> + <input type='hidden' name='subnet[]' value='{SUBNET}'> + <!-- END DYNAMIC BLOCK: Dhcppools --> + + <input type='hidden' name='mnr' value='{MNR}'> + + </table></td> + </tr> + <tr> + <td><input type='Submit' name='apply' value='anwenden' class='small_loginform_button'> + </form></td> + </tr> + + <tr> + <td height='50'></td> + </tr> + + <tr> + <td colspan='2'><h4>Dynamischen DHCP Pool hinzufügen </h4></td> + </tr> + <tr> + <td> + <table cellpadding='7' cellspacing='0' border='0' align='left' width='90%' style='border-width: 0 0 0 0;'> + <form action='dhcppool_add.php' method='post'> + + <tr valign='bottom'> + <td width='50%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>IP Range (innerhalb eines Subnetzes)</b><br> + weitere Ranges können später hinzugefügt werden</td> + <td width='50%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Unknown Clients</b></td> + </tr> + + <tr height='50' valign='top'> + <td style='border-color: black; border-style: solid; border-width: 0 0 0 0;'> + <input type='Text' name='addrange1' value='' size='15' maxlength='15' class='medium_form_field'> + - + <input type='Text' name='addrange2' value='' size='15' maxlength='15' class='medium_form_field'> + </td> + <td style='border-color: black; border-style: solid; border-width: 0 0 0 0;'> + <select name='unknownclients' size='3' class='small_form_selectbox'> + <option selected value='deny'> DENY </option> + <option value='allow'> ALLOW </option> + <option value='ignore'> IGNORE </option> + </select> + </td> + </tr> + <input type='hidden' name='mnr' value='{MNR}'> + + </table></td> + </tr> + <tr> + <td> + <input type='Submit' name='apply' value='anlegen' class='small_loginform_button'> + </form></td> + </tr> + + +</table>
\ No newline at end of file diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcppool.php b/ldap-site-mngmt/webinterface/dhcp/dhcppool.php new file mode 100644 index 00000000..dd648f49 --- /dev/null +++ b/ldap-site-mngmt/webinterface/dhcp/dhcppool.php @@ -0,0 +1,132 @@ +<?php +include('../standard_header.inc.php'); + +# 1. Seitentitel - wird in der Titelleiste des Browser angezeigt. +$titel = "DHCP Service Management"; +# 2. Nummer des zugehörigen Hauptmenus (Registerkarte) beginnend bei 0, siehe Dokumentation.doc. +$mainnr = 5; +$mnr = 3; +$sbmnr = -1; +# 3. Dateiname und evtl. Pfad des Templates für die Webseite +$webseite = "dhcppool.dwt"; + +include("../class.FastTemplate.php"); + +include('dhcp_header.inc.php'); + + +################################################################################### + +$mnr = $_GET['mnr']; +$sbmnr = $_GET['sbmnr']; + +# Menuleisten erstellen +createMainMenu($rollen, $mainnr); +createDhcpMenu($rollen, $mnr, $auDN, $sbmnr); + +include("ip_blocks.inc.php"); + +################################################################################### + +$template->assign(array("POOLDN" => "", + "CN" => "", + "SUBNETDN" => "", + "SUBNET" => "", + "RANGE1" => "", + "RANGE2" => "", + "DESCRIPTION" => "", + "STATEMENTS" => "", + "ALLOW" => "", + "DENY" => "", + "IGNORE" => "", + "DEFAULTLEASE" => "", + "MAXLEASE" => "", + "MNR" => $mnr)); + +# DHCP Subnet Daten +#$dhcppoolDN = $_GET['dn']; +$attributes = array("dn","cn","dhcphlpcont","dhcprange","description","dhcpstatements","dhcpoptallow", + "dhcpoptdefault-lease-time","dhcpoptdeny","dhcpoptignore","dhcpoptmax-lease-time", + "dhcpoptgeneric"); +$pools = get_dhcppools($auDN, $attributes); +#print_r($pools); +$template->define_dynamic("Dhcppools", "Webseite"); +$template->define_dynamic("Dhcpranges", "Webseite"); + +foreach ($pools as $pool){ + + $template->clear_parse("DHCPRANGES_LIST"); + + # DHCP Range + if (count($pool['dhcprange']) != 0){ + #$template->define_dynamic("Dhcpranges", "Webseite"); + if (count($pool['dhcprange']) > 1){ + foreach ($pool['dhcprange'] as $dhcprange){ + $iprange = explode('_',$dhcprange); + $template->assign(array( + "RANGE1" => $iprange[0], + "RANGE2" => $iprange[1], + "RPOOLDN" => $pool['dn'])); + $template->parse("DHCPRANGES_LIST", ".Dhcpranges"); + $template->clear_dynamic("Dhcpranges"); + } + }else{ + $iprange = explode('_',$pool['dhcprange']); + $template->assign(array( + "RANGE1" => $iprange[0], + "RANGE2" => $iprange[1], + "RPOOLDN" => $pool['dn'])); + $template->parse("DHCPRANGES_LIST", ".Dhcpranges"); + $template->clear_dynamic("Dhcpranges"); + } + } + + # DHCP Subnet + $subnet = ldap_explode_dn($pool['dhcphlpcont'],1); + + + if ($pool['dhcpoptallow'] == "unknown-clients"){ + $unknownclients = "allow"; + $ucselectbox = "<option selected value='allow'> ALLOW </option> + <option value='deny'> DENY </option> + <option value='ignore'> IGNORE </option>"; + } + elseif ($pool['dhcpoptignore'] == "unknown-clients") { + $unknownclients = "ignore"; + $ucselectbox = "<option selected value='ignore'> IGNORE </option> + <option value='allow'> ALLOW </option> + <option value='deny'> DENY </option>"; + } + else{ + $unknownclients = "deny"; + $ucselectbox = "<option selected value='deny'> DENY </option> + <option value='allow'> ALLOW </option> + <option value='ignore'> IGNORE </option>"; + } + + + $template->assign(array("POOLDN" => $pool['dn'], + "CN" => $pool['cn'], + "SUBNETDN" => $pool['dhcphlpcont'], + "SUBNET" => $subnet[0], + "DESCRIPTION" => $pool['description'], + "STATEMENTS" => $pool['dhcpstatements'], + "UCSELECT" => $ucselectbox, + "UCNOW" => $unknownclients, + "ALLOW" => $pool['dhcpoptallow'], + "DENY" => $pool['dhcpoptdeny'], + "IGNORE" => $pool['dhcpoptignore'], + "DEFAULTLEASE" => $pool['dhcpoptdefault-lease-time'], + "MAXLEASE" => $pool['dhcpoptmax-lease-time'], + "MNR" => $mnr)); + $template->parse("DHCPPOOLS_LIST", ".Dhcppools"); + #$template->clear_dynamic("Dhcppools"); + + +} + +################################################################################### + +include("dhcp_footer.inc.php"); + +?>
\ No newline at end of file diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php b/ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php new file mode 100644 index 00000000..c6cef33a --- /dev/null +++ b/ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php @@ -0,0 +1,98 @@ +<?php +include('../standard_header.inc.php'); + +$syntax = new Syntaxcheck; + +$range1 = $_POST['addrange1']; +$range2 = $_POST['addrange2']; +$unknownclients = $_POST['unknownclients']; +$mnr = $_POST['mnr']; + +$seconds = 200; +$url = "dhcppool.php?mnr=".$mnr; + +echo " +<html> +<head> + <title>Computers Management</title> + <link rel='stylesheet' href='../styles.css' type='text/css'> +</head> +<body> +<table border='0' cellpadding='30' cellspacing='0'> +<tr><td>"; + + +if ($syntax->check_ip_syntax($range1) && $syntax->check_ip_syntax($range2)){ + + $fs = explode('.',$range1); + $fe = explode('.',$range2); + if ( $fs[0] == $fe[0] && $fs[1] == $fe[1] && $fs[2] == $fe[2] ) { + if ( $fs[3] <= $fe[3] ){ + # Range zusammenstellen + $range = implode("_", array($range1,$range2)); + + # Freie IP Bereiche testen + $fipb_array = get_freeipblocks_au($auDN); + for ($i=0; $i < count($fipb_array); $i++){ + if ( split_iprange($range,$fipb_array[$i]) != 0 ){ + $ipranges = split_iprange($range,$fipb_array[$i]); + array_splice($fipb_array, $i, 1, $ipranges); + break; + } + } + if ($i < count($fipb_array) ){ + foreach ( $fipb_array as $item ){ + $entry ['FreeIPBlock'][] = $item; + } + $results = ldap_mod_replace($ds,$auDN,$entry); + if ($results){ + echo "<br>Neue FIPBs erfolgreich eingetragen!<br>"; + + # DHCP Subnet DN finden + $subnet = implode(".", array($fs[0],$fs[1],$fs[2],"0")); + print_r($subnet);echo"<br><br>"; + if(!($result = uniLdapSearch($ds, "ou=RIPM,".$suffix, "(&(objectclass=dhcpSubnet)(cn=$subnet))", array("dn","dhcphlpcont"), "", "sub", 0, 0))) { + # redirect(5, "", $ldapError, FALSE); + echo "no search"; + die; + } + $result = ldapArraySauber($result); + print_r($result);echo "<br><br>"; + if (count($result[0]) != 0){ + $result = add_dhcppool($result[0]['dn'],$range,$unknownclients,$result[0]['dhcphlpcont']); + if ($result){ + echo "<br>Dynamischer DHCP Pool erfolgreich eingetragen!<br>" ; + update_dhcpmtime(); + }else{ + echo "<br>Fehler beim eintragen des dynamischen DHCP Pools!<br>"; + # Range wieder in FIPBs aufnehmen. + $entry2 ['FreeIPBlock'] = $range; + ldap_mod_add($ds,$auDN,$entry2); + merge_ipranges($auDN); + } + }else{ + echo "DHCP Subnet nicht im System vorhanden!<br>"; + } + }else{ + echo "<br>Fehler beim eintragen der FIPBs!<br>"; + } + }else{ + printf("<br>IP Range %s ist nicht im verfuegbaren Bereich!<br>", $range ); + } + }else{ + echo "erster Range Wert grösser als zweiter Range Wert<br>"; + } + }else{ + echo "Range nicht im gleichen Subnetz<br>"; + } +}else{ + echo "falsche IP Syntax<br>"; +} + +$mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br> + Falls nicht, klicken Sie hier <a href=".$url." style='publink'>back</a>"; +redirect($seconds, $url, $mesg, $addSessionId = TRUE); + +echo "</td></tr></table></body> +</html>"; +?>
\ No newline at end of file diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcppools_change.php b/ldap-site-mngmt/webinterface/dhcp/dhcppools_change.php new file mode 100644 index 00000000..b0ed4210 --- /dev/null +++ b/ldap-site-mngmt/webinterface/dhcp/dhcppools_change.php @@ -0,0 +1,277 @@ +<?php +include('../standard_header.inc.php'); + +$syntax = new Syntaxcheck; + +$pooldn = $_POST['pooldn']; +$subnet = $_POST['subnet']; +$delpool = $_POST['delpool']; +$poolranges = array(); +foreach ($pooldn as $dn){ + $poolranges [$dn] = get_dhcppoolranges($dn); +} +$range1 = $_POST['range1']; +$range2 = $_POST['range2']; +$oldrange1 = $_POST['oldrange1']; +$oldrange2 = $_POST['oldrange2']; +$rangepooldn = $_POST['rangepooldn']; +$addrange1 = $_POST['addrange1']; +$addrange2 = $_POST['addrange2']; +$uc = $_POST['unknownclients']; +$olduc = $_POST['olduc']; + +#print_r($pooldn); echo "<br>"; +#print_r($subnet); echo "<br>"; +#print_r($delpool); echo "<br><br>"; +#print_r($oldrange1); echo "<br>"; +#print_r($oldrange2); echo "<br>"; +#print_r($range1); echo "<br>"; +#print_r($range2); echo "<br>"; +#print_r($rangepooldn); echo "<br><br>"; +#print_r($addrange1); echo "<br>"; +#print_r($addrange2); echo "<br><br>"; +#print_r($olduc); echo "<br><br>"; +#print_r($uc); echo "<br><br>"; + +$mnr = $_POST['mnr']; + +$seconds = 2000; +$url = "dhcppool.php?mnr=".$mnr; + +echo " +<html> +<head> + <title>Computers Management</title> + <link rel='stylesheet' href='../styles.css' type='text/css'> +</head> +<body> +<table border='0' cellpadding='30' cellspacing='0'> +<tr><td>"; + + +for ($i=0;$i<count($delpool);$i++){ + # Löschen und Arrays $pooldn, $uc, ... und $rpooldn anpassen zur weiteren Verarbeitung + + $key = array_keys ( $pooldn, $delpool[$i] ); + $key_r = array_keys ( $rangepooldn, $delpool[$i] ); + + # Ranges wieder in FIPBs aufnehmen + if (count($key_r) > 1){ + foreach ($key_r as $item){ + $modentry['FreeIPBlock'][] = $oldrange1[$item]."_".$oldrange2[$item]; + } + }else{ + $modentry['FreeIPBlock'] = $oldrange1[$key_r[0]]."_".$oldrange2[$key_r[0]]; + } + print_r($modentry); echo "<br><br>"; + $add_fipb = ldap_mod_add($ds,$auDN,$modentry); + if ($add_fipb){ + echo "<br>geloeschte IP Range(s) erfolgreich als neuer FIPB in die AU eingetragen!<br>" ; + merge_ipranges($auDN); + + $delete = ldap_delete($ds,$delpool[$i]); + if ($delete){ + # Arrays von gelöschten Pools für weitere Verarbeitung bereinigen + foreach ( $key as $nr ){ + array_splice ( &$pooldn, $nr, 1 ); + array_splice ( &$addrange1, $nr, 1 ); + array_splice ( &$addrange2, $nr, 1 ); + array_splice ( &$uc, $nr, 1 ); + array_splice ( &$olduc, $nr, 1 ); + } + # da sich Arrays verkleinern, Wert in $key_r entsprechend verkleinern, + $j=0; # Variable $j als Zähler um wieviel + foreach ( $key_r as $nr ){ + array_splice ( &$rangepooldn, $nr-$j, 1 ); + array_splice ( &$range1, $nr-$j, 1 ); + array_splice ( &$range2, $nr-$j, 1 ); + array_splice ( &$oldrange1, $nr-$j, 1 ); + array_splice ( &$oldrange2, $nr-$j, 1 ); + $j++; + } + printf("Pool <b>%s</b> erfolgreich gelöscht<br>", $delpool[$i]); + }else{ + printf("Fehler beim Löschen des Pools <b>%s</b>", $delpool[$i]); + } + }else{ + echo "<br>Fehler beim eintragen der geloeschten IP Range(s) als neuen FIPB! <br>DHCP Pool nicht gelöscht<br>"; + } +} + + +for ($i=0;$i<count($pooldn);$i++){ + + $entrydel = array(); + $entryadd = array(); + # DENY, ALLOW, IGNORE Unknown-clients verarbeiten + if ( $uc[$i] != $olduc[$i] ){ + printf("Unknown-Clients für Pool %s ändern<br>", $pooldn[$i]); + $dhcpoptdel = "dhcpopt".$olduc[$i]; + $entrydel [$dhcpoptdel] = array(); + print_r($entrydel); echo "<br>"; + ldap_mod_del($ds,$pooldn[$i],$entrydel); + $dhcpoptadd = "dhcpopt".$uc[$i]; + $entryadd [$dhcpoptadd] = "unknown-clients"; + print_r($entryadd); echo "<br><br>"; + ldap_mod_add($ds,$pooldn[$i],$entryadd); + } + # Ranges hinzufügen + if ( $addrange1[$i] != "" && $addrange2[$i] != "" ){ + if ($syntax->check_ip_syntax($addrange1[$i]) && $syntax->check_ip_syntax($addrange2[$i])){ + $net = strrev(strchr(strrev($subnet[$i]), ".")); + $add1 = strrev(strchr(strrev($addrange1[$i]), ".")); + $add2 = strrev(strchr(strrev($addrange2[$i]), ".")); + if ( $net == $add1 && $net == $add2 ){ + + printf("Range in Pool %s hinzufügen<br>",$pooldn[$i]); + # Range zusammenstellen + $newrange = implode("_", array($addrange1[$i],$addrange2[$i])); + $result = add_dhcprange($newrange,$pooldn[$i]); + if ($result){ + printf("Neue dynamische IP Range %s - %s erfolgreich in Subnetz %s0 eingetragen!<br>",$addrange1[$i],$addrange2[$i],$net); + }else{ + echo "<br>Fehler beim eintragen des dynamischen DHCP Pools!<br>"; + } + + }else{ + printf("Neue Range %s - %s nicht in Subnetz %s0",$addrange1[$i],$addrange2[$i],$net); + } + }else{ + printf("falsche IP Syntax der neuen Range %s - %s<br>", $addrange1[$i],$addrange2[$i]); + } + } + +} + +# bereits angelegte Ranges verarbeiten (löschen, verkleinern, vergrößern) +$fipbs = get_freeipblocks_au($auDN); +$new_fipbs ['freeipblock'] = $fipbs; +$mod_dhcpranges = array(); + +for ($i=0;$i<count($rangepooldn);$i++){ + + $range = implode('_',array($range1[$i],$range2[$i])); + $oldrange = implode('_',array($oldrange1[$i],$oldrange2[$i])); + + if ( $oldrange1[$i] != "" && $oldrange2[$i] != "" && $range1[$i] == "" && $range2[$i] == "" ){ + # Range löschen + $mod_dhcpranges [$rangepooldn[$i]] = $poolranges [$rangepooldn[$i]]; + $range_key = array_search ( $oldrange, $mod_dhcpranges[$rangepooldn[$i]] ); + #print_r($range_key); echo "<br>"; + array_splice ( &$mod_dhcpranges[$rangepooldn[$i]], $range_key, 1 ); + array_splice ( &$poolranges[$rangepooldn[$i]], $range_key, 1 ); + $new_fipbs ['freeipblock'][] = $oldrange; + } + elseif ( $oldrange1[$i] != "" && $oldrange2[$i] != "" && $range1[$i] != "" && $range2[$i] != "" ){ + $or1 = ip2long($oldrange1[$i]); + $or2 = ip2long($oldrange2[$i]); + $nr1 = ip2long($range1[$i]); + $nr2 = ip2long($range2[$i]); + + if ( ($nr1 > $or1 || $nr2 < $or2) && !($nr1 < $or1 || $nr2 > $or2) ){ + if ($syntax->check_ip_syntax($range1[$i]) && $syntax->check_ip_syntax($range2[$i])){ + # Range verkleinern + $diffrange = split_iprange($range,$oldrange); + echo "<br>diffrange: "; print_r($diffrange); echo "<br>"; + # array $poolranges aktualisieren (neue Ranges) + $mod_dhcpranges [$rangepooldn[$i]] = $poolranges [$rangepooldn[$i]]; + $range_key = array_search ( $oldrange, $mod_dhcpranges [$rangepooldn[$i]] ); + #print_r($range_key); echo "<br>"; + $poolranges [$rangepooldn[$i]][$range_key] = $range; + $mod_dhcpranges [$rangepooldn[$i]][$range_key] = $range; + + foreach ($diffrange as $dr){ + $new_fipbs ['freeipblock'][] = $dr; + } + }else{ + printf("falsche IP Syntax der neuen Range %s - %s<br>", $range1[$i],$range2[$i]); + } + } + elseif( ($nr1 < $or1 || $nr2 > $or2) && !($nr1 > $or1 || $nr2 < $or2) ){ + if ($syntax->check_ip_syntax($range1[$i]) && $syntax->check_ip_syntax($range2[$i])){ + # Range vergrößern + $addrange = split_iprange($oldrange,$range); + echo "addrange: "; print_r($addrange); echo "<br>"; + $mod_dhcpranges [$rangepooldn[$i]] = $poolranges [$rangepooldn[$i]]; + + foreach ($addrange as $ar){ + $test = 0; + for ($c=0; $c < count($new_fipbs['freeipblock']); $c++){ + if ( split_iprange($ar,$new_fipbs['freeipblock'][$c]) != 0 ){ + $ipranges = split_iprange($ar,$new_fipbs['freeipblock'][$c]); + array_splice($new_fipbs['freeipblock'], $c, 1, $ipranges); + $test = 1; + break; + } + } + if ( $test ){ + $poolranges [$rangepooldn[$i]][] = $ar; + $mod_dhcpranges [$rangepooldn[$i]][] = $ar; + } + } + }else{ + printf("falsche IP Syntax der neuen Range %s - %s<br>", $range1[$i],$range2[$i]); + } + } + #else{ + # $mesg = "<br>Verschieben (Shiften) einer IP Range nicht moeglich!<br> + # Nur Vergroessern und Verkleinern moeglich!<br>"; + # $mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br> + # Falls nicht, klicken Sie hier <a href='dhcppool.php' style='publink'>back</a>"; + # redirect($seconds, $url, $mesg, $addSessionId = TRUE); + #} + } +} + +#print_r($mod_dhcpranges); echo "<br>"; +#print_r($new_fipbs); echo "<br><br>"; +$keys = array_keys($mod_dhcpranges); +foreach ($keys as $pdn){ + #print_r($pdn); echo "<br>"; + #print_r($mod_dhcpranges[$pdn]); echo "<br>"; + if ( count($mod_dhcpranges[$pdn]) == 0 ){ + printf("Pool %s löschen<br>",$pdn); + if ($res = ldap_delete($ds,$pdn)){ + printf("Pool %s erfolgreich gelöscht",$pdn); + }else{ + printf("Fehler beim Löschen von %s",$pdn); + } + }else{ + echo "Pool Ranges anpassen<br>"; + foreach ($mod_dhcpranges[$pdn] as $rg){ + $modpool ['dhcprange'][] = $rg; + } + #print_r($modpool); echo "<br>"; + $modpool ['dhcprange'] = merge_ipranges_array($modpool ['dhcprange']); + print_r($modpool); echo "<br>"; + if ($res = ldap_mod_replace($ds,$pdn,$modpool)){ + printf("Pool Ranges von %s erfolgreich angepasst",$pdn); + }else{ + printf("Fehler beim Anpassen der Pool Ranges von %s",$pdn); + } + } +} + +$diff = array_diff( $new_fipbs['freeipblock'], $fipbs ); +$revdiff = array_diff( $fipbs, $new_fipbs['freeipblock'] ); +if ( count($diff) != 0 || count($revdiff) != 0 ){ + echo "<br>FIPBS anpassen<br>"; + #print_r($new_fipbs['freeipblock']); echo "<br>"; + $new_fipbs['freeipblock'] = merge_ipranges_array($new_fipbs['freeipblock']); + print_r($new_fipbs); echo "<br>"; + if ($res = ldap_mod_replace($ds,$auDN,$new_fipbs)){ + printf("FIPBs erfolgreich angepasst"); + }else{ + printf("Fehler beim Anpassen der FIPBs"); + } +} +# DHCP Modify Timestamp festhalten +update_dhcpmtime(); + +$mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br> + Falls nicht, klicken Sie hier <a href=".$url." style='publink'>back</a>"; +redirect($seconds, $url, $mesg, $addSessionId = TRUE); + +echo "</td></tr></table></body> +</html>"; +?>
\ No newline at end of file diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpservice.php b/ldap-site-mngmt/webinterface/dhcp/dhcpservice.php index 144ae183..388f01ff 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpservice.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpservice.php @@ -22,6 +22,8 @@ $mnr = $_GET['mnr']; createMainMenu($rollen, $mainnr); createDhcpMenu($rollen, $mnr, $auDN, $sbmnr); +include("ip_blocks.inc.php"); + ################################################################################### $template->assign(array("DHCPDN" => "", diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpservice_add.php b/ldap-site-mngmt/webinterface/dhcp/dhcpservice_add.php index bcb5899e..ecaa27d9 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpservice_add.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpservice_add.php @@ -19,7 +19,7 @@ $sbmnr = $_POST['sbmnr']; $mcnr = $_POST['mcnr']; $get_dhcpcn = str_replace ( " ", "_", $cn ); -$seconds = 200; +$seconds = 2; $url = "new_dhcpservice.php?&mnr=1"; echo " diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpservice_change.php b/ldap-site-mngmt/webinterface/dhcp/dhcpservice_change.php index 55e51cd9..4b17dec9 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpservice_change.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpservice_change.php @@ -35,7 +35,7 @@ $mcnr = $_POST['mcnr']; #$deltr = $_POST['deltr']; -$seconds = 200; +$seconds = 2; $url = "dhcpservice.php?dn=".$dhcpdn."&mnr=1"; echo " @@ -133,6 +133,7 @@ if ( $adddhcpoptdefinition != "" ){ $entryadd['optiondefinition'] = $adddhcpoptdefinition; if(ldap_mod_add($ds,$dhcpDN,$entryadd)){ $mesg = "Selbst-definierte DHCP Option erfolgreich eingetragen<br><br>"; + update_dhcpmtime(); }else{ $mesg = "Fehler beim eintragen Selbst-definierte DHCP Option<br><br>"; } @@ -175,6 +176,7 @@ if (count($entryadd) != 0 ){ } if(ldap_mod_add($ds,$dhcpDN,$entryadd)){ $mesg = "Attribute ".$addatts." erfolgreich eingetragen<br><br>"; + update_dhcpmtime(); }else{ $mesg = "Fehler beim eintragen der Attribute ".$addatts."<br><br>"; } @@ -186,6 +188,7 @@ if (count($entrymod) != 0 ){ } if(ldap_mod_replace($ds,$dhcpDN,$entrymod)){ $mesg = "Attribute ".$modatts." erfolgreich geaendert<br><br>"; + update_dhcpmtime(); }else{ $mesg = "Fehler beim aendern der Attribute ".$modatts."<br><br>"; } @@ -197,6 +200,7 @@ if (count($entrydel) != 0 ){ } if(ldap_mod_del($ds,$dhcpDN,$entrydel)){ $mesg = "Attribute ".$delatts." erfolgreich geloescht<br><br>"; + update_dhcpmtime(); }else{ $mesg = "Fehler beim loeschen der Attribute ".$delatts."<br><br>"; } diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpservice_delete.php b/ldap-site-mngmt/webinterface/dhcp/dhcpservice_delete.php index 36260cd1..3d121397 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpservice_delete.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpservice_delete.php @@ -4,7 +4,7 @@ include('../standard_header.inc.php'); $dhcpDN = $_POST['dn']; $dhcpcn = $_POST['name']; -$seconds = 100; +$seconds = 2; $url = "dhcpservice.php?mnr=1"; echo " diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet.dwt b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet.dwt index d35b3d30..0f16f966 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet.dwt +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet.dwt @@ -1,9 +1,11 @@ <table border='0' cellpadding='5' cellspacing='0' width='100%'> + <tr> - <td colspan='2'><h3>DHCP Subnet <code class='font_object'> {CN} </code> </h3></td> + <td colspan='4' height='20'><h4><a href='dhcpsubnets.php?mnr={MNR}' class='headerlink'><< Zurück zur Übersicht </a></h4></td> </tr> + <tr> - <td height='20'></td> + <td colspan='2'><h3>DHCP Subnet <code class='font_object'> {CN} </code> </h3></td> </tr> <tr><td> <table cellpadding='7' cellspacing='0' border='1' align='left' width='90%' style='border-width: 0 0 0 0;'> @@ -31,7 +33,7 @@ </tr> <tr valign='top'> <td style='border-color: black; border-style: solid; border-width: 0 0 0 0;'><b>Eingebunden in DHCP Dienst: <b></td> - <td style='border-color: black; border-style: solid; border-width: 0 0 0 0;'>Service <b>{DHCPSVNOW}</b> / AU <b>{DHCPSVNOWAU}</b> + <td style='border-color: black; border-style: solid; border-width: 0 0 0 0;'>{DHCPSVNOW} </td> </tr> <tr height='50' valign='top'> @@ -60,7 +62,7 @@ </table></td> </tr> - <tr> + <!--<tr> <td height='40'></td> </tr> <tr> @@ -88,7 +90,7 @@ <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> </td> </tr> </table></td> - </tr> + </tr>--> <tr> <td height='40'></td> @@ -96,9 +98,6 @@ <tr> <td colspan='2'><h4>DHCP Optionen des Subnets (Subnet Scope):</h4></td> </tr> - <tr> - <td height='10'></td> - </tr> <tr><td> <table cellpadding='7' cellspacing='0' border='1' align='left' width='90%' style='border-width: 0 0 0 0;'> @@ -203,6 +202,7 @@ <input type='hidden' name='dn' value='{SUBNETDN}'> <input type='hidden' name='name' value='{CN}'> + <input type='hidden' name='mnr' value='{MNR}'> <input type='hidden' name='type' value='dhcp'> <input type='hidden' name='delurl' value='dhcpsubnet_delete.php'> <input type='hidden' name='backurl' value='dhcpsubnet.php?dn={SUBNETDN}&mnr={MNR}&sbmnr{SBMNR}'> diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet.php b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet.php index 235667aa..ee3338ef 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet.php @@ -5,7 +5,7 @@ include('../standard_header.inc.php'); $titel = "DHCP Service Management"; # 2. Nummer des zugehörigen Hauptmenus (Registerkarte) beginnend bei 0, siehe Dokumentation.doc. $mainnr = 5; -$mnr = 0; +$mnr = -1; $sbmnr = -1; # 3. Dateiname und evtl. Pfad des Templates für die Webseite $webseite = "dhcpsubnet.dwt"; @@ -17,12 +17,14 @@ include('dhcp_header.inc.php'); ################################################################################### $mnr = $_GET['mnr']; -$sbmnr = $_GET['sbmnr']; +#$sbmnr = $_GET['sbmnr']; # Menuleisten erstellen createMainMenu($rollen, $mainnr); createDhcpMenu($rollen, $mnr, $auDN, $sbmnr); +include("ip_blocks.inc.php"); + ################################################################################### $template->assign(array("SUBNETDN" => "", @@ -50,7 +52,6 @@ $template->assign(array("SUBNETDN" => "", "OPTGENERIC" => "", "DHCPOFFERNOWDN" => "", "DHCPSVNOW" => "", - "DHCPSVNOWAU" => "", "MNR" => $mnr, "SBMNR" => $sbmnr, "MCNR" => $mcnr)); @@ -67,7 +68,12 @@ $subnet_data = get_node_data($dhcpsubnetDN, $attributes); #print_r($subnet_data); # momentane DHCP Service Zuordnung -$dhcpsvnowdn = ldap_explode_dn($subnet_data['dhcphlpcont'], 1); +if ($subnet_data['dhcphlpcont'] != ""){ + $dhcpsvnowdn = ldap_explode_dn($subnet_data['dhcphlpcont'], 1); + $dhcpsvnow = "<b>".$dhcpsvnowdn[0]."</b> [AU: ".$dhcpsvnowdn[2]."]"; +}else{ + $dhcpsvnow = "<b>–</b>"; +} # DHCP Range $iprange = explode('_',$subnet_data['dhcprange']); @@ -96,8 +102,7 @@ $template->assign(array("SUBNETDN" => $dhcpsubnetDN, "NTPSERVERS" => $subnet_data['dhcpoptntp-servers'], "OPTGENERIC" => $subnet_data['dhcpoptgeneric'], "DHCPOFFERNOWDN" => $subnet_data['dhcphlpcont'], - "DHCPSVNOW" => $dhcpsvnowdn[0], - "DHCPSVNOWAU" => $dhcpsvnowdn[2], + "DHCPSVNOW" => $dhcpsvnow, "MNR" => $mnr, "SBMNR" => $sbmnr, "MCNR" => $mcnr)); @@ -110,7 +115,7 @@ $template->assign(array("DHCPSVDN" => "", "DHCPSVCN" => "", "DHCPSVAU" => "")); if (count($altdhcp) != 0){ -$template->define_dynamic("Dhcpservices", "Webseite"); + $template->define_dynamic("Dhcpservices", "Webseite"); foreach ($altdhcp as $item){ $template->assign(array("DHCPSVDN" => $item['dn'], "DHCPSVCN" => $item['cn'], diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_add.php b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_add.php index 6939afe0..5fdc0dec 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_add.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_add.php @@ -3,12 +3,17 @@ include('../standard_header.inc.php'); $syntax = new Syntaxcheck; -$cn = $_POST['cn']; -$netmask = $_POST['netmask']; -$dhcpservice = $_POST['dhcpservice']; -$range1 = $_POST['range1']; -$range2 = $_POST['range2']; +$subnet = $_POST['dhcpsubnet']; +$subnetexp = explode("|",$subnet); +$cn = $subnetexp[0]; +$netmask = $subnetexp[1]; +#print_r($subnet); echo "<br><br>"; +#print_r($cn); echo "<br><br>"; +#print_r($netmask); echo "<br><br>"; +$dhcpservice = $_POST['dhcpservice']; +#$range1 = $_POST['range1']; +#$range2 = $_POST['range2']; # sonstige Attribute $attribs = $_POST['attribs']; if (count($attribs) != 0){ @@ -23,7 +28,7 @@ $mnr = $_POST['mnr']; $sbmnr = $_POST['sbmnr']; $get_dhcpcn = str_replace ( " ", "_", $cn ); -$seconds = 200; +$seconds = 2; $url = "new_dhcpsubnet.php?&mnr=2"; echo " @@ -40,16 +45,16 @@ if ( $cn != "" && $cn != "Hier_Subnetz_eintragen" && $netmask != "" && $netmask if ( $syntax->check_netip_syntax($cn) && $syntax->check_ip_syntax($netmask) ){ - if (add_dhcpsubnet ($cn,$dhcpservice,$netmask,$range1,$range2,$atts)){ + if (add_dhcpsubnet ($cn,$dhcpservice,$netmask,$atts)){ $mesg .= "<br>DHCP Subnet erfolgreich angelegt<br>"; - $url = "dhcpsubnets.php?mnr=2"; + $url = "dhcpsubnets.php?mnr=".$mnr; }else{ $mesg .= "<br>Fehler beim anlegen des DHCP Subnets!<br>"; } }else{ $mesg .= "Falsche IP Syntax! Geben Sie eine korrekte IP Adresse als Subnet Name oder Netzmaske ein."; - $url = "new_dhcpsubnet.php?subnetcn=Hier_Subnetz_eintragen&netmask=".$netmask."&mnr=2"; + $url = "new_dhcpsubnet.php?subnetcn=Hier_Subnetz_eintragen&netmask=".$netmask."&mnr=".$mnr; } } @@ -59,7 +64,7 @@ elseif ( $cn == "" || $cn == "Hier_Subnetz_eintragen" || $netmask == "" || $netm if ( $netmask == ""){ $netmask = "Hier_Netzmaske_eintragen";} $mesg = "Sie haben die notwendigen Attribute: Name (IP) und Netzmaske des neuen DHCP Subnets nicht angegeben.<br> Bitte geben Sie fehlende ein.<br><br>"; - $url = "new_dhcpsubnet.php?subnetcn=".$cn."&netmask=".$netmask."&mnr=2"; + $url = "new_dhcpsubnet.php?subnetcn=".$cn."&netmask=".$netmask."&mnr=".$mnr; } $mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br> diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_change.php b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_change.php index b0dc13c7..ded54e2c 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_change.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_change.php @@ -37,7 +37,7 @@ $mnr = $_POST['mnr']; $sbmnr = $_POST['sbmnr']; $mcnr = $_POST['mcnr']; -$seconds = 200; +$seconds = 2; $url = "dhcpsubnet.php?dn=".$subnetDN."&mnr=".$mnr."&sbmnr=".$sbmnr; echo " @@ -283,6 +283,8 @@ if (count($entrydel) != 0 ){ } +update_dhcpmtime(); + $mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br> Falls nicht, klicken Sie hier <a href=".$url." style='publink'>back</a>"; redirect($seconds, $url, $mesg, $addSessionId = TRUE); diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_delete.php b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_delete.php index eb5d66aa..5bbe10d0 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_delete.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnet_delete.php @@ -3,9 +3,10 @@ include('../standard_header.inc.php'); $subnetDN = $_POST['dn']; $cn = $_POST['name']; +$mnr = $_POST['mnr']; -$seconds = 100; -$url = "dhcpsubnets.php?mnr=2"; +$seconds = 1; +$url = "dhcpsubnets.php?mnr=".$mnr; echo " <html> @@ -20,6 +21,7 @@ echo " if ( $subnetDN != ""){ if( delete_dhcpsubnet($subnetDN,$cn)){ $mesg = "Subnet <b>".$cn."</b> erfolgreich gelöscht!<br><br>"; + update_dhcpmtime(); }else{ $mesg = "Fehler beim löschen des Subnets <b>".$cn."</b> !<br><br>"; } diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnets.dwt b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnets.dwt index e887509d..76c2913f 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnets.dwt +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnets.dwt @@ -3,30 +3,22 @@ <td colspan='2'><h3>DHCP Subnets</h3> </td> </tr> - <tr> - <td height='10'></td> - </tr> + <tr><td> <table cellpadding='7' cellspacing='0' border='1' align='left' width='90%' style='border-width: 0 0 0 0;'> <tr> <td width='15%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Subnet</b></td> - <td width='20%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Netmask</b></td> - <td width='25%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>DHCP Dienst</b></td> - <td width='25%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Range</b></td> - <td width='15%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Hostobjekte</b></td> + <td width='15%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Netmask</b></td> + <td width='25%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>DHCP Service</b></td> + <td width='45%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Dynamic Pools (IP Ranges)</b></td> </tr> <!-- BEGIN DYNAMIC BLOCK: Subnets --> - <tr height='50'> + <tr height='45' valign='top'> <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>{SUBNETCN} </td> <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>{NETMASK} </td> <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>{DHCP} </td> - <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>{RANGE} </td> - <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> - <!-- BEGIN DYNAMIC BLOCK: Hosts --> - <b>{HOSTS}</b><br> - <!-- END DYNAMIC BLOCK: Hosts --> - </td> + <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>{POOLS} </td> </tr> <!-- END DYNAMIC BLOCK: Subnets --> diff --git a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnets.php b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnets.php index 1104f496..d0d61aa5 100644 --- a/ldap-site-mngmt/webinterface/dhcp/dhcpsubnets.php +++ b/ldap-site-mngmt/webinterface/dhcp/dhcpsubnets.php @@ -6,7 +6,7 @@ include('../standard_header.inc.php'); $titel = "DHCP Service Management"; # 2. Nummer des zugehörigen Hauptmenus (Registerkarte) beginnend bei 0, siehe Dokumentation.doc. $mainnr = 5; -$mnr = 2; +$mnr = -1; $sbmnr = -1; $mcnr = -1; # 3. Dateiname und evtl. Pfad des Templates für die Webseite @@ -18,42 +18,73 @@ include('dhcp_header.inc.php'); ################################################################################### +$mnr = $_GET['mnr']; + # Menuleisten erstellen createMainMenu($rollen, $mainnr); createDhcpMenu($rollen, $mnr, $auDN, $sbmnr); +include("ip_blocks.inc.php"); + ################################################################################### $template->assign(array("SUBNETDN" => "", "SUBNETCN" => "Noch keine Subnets angelegt", "NETMASK" => "", "DHCP" => "", - "RANGE" => "", - "HOSTS" => "")); + "POOLS" => "")); # rbservice und pxe daten (voerst nur ein rbs) $subnet_array = get_dhcpsubnets($auDN,array("dn","cn","dhcpoptnetmask","dhcprange","dhcphlpcont")); $template->define_dynamic("Subnets", "Webseite"); +$template->define_dynamic("Pools", "Webseite"); + foreach ($subnet_array as $subnet){ - $range = ""; - if ($subnet['dhcprange'] != ""){ - $exp = explode('_',$subnet['dhcprange']); - $range = $exp[0]." - ".$exp[1]; + # Pools des Subnetzes + $pools = get_dhcppools_subnet($subnet['dn'],array("dhcprange","dhcpoptallow","dhcpoptdeny","dhcpoptignore")); + #print_r($pools); echo "<br><br>"; + $poollist = "<ul>"; + foreach ($pools as $pool){ + $poollist .= "<li>"; + if (count($pool['dhcprange']) >1){ + for ($i=0; $i<count($pool['dhcprange']); $i++){ + $range = explode('_',$pool['dhcprange'][$i]); + $poollist .= $range[0]." - ".$range[1]; + if ($i+1 != count($pool['dhcprange'])){ + $poollist .= "<br>"; + } + } + }else{ + $range = explode('_',$pool['dhcprange']); + $poollist .= $range[0]." - ".$range[1]; + } + if ($pool['dhcpoptallow'] != ""){ + $poollist .= "<br>ALLOW ".$pool['dhcpoptallow']; + } + if ($pool['dhcpoptignore'] != ""){ + $poollist .= "<br>IGNORE ".$pool['dhcpoptignore']; + } + if ($pool['dhcpoptdeny'] != ""){ + $poollist .= "<br>DENY ".$pool['dhcpoptdeny']; + } + $poollist .= " [Abt.: ".$pool['poolAU']."]</li><br>"; } + $poollist .= "</ul>"; + + # Dienstzuordnung des Subnetzes + $dhcpservice = ""; if ($subnet['dhcphlpcont'] != ""){ $exp = ldap_explode_dn($subnet['dhcphlpcont'],1); $dhcpservice = $exp[0]." [".$exp[2]."]"; - }else{ - $dhcpservice = ""; } + $subnetcn = "<a href='dhcpsubnet.php?dn=".$subnet['dn']."&mnr=".$mnr."' class='headerlink'><b>".$subnet['cn']."</b></a>"; $template->assign(array("SUBNETDN" => $subnet['dn'], - "SUBNETCN" => $subnet['cn'], + "SUBNETCN" => $subnetcn, "NETMASK" => $subnet['dhcpoptnetmask'], "DHCP" => $dhcpservice, - "RANGE" => $range, - "HOSTS" => "")); + "POOLS" => $poollist)); $template->parse("SUBNETS_LIST", ".Subnets"); } diff --git a/ldap-site-mngmt/webinterface/dhcp/ip_blocks.inc.php b/ldap-site-mngmt/webinterface/dhcp/ip_blocks.inc.php new file mode 100644 index 00000000..8530e079 --- /dev/null +++ b/ldap-site-mngmt/webinterface/dhcp/ip_blocks.inc.php @@ -0,0 +1,68 @@ +<?php + +# Max und Free IP Blocks +$mipb_array = get_maxipblocks_au($auDN); +$fipb_array = get_freeipblocks_au($auDN); +#print_r(count($mipb_array)); echo "<br>"; +#print_r(count($fipb_array)); echo "<br>"; +$ipblocks = ""; + +# print_r($mipb_array); +if ($mipb_array[0] != "" ){ + if (count($mipb_array) > 1 ){ + $ipblocks .= "<table border='1' cellpadding='2' cellspacing='0' width='100%' style='border-width: 0 0 0 0;'> + <tr><td colspan='3' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'> + <h4>Zugewiesene IP Bereiche:</h4></td></tr>"; + foreach ($mipb_array as $mipb){ + $exp = explode('_',$mipb); + $ipblocks .= "<tr><td width='45%' style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>$exp[0] </td> + <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> - </td> + <td width='45%' style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>$exp[1] </td></td></tr>"; + } + } + elseif (count($mipb_array) == 1){ + $ipblocks .= "<table border='1' cellpadding='2' cellspacing='0' width='100%' style='border-width: 0 0 0 0;'> + <tr><td colspan='3' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'> + <h4>Zugewiesener IP Bereich:</h4></td></tr>"; + $exp = explode('_',$mipb_array[0]); + $ipblocks .= "<tr><td width='45%' style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>$exp[0] </td> + <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> - </td> + <td width='45%' style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>$exp[1] </td></tr>"; + } + elseif( $fipb_array[0] == "" ){ + $ipblocks .= "<table border='0' cellpadding='2' cellspacing='0' width='100%' style='border-width: 0 0 0 0;'> + <tr><td><h4>Keine IP Adressen mehr verfügbar</h4></td></tr>"; + } + if (count($fipb_array) > 1 ){ + $ipblocks .= "<table border='1' cellpadding='2' cellspacing='0' width='100%' style='border-width: 0 0 0 0;'> + <tr valign='bottom' height='50'> + <td colspan='3' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'> + <h4>Davon noch frei verfügbar:</h4></td></tr>"; + foreach ($fipb_array as $fipb){ + $exp = explode('_',$fipb); + $ipblocks .= "<tr><td width='45%' style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>$exp[0] </td> + <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> - </td> + <td width='45%' style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>$exp[1] </td></tr>"; + } + } + elseif (count($fipb_array) == 1){ + $ipblocks .= "<table border='1' cellpadding='2' cellspacing='0' width='100%' style='border-width: 0 0 0 0;'> + <tr><td colspan='3' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'> + <h4>Davon noch frei verfügbar:</h4></td></tr>"; + $exp = explode('_',$fipb_array[0]); + $ipblocks .= "<tr><td width='45%' style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>$exp[0] </td> + <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> - </td> + <td width='45%' style='border-color: black; border-style: solid; border-width: 0 0 1 0;'>$exp[1] </td></tr>"; + } + +} + +if( $mipb_array[0] == "" ){ + $ipblocks .= "<table border='0' cellpadding='2' cellspacing='0' width='100%' style='border-width: 0 0 0 0;'> + <tr><td><h4>Ihnen wurden keine IP Adressen zugewiesen</h4></td></tr>"; +} +$ipblocks .= "</table>"; + +$template->assign(array("IPBLOCKS" => $ipblocks)); + +?>
\ No newline at end of file diff --git a/ldap-site-mngmt/webinterface/dhcp/ipblocks.dwt b/ldap-site-mngmt/webinterface/dhcp/ipblocks.dwt new file mode 100644 index 00000000..b77f53b3 --- /dev/null +++ b/ldap-site-mngmt/webinterface/dhcp/ipblocks.dwt @@ -0,0 +1,11 @@ +<table cellpadding='5' cellspacing='0' border='1' width='100%' style='border-width: 0 0 0 0;'> + + <tr align='left'>
+ <td width='8%'></td>
+ <td width='82%' style='border-color: black; border-style: solid; border-width: 1 1 1 1;'>{IPBLOCKS}</td> + <td width='10%'></td> + + </tr> + <tr height='5'></tr>
+ +</table>
\ No newline at end of file diff --git a/ldap-site-mngmt/webinterface/dhcp/new_dhcpsubnet.dwt b/ldap-site-mngmt/webinterface/dhcp/new_dhcpsubnet.dwt index 8b710fb8..7cf7f42c 100644 --- a/ldap-site-mngmt/webinterface/dhcp/new_dhcpsubnet.dwt +++ b/ldap-site-mngmt/webinterface/dhcp/new_dhcpsubnet.dwt @@ -11,26 +11,27 @@ <form action='dhcpsubnet_add.php' method='post'> <tr> - <td width='40%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Attribut</b></td> - <td width='60%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Wert</b></td> + <td width='30%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Attribut</b></td> + <td width='70%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Wert</b></td> </tr> - <tr height='50'> - <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'><b>DHCP Subnet (cn):</b><br>(Teil des dn, ohne Leerzeichen eingeben) </td> - <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> - <input type='Text' name='cn' value='{CN}' size='15' maxlength='15' class='medium_form_field'> - </td> - </tr> - <tr height='50'> - <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'><b>Netmask:</b></td> + <tr height='50' valign='top'> + <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'><b>DHCP Subnet (+ Netmask):</b><br> + (Noch freie verfügbare Netze) </td> <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> - <input type='Text' name='netmask' value='{NETMASK}' size='15' maxlength='15' class='medium_form_field'> + <select name='dhcpsubnet' size='{SUBLIST}' class='medium_form_selectbox'> + + <!-- BEGIN DYNAMIC BLOCK: Dhcpsubnets --> + <option value='{SUBNET}'>{CN} / {NETMASK}</option> + <!-- END DYNAMIC BLOCK: Dhcpsubnets --> + + </select> </td> </tr> <tr height='50' valign='top'> <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'><b>DHCP Dienst wählen:</b> </td> <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> - <select name='dhcpservice' size='5' class='medium_form_selectbox'> + <select name='dhcpservice' size='{SRVLIST}' class='medium_form_selectbox'> <option selected value='none'>----------</option> <!-- BEGIN DYNAMIC BLOCK: Dhcpservices --> @@ -46,14 +47,14 @@ <input type='Text' name='attribs[description]' value='{DESCRIPTION}' size='50' class='medium_form_field'> </td> </tr> - <tr height='50'> + <!--<tr height='50'> <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'><b>IP Range:</b><br>(Zur dynamischen Vergabe)</td> <td style='border-color: black; border-style: solid; border-width: 0 0 1 0;'> <input type='Text' name='range1' value='{RANGE1}' size='15' maxlength='15' class='medium_form_field'> - <input type='Text' name='range2' value='{RANGE2}' size='15' maxlength='15' class='medium_form_field'> </td> - </tr> + </tr>--> </table></td> </tr> @@ -71,8 +72,8 @@ <table cellpadding='7' cellspacing='0' border='1' align='left' width='90%' style='border-width: 0 0 0 0;'> <tr valign='top'> - <td width='40%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Option</b></td> - <td width='60%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Wert(e)</b></td> + <td width='30%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Option</b></td> + <td width='70%' style='border-color: black; border-style: solid; border-width: 0 0 3 0;'><b>Wert(e)</b></td> </tr> <tr height='50'> diff --git a/ldap-site-mngmt/webinterface/dhcp/new_dhcpsubnet.php b/ldap-site-mngmt/webinterface/dhcp/new_dhcpsubnet.php index a7697c14..adf7720f 100644 --- a/ldap-site-mngmt/webinterface/dhcp/new_dhcpsubnet.php +++ b/ldap-site-mngmt/webinterface/dhcp/new_dhcpsubnet.php @@ -23,14 +23,14 @@ $sbmnr = $_GET['sbmnr']; createMainMenu($rollen, $mainnr); createDhcpMenu($rollen, $mnr, $auDN, $sbmnr); +include("ip_blocks.inc.php"); + ################################################################################### $subnetcn = str_replace ( "_", " ", $_GET['subnetcn']); $netmask = str_replace ( "_", " ", $_GET['netmask']); $template->assign(array("CN" => $subnetcn, "NETMASK" => $netmask, - "RANGE1" => "", - "RANGE2" => "", "DESCRIPTION" => "", "STATEMENTS" => "", "ALLOW" => "", @@ -57,6 +57,30 @@ $template->assign(array("CN" => $subnetcn, +$freenets = get_networks(); +#print_r($freenets); +$subnets = array(); +if (count($freenets) != 0){ + $template->define_dynamic("Dhcpsubnets", "Webseite"); + + foreach ($freenets as $subnet){ + $netexp = explode(".",$subnet); + $mask = array(255,255,255,255); + for ($i=0; $i<count($netexp); $i++){ + if ($netexp[$i] == "0"){ + $mask[$i] = "0"; + } + } + $netmask = implode(".", $mask); + $subnets[] = $subnet."|".$netmask; + + $template->assign(array("SUBNET" => $subnet."|".$netmask, + "CN" => $subnet, + "NETMASK" => $netmask)); + $template->parse("DHCPSUBNETS_LIST", ".Dhcpsubnets"); + } + #print_r($subnets); + # DHCP Services $dhcpservices = get_dhcpoffers($auDN); #print_r($dhcpservices); echo "<br>"; @@ -76,6 +100,13 @@ $template->define_dynamic("Dhcpservices", "Webseite"); } } +$template->assign(array("SUBLIST" => count($freenets)+1, + "SRVLIST" => count($dhcpservices)+1)); + +}else{ + # keine freie Netze mehr zur Verfügung + # wird schon über das DHCP Menu abgefangen ... +} ################################################################################### diff --git a/ldap-site-mngmt/webinterface/dhcp/no_dhcp.dwt b/ldap-site-mngmt/webinterface/dhcp/no_dhcp.dwt index 5b8ffe4f..4e83f948 100644 --- a/ldap-site-mngmt/webinterface/dhcp/no_dhcp.dwt +++ b/ldap-site-mngmt/webinterface/dhcp/no_dhcp.dwt @@ -7,17 +7,19 @@ </tr> <tr> <td> - <p>Dieses Modul dient der Verwaltung des DHCP Dienstes und DHCP Subnetzen.<br> + <p>Verwaltung von DHCP Subnets, Pools (und Classes).<br> <br> - <b>Sie verfügen über keine kompletten Netzwerke!</b> <br> + <b>Sie verfügen über keine IP Adressen, so dass Sie keine dieser Objekte + anlegen bzw. verwalten können.</b><br> + <!--<b>Sie verfügen über keine kompletten Netzwerke!</b> <br> x.x.x.0/24<br> x.x.0.0/16<br> x.0.0.0/8<br> <br> - Sie können daher keine DHCP Dienst- bzw. DHCP Subnetz-Objekte anlegen. <br> + Sie können daher keine DHCP Dienst- bzw. DHCP Subnetz-Objekte anlegen. <br>--> <br> - Jedoch können Sie ihre Rechner in DHCP Diensten (Subnetzen) anderer AUs - anmelden (Modul Rechner Management). + Sie können jedoch ihre Rechner im zentralen DHCP Dienst eintragen, über das<br> + Modul <a class='headerlink' href='../computers/computers.php' >Rechner Management</a>. </td> </tr> diff --git a/ldap-site-mngmt/webinterface/dhcp/no_dhcp.php b/ldap-site-mngmt/webinterface/dhcp/no_dhcp.php index 57653255..2a09a6e7 100644 --- a/ldap-site-mngmt/webinterface/dhcp/no_dhcp.php +++ b/ldap-site-mngmt/webinterface/dhcp/no_dhcp.php @@ -20,6 +20,8 @@ include('dhcp_header.inc.php'); createMainMenu($rollen, $mainnr); createDhcpMenu($rollen, $mnr, $auDN, $sbmnr); +include("ip_blocks.inc.php"); + ################################################################################### include("dhcp_footer.inc.php"); diff --git a/ldap-site-mngmt/webinterface/ip/ip_rechner_change.php b/ldap-site-mngmt/webinterface/ip/ip_rechner_change.php index 68023cb0..7d337f7e 100644 --- a/ldap-site-mngmt/webinterface/ip/ip_rechner_change.php +++ b/ldap-site-mngmt/webinterface/ip/ip_rechner_change.php @@ -2,12 +2,9 @@ include('../standard_header.inc.php'); -$auDN = $_POST['audn']; $hostDN = $_POST['hostdn']; $oldip = $_POST['oldip']; $newip = $_POST['newip']; -# print_r($newip);echo "<br>"; -# print_r($oldip);echo "<br>"; $syntax = new Syntaxcheck; $url = "ip_rechner.php"; @@ -26,16 +23,11 @@ echo " $diff1 = array_keys(array_diff_assoc($oldip,$newip)); $diff2 = array_keys(array_diff_assoc($newip,$oldip)); $tochange = array_unique(array_merge($diff1,$diff2)); -# print_r($diff1);echo "<br>"; -# print_r($diff2);echo "<br>"; -# print_r($tochange);echo "<br><br>"; foreach ($tochange as $i){ if ( $oldip[$i] == "" && $newip[$i] != "" ){ echo "neue IP";echo "<br>";echo "<br>"; - #print_r($auDN[$i]);echo "<br>"; - #print_r($hostDN[$i]);echo "<br>"; echo "<br>"; echo "alte IP: ";print_r($oldip[$i]);echo "<br>"; echo "neue IP: ";print_r($newip[$i]);echo "<br>"; @@ -48,8 +40,9 @@ foreach ($tochange as $i){ $newipp = implode('_',$newip_array); #print_r($newipp); $oldip[$i] = htmlentities($oldip[$i]); - if (new_ip_host($newipp,$hostDN[$i],$auDN[$i])){ + if (new_ip_host($newipp,$hostDN[$i],$auDN)){ $mesg = "Neue IP Adresse eingetragen<br>"; + update_dhcpmtime(); }else{$mesg = "Fehler beim eintragen der neuen IP Adresse<br>";} }else{echo "falsche IP Syntax";} @@ -60,8 +53,6 @@ foreach ($tochange as $i){ elseif ( $oldip[$i] != "" && $newip[$i] != "" ){ echo "aendern IP";echo "<br>";echo "<br>"; - #print_r($auDN[$i]);echo "<br>"; - #print_r($hostDN[$i]);echo "<br>"; echo "<br>"; echo "alte IP: ";print_r($oldip[$i]);echo "<br>"; echo "neue IP: ";print_r($newip[$i]);echo "<br>"; @@ -76,12 +67,14 @@ foreach ($tochange as $i){ $oldip[$i] = htmlentities($oldip[$i]); $oldip_array = array($oldip[$i],$oldip[$i]); $oldipp = implode('_',$oldip_array); - if (modify_ip_host($newipp,$hostDN[$i],$auDN[$i])){ + if (modify_ip_host($newipp,$hostDN[$i],$auDN)){ $mesg = "IP Adresse geaendert<br>"; + adjust_hostip_tftpserverip($oldip[$i],$newip[$i]); + update_dhcpmtime(); }else{ $mesg = "Fehler beim aendern der IP Adresse<br>"; # oldip die schon gelöscht wurde wieder einfügen - new_ip_host($oldipp,$hostDN[$i],$auDN[$i]);} + new_ip_host($oldipp,$hostDN[$i],$auDN);} }else{echo "falsche IP Syntax";} $mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br> @@ -91,8 +84,6 @@ foreach ($tochange as $i){ elseif ( $oldip[$i] != "" && $newip[$i] == "" ){ echo "loeschen IP";echo "<br>";echo "<br>"; - #print_r($auDN[$i]);echo "<br>"; - #print_r($hostDN[$i]);echo "<br>"; echo "<br>"; echo "alte IP: ";print_r($oldip[$i]);echo "<br>"; echo "neue IP: ";print_r($newip[$i]);echo "<br>"; @@ -100,8 +91,10 @@ foreach ($tochange as $i){ echo "korrekte IP Syntax"; $newip[$i] = htmlentities($newip[$i]); $oldip[$i] = htmlentities($oldip[$i]); - if (delete_ip_host($hostDN[$i],$auDN[$i])){ + if (delete_ip_host($hostDN[$i],$auDN)){ $mesg = "IP Adresse geloescht<br>"; + adjust_hostip_tftpserverip($oldip[$i],""); + update_dhcpmtime(); }else{$mesg = "Fehler beim loeschen der IP Adresse<br>";} $mesg .= "<br>Sie werden automatisch auf die vorherige Seite zurückgeleitet. <br> diff --git a/ldap-site-mngmt/webinterface/lib/commonlib.inc.php b/ldap-site-mngmt/webinterface/lib/commonlib.inc.php index 32df2a1c..7fb68395 100644 --- a/ldap-site-mngmt/webinterface/lib/commonlib.inc.php +++ b/ldap-site-mngmt/webinterface/lib/commonlib.inc.php @@ -171,11 +171,13 @@ function getRoles($ds, $userDN) { */ function createMainMenu($rollen , $mainnr) { - global $template; - global $START_PATH; + + global $template, $START_PATH, $auDN; - # pre-checks - if ( check_if_max_networks() ){ + # pre-checks + $mipbs = get_maxipblocks_au($auDN); + #echo "MIPB: "; print_r ($mipbs); echo "<br>"; + if ($mipbs[0] != ""){ $dhcplink = "dhcp/dhcp.php"; }else{ $dhcplink = "dhcp/no_dhcp.php"; diff --git a/ldap-site-mngmt/webinterface/lib/config.inc.php b/ldap-site-mngmt/webinterface/lib/config.inc.php index 653cc262..e6dc17b1 100644 --- a/ldap-site-mngmt/webinterface/lib/config.inc.php +++ b/ldap-site-mngmt/webinterface/lib/config.inc.php @@ -10,12 +10,13 @@ # einige LDAP-Angaben: # der Anwendungs-LDAP - define('LDAP_HOST', 'ldap://oranje.ruf.uni-freiburg.de'); - #define('LDAP_HOST', 'ldaps://oranje.ruf.uni-freiburg.de'); + define('LDAP_HOST', 'ldap://foo.ruf.uni-freiburg.de'); + #define('LDAP_HOST', 'ldaps://foo.ruf.uni-freiburg.de'); define('LDAP_PORT', 389); #define('LDAP_PORT', 636); $suffix = "dc=uni-freiburg,dc=de"; $domsuffix = "uni-freiburg.de"; + $rootAU = "ou=UniFreiburg,ou=RIPM,dc=uni-freiburg,dc=de"; # der LDAP-Server für die Authentisierung der User #define('LDAP_HOST_RZ', '132.230.1.61'); @@ -26,5 +27,5 @@ #$dummyUid = "rz-ldap"; // Dummy-User für einige Aktionen - muss angelegt werden!!! #$dummyPassword = "dummy"; - #$standardPassword = "dipman02"; // das Passwort mit dem alle User im Anwendungsldap angelegt werden!!! + #$standardPassword = "..."; // das Passwort mit dem alle User im Anwendungsldap angelegt werden!!! ?> diff --git a/ldap-site-mngmt/webinterface/lib/dhcp_management_functions.php b/ldap-site-mngmt/webinterface/lib/dhcp_management_functions.php index 4194a1b3..fd939369 100644 --- a/ldap-site-mngmt/webinterface/lib/dhcp_management_functions.php +++ b/ldap-site-mngmt/webinterface/lib/dhcp_management_functions.php @@ -18,6 +18,22 @@ $ldapError = null; ################################################################################################### +# immer wenn ein DHCP Objekt geändert wird (DHCP modify time aktualisieren) +function update_dhcpmtime(){ + + global $ds, $auDN, $ldapError; + + $entry ['dhcpmtime'] = time(); + $results = ldap_mod_replace($ds,$auDN,$entry); + if ($results){ + echo "<br><b>dhcpMTime</b> erfolgreich aktualisiert!<br>" ; + return 1; + }else{ + echo "<br>Fehler beim Aktualisieren der <b>dhcpMTime</b>!<br>" ; + } +} + + # freie x.x.x.0/24 Netzwerke einer AU holen function get_networks(){ @@ -397,12 +413,11 @@ function alternative_dhcpobjects($objecttype,$objectDN,$ip){ # Funktionen zur Verwaltung von DHCP Subnet Objekten # -function add_dhcpsubnet ($cn,$dhcpservice,$netmask,$range1,$range2,$atts){ +function add_dhcpsubnet ($cn,$dhcpservice,$netmask,$atts){ global $ds, $suffix, $auDN, $ldapError; - $cnarray = array($cn,$cn); - $subnet = implode('_',$cnarray); + $subnet = implode('_',array($cn,$cn)); # IP checken und FIBS anpassen $fipb_array = get_freeipblocks_au($auDN); @@ -445,18 +460,21 @@ function add_dhcpsubnet ($cn,$dhcpservice,$netmask,$range1,$range2,$atts){ print_r($dhcpsubnetDN); echo "<br>"; if ($result = ldap_add($ds, $dhcpsubnetDN, $entrydhcp)){ - if ( check_ip_in_subnet($range1,$cn) && check_ip_in_subnet($range2,$cn)){ - $dhcprange = implode('_',array($range1,$range2)); - if ( $range = new_ip_dhcprange($dhcprange,$dhcpsubnetDN,$auDN) ){ - echo "DHCP Range <b>".$range1." - ".$range2."</b> erfolgreich im Subnetobjekt eingetragen"; - }else{ - echo "DHCP Range <b>".$range1." - ".$range2."</b> konnte nicht im Subnetobjekt eingetragen werden!"; - } - return 1; - }else{ - echo "DHCP Range nicht in Subnetz ".$cn." enthalten.<br>Keine DHCP Range angelegt.<br>"; - return 1; - } + printf("Subnet <b>%s / %s</b> erfolgreich eingetragen",$cn,$netmask); + return 1; + update_dhcpmtime(); + #if ( check_ip_in_subnet($range1,$cn) && check_ip_in_subnet($range2,$cn)){ + # $dhcprange = implode('_',array($range1,$range2)); + # if ( $range = new_ip_dhcprange($dhcprange,$dhcpsubnetDN,$auDN) ){ + # echo "DHCP Range <b>".$range1." - ".$range2."</b> erfolgreich im Subnetobjekt eingetragen"; + # }else{ + # echo "DHCP Range <b>".$range1." - ".$range2."</b> konnte nicht im Subnetobjekt eingetragen werden!"; + # } + # return 1; + #}else{ + # echo "DHCP Range nicht in Subnetz ".$cn." enthalten.<br>Keine DHCP Range angelegt.<br>"; + # return 1; + #} }else{ echo "<br>Fehler beim anlegen des DHCP Subnet Objekts!<br>"; return 0; @@ -485,6 +503,7 @@ function delete_dhcpsubnet($subnetDN,$cn){ $results = ldap_mod_add($ds,$auDN,$entry); if ($results){ merge_ipranges($auDN); + update_dhcpmtime(); return 1; }else{ return 0; @@ -536,6 +555,7 @@ function modify_subnet_dn($subnetDN,$newsubnetDN){ $results = ldap_mod_replace($ds,$auDN,$entry); if ($results){ merge_ipranges($auDN); + update_dhcpmtime(); echo "<br>FIPBs erfolgreich angepasst!<br>" ; return 1; }else{ @@ -550,7 +570,7 @@ function modify_subnet_dn($subnetDN,$newsubnetDN){ } } - +# wird eigentlich nicht benötigt wenn host deklarationen nicht in subnet scope sind ... function cleanup_del_dhcpsubnet ($dhcpsubnetDN){ global $ds, $suffix, $auDN, $ldapError; @@ -569,7 +589,7 @@ function cleanup_del_dhcpsubnet ($dhcpsubnetDN){ } - +# wird eigentlich nicht benötigt wenn host deklarationen nicht in subnet scope sind ... function adjust_dhcpsubnet_dn ($newdhcpsubnetDN,$dhcpsubnetDN){ global $ds, $suffix, $auDN, $ldapError; @@ -590,6 +610,7 @@ function adjust_dhcpsubnet_dn ($newdhcpsubnetDN,$dhcpsubnetDN){ # Nach Änderung der Host IP Adresse, überprüfen ob neue IP noch mit Subnet übereinstimmt # Falls keine Ãœbereinstimmung mehr, dann Subnetzuordnung aus Host löschen. +# wird eigentlich nicht benötigt wenn host deklarationen nicht in subnet scope sind ... function adjust_hostip_dhcpsubnet($ip,$hostDN,$dhcphlpcont) { global $ds, $suffix, $auDN, $ldapError; @@ -622,4 +643,56 @@ function check_ip_in_subnet($ip,$subnet) { } if ($return) { return 1; }else{ return 0; } } + +######################### +# Pools +function add_dhcppool ($dhcpsubnetdn,$range,$unknownclients,$dhcpservicedn){ + + global $ds, $suffix, $auDN, $ldapError; + + if(!($result = uniLdapSearch($ds, "cn=dhcp,".$auDN,"(objectclass=*)", array("cn"), "dn", "list", 0, 0))) { + # redirect(5, "", $ldapError, FALSE); + echo "no search"; + die; + } + $result = ldapArraySauber($result); + + $dhcpcn_array = array(); + foreach ($result as $item){ + $dhcpcn_array [] = $item['cn']; + } + print_r($dhcpcn_array);echo "<br><br>"; + for ($i=0;$i<100;$i++){ + if ( array_search ( "Pool".$i, $dhcpcn_array ) === false ){ + $cn = "Pool".$i; + break; + } + } + $dhcppoolDN = "cn=".$cn.",cn=dhcp,".$auDN; + + $entrydhcp ['objectclass'][0] = "dhcpPool"; + $entrydhcp ['objectclass'][1] = "dhcpOptions"; + $entrydhcp ['objectclass'][2] = "top"; + $entrydhcp ['cn'] = $cn; + $entrydhcp ['dhcphlpcont'] = $dhcpsubnetdn; + $entrydhcp ['dhcprange'] = $range; + if ($unknownclients == "allow"){ + $entrydhcp ['dhcpoptallow'] = "unknown-clients"; + }elseif ($unknownclients == "ignore"){ + $entrydhcp ['dhcpoptignore'] = "unknown-clients"; + }else{ + $entrydhcp ['dhcpoptdeny'] = "unknown-clients"; + } + + print_r($dhcppoolDN);echo "<br><br>"; + print_r($entrydhcp);echo "<br><br>"; + + if ($result = ldap_add($ds,$dhcppoolDN,$entrydhcp)){ + return 1; + }else{return 0;} + + +} + + ?>
\ No newline at end of file diff --git a/ldap-site-mngmt/webinterface/lib/ip_management_functions.php b/ldap-site-mngmt/webinterface/lib/ip_management_functions.php index b4f4a733..b158e35b 100644 --- a/ldap-site-mngmt/webinterface/lib/ip_management_functions.php +++ b/ldap-site-mngmt/webinterface/lib/ip_management_functions.php @@ -93,11 +93,12 @@ function split_iprange($iprange1,$iprange2) if ($ipr3s <= $ipr3e){$iprange3 = long2ip($ipr3s)."_".long2ip($ipr3e); $ipranges[] = $iprange3;} if ($ipr4s <= $ipr4e){$iprange4 = long2ip($ipr4s)."_".long2ip($ipr4e); $ipranges[] = $iprange4;} + #echo "MATCH!<br>"; return $ipranges; } else { - echo "IPRange1 not in IPRange2: "; + #echo "IPRange1 not in IPRange2: "; return 0; } } @@ -246,6 +247,86 @@ function get_maxipblocks_au($auDN) return $mipb_array; } +# benutze IP Ranges (Rechner, Ranges, Delegs) +function get_used_ipblocks_au($auDN) +{ + global $ds, $suffix, $ldapError; + + $host_ips = array(); + $dhcps_ips = array(); + $dhcpr_ips = array(); + $deleg_ips = array(); + # Rechner IPs + if(!($result = uniLdapSearch($ds, "cn=computers,".$auDN, "(objectclass=Host)", array("IPAddress"), "", "list", 0, 0))) { + # redirect(5, "", $ldapError, FALSE); + echo "no search"; + die; + } else { + $result = ldapArraySauber($result); + foreach ($result as $item){ + if (count($item['ipaddress']) != 0){ + $host_ips [] = $item['ipaddress']; + } + } + } + echo "Rechner IPs:<br>"; print_r($host_ips); echo "<br><br>"; + + # DHCP Subnets + if(!($result = uniLdapSearch($ds, "cn=dhcp,".$auDN, "(objectclass=dhcpSubnet)", array("cn"), "", "list", 0, 0))) { + # redirect(5, "", $ldapError, FALSE); + echo "no search"; + die; + } else { + $result = ldapArraySauber($result); + foreach ($result as $item){ + $dhcps_ips [] = $item['cn']."_".$item['cn']; + } + } + echo "DHCP Subnets:<br>"; print_r($dhcps_ips); echo "<br><br>"; + + # DHCP Pool Ranges + if(!($result = uniLdapSearch($ds, "cn=dhcp,".$auDN, "(objectclass=dhcpPool)", array("dhcpRange"), "", "list", 0, 0))) { + # redirect(5, "", $ldapError, FALSE); + echo "no search"; + die; + } else { + $result = ldapArraySauber($result); + foreach ($result as $item){ + if (count($item['dhcprange']) > 1){ + foreach ($item['dhcprange'] as $range){ + $dhcpr_ips [] = $range; + } + } + elseif (count($item['dhcprange']) == 1){ + $dhcpr_ips [] = $item['dhcprange']; + } + } + } + echo "DHCP Pool Ranges:<br>"; print_r($dhcpr_ips); echo "<br><br>"; + + # Delegierte IPs + $childau_array = get_childau($auDN,array("dn","ou","maxipblock")); + #print_r($childau_array); + if (count($childau_array) != 0){ + foreach ($childau_array as $childau){ + if (count($childau['maxipblock']) > 1){ + foreach ($childau['maxipblock'] as $mipb){ + $deleg_ips [] = $mipb; + } + }elseif (count($childau['maxipblock']) == 1){ + $deleg_ips [] = $childau['maxipblock']; + } + } + } + echo "Delegiert IP Blocks:<br>"; print_r($deleg_ips); echo "<br><br>"; + + $used_ips = array_merge($host_ips, $dhcps_ips, $dhcpr_ips, $deleg_ips); + sort($used_ips); + $used_ips = merge_ipranges_array($used_ips); + + return $used_ips; +} + /** * get_host_ip($hostDN) @@ -316,6 +397,33 @@ function get_dhcp_range($dhcpobjectDN) } } +function get_dhcp_range2($dhcpobjectDN) +{ + global $ds, $suffix, $ldapError; + + if(!($result = uniLdapSearch($ds, $dhcpobjectDN, "(objectclass=*)", array("dhcpRange"), "", "one", 0, 0))) { + # redirect(5, "", $ldapError, FALSE); + echo "no search"; + die; + return 0; + } + else { + $result = ldapArraySauber($result); + $dhcp_array = array(); + foreach ($result as $item){ + if ( count($item['dhcprange']) == 1 ){ + $dhcp_array[] = $item['dhcprange']; + } + if ( count($item['dhcprange']) > 1 ){ + foreach ($item['dhcprange'] as $range){ + $dhcp_array[] = $range; + } + } + } + return $dhcp_array; + } +} + /** * merge_ipranges($auDN) @@ -349,8 +457,8 @@ function merge_ipranges($auDN) } print_r($fipb_array);printf("<br>"); foreach ( $fipb_array as $item ){ - $entry ['FreeIPBlock'][] = $item; - } + $entry ['FreeIPBlock'][] = $item; + } $results = ldap_mod_replace($ds,$auDN,$entry); if ($results) echo "<br>FIPBs erfolgreich zusammengefasst!<br><br>" ; else echo "<br>Fehler beim eintragen der FIPBs!<br><br>"; @@ -376,6 +484,55 @@ function merge_ipranges($auDN) else echo "<br>Fehler beim eintragen der MIPBs!<br><br>"; } +function merge_dhcpranges($dhcpobjectDN) +{ + global $ds, $suffix, $ldapError; + + $dhcp_array = get_dhcp_range2($dhcpobjectDN); + if ( count($dhcp_array) > 1) sort($dhcp_array); + + $c = count($dhcp_array); + for ($i=0; $i < $c; $i++){ + for ($j=$i+1; $j < $c; $j++){ + if ( merge_2_ipranges($dhcp_array[$i],$dhcp_array[$j])){ + $dhcp_array[$i] = merge_2_ipranges($dhcp_array[$i],$dhcp_array[$j]); + array_splice($dhcp_array, $j, 1); + $c--; + $i=-1; + break; + } + } + } + foreach ( $dhcp_array as $item ){ + $entry ['dhcprange'][] = $item; + } + $results = ldap_mod_replace($ds,$dhcpobjectDN,$entry); + if ($results) echo "<br>DHCP Ranges erfolgreich zusammengefasst!<br><br>" ; + else echo "<br>Fehler beim eintragen der DHCP Ranges!<br><br>"; +} + +function merge_ipranges_array($ipranges_array) +{ + global $ds, $suffix, $ldapError; + + sort($ipranges_array); + $c = count($ipranges_array); + for ($i=0; $i < $c; $i++){ + for ($j=$i+1; $j < $c; $j++){ + if ( merge_2_ipranges($ipranges_array[$i],$ipranges_array[$j])){ + $ipranges_array[$i] = merge_2_ipranges($ipranges_array[$i],$ipranges_array[$j]); + array_splice($ipranges_array, $j, 1); + $c--; + $i=-1; + break; + } + } + } + return $ipranges_array; + # Rückgabewert ... +} + + /** * new_ip_host($ip,$hostDN,$auDN) @@ -454,7 +611,7 @@ function new_ip_dhcprange($ip,$dhcpobjectDN,$auDN) $fipb_array = get_freeipblocks_au($auDN); - print_r($fipb_array); + #print_r($fipb_array); for ($i=0; $i < count($fipb_array); $i++){ if ( split_iprange($ip,$fipb_array[$i]) != 0 ){ @@ -494,6 +651,55 @@ function new_ip_dhcprange($ip,$dhcpobjectDN,$auDN) } } +## Add Dhcprange in DHCP Pool +function add_dhcprange($newrange,$pooldn) { + + global $ds, $auDN, $suffix, $ldapError; + + # Freie IP Bereiche testen + $fipb_array = get_freeipblocks_au($auDN); + $test = 0; + for ($f=0; $f < count($fipb_array); $f++){ + if ( split_iprange($newrange,$fipb_array[$f]) != 0 ){ + $ipranges = split_iprange($newrange,$fipb_array[$f]); + array_splice($fipb_array, $f, 1, $ipranges); + $test = 1; + break; + } + } + if ( $test ){ + foreach ( $fipb_array as $item ){ + $entry ['FreeIPBlock'][] = $item; + } + $result1 = ldap_mod_replace($ds,$auDN,$entry); + if ($result1){ + echo "<br>Neue FIPBs erfolgreich eingetragen!<br>"; + $rangeentry ['dhcprange'] = $newrange; + print_r($rangeentry);echo "<br><br>"; + $result2 = ldap_mod_add($ds,$pooldn,$rangeentry); + if ($result2){ + merge_dhcpranges($pooldn); + #printf("Neue dynamische IP Range %s - %s erfolgreich in Subnetz %s0 eingetragen!<br>",$addrange1[$i],$addrange2[$i],$net); + return 1; + }else{ + # echo "<br>Fehler beim eintragen des dynamischen DHCP Pools!<br>"; + # Range wieder in FIPBs aufnehmen. + $entry2 ['FreeIPBlock'] = $newrange; + ldap_mod_add($ds,$auDN,$entry2); + merge_ipranges($auDN); + return 0; + } + }else{ + echo "<br>Fehler beim eintragen der FIPBs!<br>"; + return 0; + } + }else{ + printf("<br>IP Range %s ist nicht im verfuegbaren Bereich!<br>", $range ); + return 0; + } +} + + /** * delete_ip_host($hostDN,$auDN) * Löscht die IP Adresse eines Hosts, und passt die FreeIPBlocks der AU an. diff --git a/ldap-site-mngmt/webinterface/lib/ldap.inc.php b/ldap-site-mngmt/webinterface/lib/ldap.inc.php index 60a83e0d..292529a6 100644 --- a/ldap-site-mngmt/webinterface/lib/ldap.inc.php +++ b/ldap-site-mngmt/webinterface/lib/ldap.inc.php @@ -629,6 +629,58 @@ function get_dhcppools($auDN,$attributes) if($attributes != false ){return $pool_array;} else{return $result;} } +} + +function get_dhcppools_subnet($subnetDN,$attributes) +{ + global $ds, $suffix, $auDN, $ldapError; + + if(!($result = uniLdapSearch($ds, $auDN, "(&(objectclass=dhcpPool)(dhcphlpcont=$subnetDN))", $attributes, "cn", "sub", 0, 0))) { + # redirect(5, "", $ldapError, FALSE); + echo "no search"; + die; + } + else { + $result = ldapArraySauber($result); + + $pool_array = array(); + foreach ($result as $item){ + $poolexpdn = ldap_explode_dn($item['dn'], 1); + $poolau = $poolexpdn[2]; + foreach ($attributes as $att){ + $atts[$att] = $item[$att]; + } + $atts['poolAU'] = $poolau; + $pool_array[] = $atts; + } + if($attributes != false ){return $pool_array;} + else{return $result;} + } +} + +function get_dhcppoolranges($poolDN) +{ + global $ds, $suffix, $ldapError; + + if(!($result = uniLdapSearch($ds, $poolDN, "(objectclass=dhcpPool)", array("dhcprange"), "", "one", 0, 0))) { + # redirect(5, "", $ldapError, FALSE); + echo "no search"; + die; + } + else { + $result = ldapArraySauber($result); + #print_r($result); echo "<br><br>"; + $ranges_array = array(); + if ( count($result[0]['dhcprange']) == 1 ){ + $ranges_array [] = $result[0]['dhcprange']; + } + elseif ( count($result[0]['dhcprange']) > 1 ){ + foreach ($result[0]['dhcprange'] as $range){ + $ranges_array [] = $range; + } + } + return $ranges_array; + } } function get_childau($auDN,$attributes) @@ -999,4 +1051,5 @@ function get_service_subnets($dhcpserviceDN,$attributes) else{return $result;} } } + ?> diff --git a/ldap-site-mngmt/webinterface/lib/rbs_management_functions.php b/ldap-site-mngmt/webinterface/lib/rbs_management_functions.php index cc73595e..6fd64737 100644 --- a/ldap-site-mngmt/webinterface/lib/rbs_management_functions.php +++ b/ldap-site-mngmt/webinterface/lib/rbs_management_functions.php @@ -206,9 +206,33 @@ function adjust_dhcpnextserver($tftpIP, $rbsDN){ die; } $result = ldapArraySauber($result); - $modtftpentry ['dhcpoptnext-server'] = $tftpIP; - foreach ($result as $item){ - ldap_mod_replace($ds, $item['dn'], $modtftpentry); + $host_au = array(); + if ($tftpIP == ""){ + $deltftpentry ['dhcpoptnext-server'] = array(); + foreach ($result as $item){ + ldap_mod_del($ds, $item['dn'], array()); + $expdn = array_slice(ldap_explode_dn($item['dn'], 0), 3); + $host_au [] = implode(",", $expdn); + } + }else{ + $modtftpentry ['dhcpoptnext-server'] = $tftpIP; + foreach ($result as $item){ + ldap_mod_replace($ds, $item['dn'], $modtftpentry); + $expdn = array_slice(ldap_explode_dn($item['dn'], 0), 3); + $host_au [] = implode(",", $expdn); + } + } + if ( count($host_au) != 0 ){ + $host_au = array_unique($host_au); + $entry ['dhcpmtime'] = time(); + foreach ($host_au as $au){ + $results = ldap_mod_replace($ds,$au,$entry); + if ($results){ + #echo "<br><b>dhcpMTime</b> erfolgreich aktualisiert!<br>" ; + }else{ + echo "<br>Fehler beim Aktualisieren der <b>dhcpMTime</b>!<br>" ; + } + } } } @@ -224,6 +248,7 @@ function adjust_dhcpfilename($initbootfile, $rbsDN, $type){ die; } $result = ldapArraySauber($result); + $host_au = array(); if ($type == "add"){ $modentry ['dhcpoptfilename'] = $initbootfile; foreach ($result as $item){ @@ -239,36 +264,71 @@ function adjust_dhcpfilename($initbootfile, $rbsDN, $type){ elseif ($type == "replace"){ $modentry ['dhcpoptfilename'] = $initbootfile; foreach ($result as $item){ - ldap_mod_replace($ds, $item['dn'], $modentry); + ldap_mod_replace($ds, $item['dn'], $modentry); + $expdn = array_slice(ldap_explode_dn($item['dn'], 0), 3); + $host_au [] = implode(",", $expdn); } } + if ( count($host_au) != 0 ){ + $host_au = array_unique($host_au); + $entry ['dhcpmtime'] = time(); + foreach ($host_au as $au){ + $results = ldap_mod_replace($ds,$au,$entry); + if ($results){ + #echo "<br><b>dhcpMTime</b> erfolgreich aktualisiert!<br>" ; + }else{ + echo "<br>Fehler beim Aktualisieren der <b>dhcpMTime</b>!<br>" ; + } + } + } } +# IP Adresse eines Host ändern -> RBS TFTP Server IP anpassen (inkl. dhcpNext-server) +function adjust_hostip_tftpserverip($oldip,$newip){ + + global $ds, $suffix, $ldapError, $auDN; + + if(!($result = uniLdapSearch($ds, "cn=rbs,".$auDN, "(&(objectclass=RBService)(tftpserverip=$oldip))", array("dn","tftpserverip"), "dn", "sub", 0, 0))) { + # redirect(5, "", $ldapError, FALSE); + echo "no search"; + die; + } + $result = ldapArraySauber($result); + if (count($result) != 0){ + foreach ($result as $item){ + if ($newip == ""){ + $delentry ['tftpserverip'] = array(); + ldap_mod_del($ds, $item['dn'], $delentry); + adjust_dhcpnextserver("", $item['dn']); + }else{ + $modentry ['tftpserverip'] = $newip; + ldap_mod_replace($ds, $item['dn'], $modentry); + adjust_dhcpnextserver($newip, $item['dn']); + } + } + } +} # # Sucht den Hostname zu einer IP im Rechnerteilbaum der AU # Verwaltung der am RBS beteiligten Server # -function get_hostname_from_ip($ip,$auDN){ +function get_hostname_from_ip($ip){ - global $ds, $suffix, $ldapError; + global $ds, $suffix, $ldapError, $auDN; $ipp = array($ip,$ip); $ipaddress = implode('_',$ipp); - - if(!($result = uniLdapSearch($ds, "cn=computers,".$auDN, "(&(objectclass=Host)(ipaddress=$ipaddress))", array("hostname"), "", "list", 0, 0))) { + if(!($result = uniLdapSearch($ds, "cn=computers,".$auDN, "(&(objectclass=Host)(ipaddress=$ipaddress))", array("dn","hostname"), "", "list", 0, 0))) { # redirect(5, "", $ldapError, FALSE); echo "no search"; die; } - elseif(count($result) == 0){echo "kein Rechner mit dieser IP"; return "";} - else{ - $result = ldapArraySauber($result); - #print_r($result); - $host ['hostname'] = $result[0]['hostname']; - $host ['dn'] = $result[0]['dn']; - return $host; - } + $result = ldapArraySauber($result); + #print_r($result); + $host ['hostname'] = $result[0]['hostname']; + $host ['dn'] = $result[0]['dn']; + return $host; } diff --git a/ldap-site-mngmt/webinterface/rbs/rbservice.dwt b/ldap-site-mngmt/webinterface/rbs/rbservice.dwt index 601372cd..e738d990 100644 --- a/ldap-site-mngmt/webinterface/rbs/rbservice.dwt +++ b/ldap-site-mngmt/webinterface/rbs/rbservice.dwt @@ -57,27 +57,27 @@ <tr valign='top'> <td width='15%' class='tab_h'> </td> - <td width='30%' class='tab_h'> </td> + <td width='35%' class='tab_h'> </td> <td colspan='2' class='tab_h'> </td> </tr> <tr valign='top'> <td class='tab_d_ohne'><b>TFTP Server: </td> <td class='tab_d_ohne'> - <input type='Text' name='tftpserverip' value='{TFTPIP}' size='15' class='medium_form_field'> - <input type='hidden' name='oldtftpserverip' value='{TFTPIP}'></td> + <!--<input type='Text' name='tftpserverip' value='{TFTPIP}' size='15' class='medium_form_field'>--> + <input type='hidden' name='oldtftpserverip' value='{TFTPIP}'><font size='+1'>Hostname: <b>{TFTP}</b> [IP: <b>{TFTPIP}</b>]</font></td> <td width='15%' class='tab_d_ohne'>TFTP Root</td> - <td width='35%' class='tab_d_ohne'> + <td width='30%' class='tab_d_ohne'> <input type='Text' name='attribs[tftproot]' value='{TFTPROOT}' size='20' class='medium_form_field'> <input type='hidden' name='oldattribs[tftproot]' value='{TFTPROOT}'></td> </tr> <tr valign='top'> - <td class='tab_d_ohne'><font size='+1'>{TFTP}</font></td> + <td class='tab_d_ohne'>ändern:</td> <td rowspan='2' class='tab_d_ohne'> - <select name='tftpserver' size='4' class='small_form_selectbox'> + <select name='tftpserver' size='6' class='tftp_form_selectbox'> <option selected value='none'>----------------------------</option> <!-- BEGIN DYNAMIC BLOCK: TftpHosts --> - <option value='{HDN}'>{HN}</option> + <option value='{HDN}'>{HN} [IP: {IP}]</option> <!-- END DYNAMIC BLOCK: TftpHosts --> </select></td> <td class='tab_d_ohne'>PXE Path</td> diff --git a/ldap-site-mngmt/webinterface/rbs/rbservice.php b/ldap-site-mngmt/webinterface/rbs/rbservice.php index f3c5db7e..b6b7162d 100644 --- a/ldap-site-mngmt/webinterface/rbs/rbservice.php +++ b/ldap-site-mngmt/webinterface/rbs/rbservice.php @@ -75,9 +75,8 @@ $name = array_slice($expcn,1); $rbscn = implode('_',$name); # Server Hostnamen holen -$tftpserver = get_hostname_from_ip($rbs_data['tftpserverip'],$auDN); -$nfsserver = get_hostname_from_ip($rbs_data['nfsserverip'],$auDN); -$nbdserver = get_hostname_from_ip($rbs_data['nbdserverip'],$auDN); +$tftpserver = get_hostname_from_ip($rbs_data['tftpserverip']); +#print_r($tftpserver); $template->assign(array("RBSDN" => $rbs_data['dn'], "RBSCN" => $rbscn, @@ -127,21 +126,14 @@ $hostorgroup = $exp[0]; $hosts_array = get_hosts($auDN,array("dn","hostname","ipaddress")); $template->define_dynamic("TftpHosts", "Webseite"); -$template->define_dynamic("NfsHosts", "Webseite"); -$template->define_dynamic("NbdHosts", "Webseite"); foreach ($hosts_array as $item){ - $template->assign(array("HDN" => $item['dn'], - "HN" => $item['hostname'], - "IP" => $item['ipaddress'])); - $template->parse("TFTPHOSTS_LIST", ".TftpHosts"); - $template->assign(array("HDN" => $item['dn'], - "HN" => $item['hostname'], - "IP" => $item['ipaddress'])); - $template->parse("NFSHOSTS_LIST", ".NfsHosts"); - $template->assign(array("HDN" => $item['dn'], - "HN" => $item['hostname'], - "IP" => $item['ipaddress'])); - $template->parse("NBDHOSTS_LIST", ".NbdHosts"); + if ($item['ipaddress'] != "" && $item['hostname'] != $tftpserver['hostname']){ + $hostip = explode("_",$item['ipaddress']); + $template->assign(array("HDN" => $item['dn'], + "HN" => $item['hostname'], + "IP" => $hostip[0])); + $template->parse("TFTPHOSTS_LIST", ".TftpHosts"); + } } ################################################ diff --git a/ldap-site-mngmt/webinterface/rbs/rbservice_change.php b/ldap-site-mngmt/webinterface/rbs/rbservice_change.php index 5f82ac26..f7557dfb 100644 --- a/ldap-site-mngmt/webinterface/rbs/rbservice_change.php +++ b/ldap-site-mngmt/webinterface/rbs/rbservice_change.php @@ -9,28 +9,27 @@ $oldrbsoffer = $_POST['oldrbsoffer']; $tftpserverip = $_POST['tftpserverip']; $oldtftpserverip = $_POST['oldtftpserverip']; -$nfsserverip = $_POST['nfsserverip']; -$oldnfsserverip = $_POST['oldnfsserverip']; -$nbdserverip = $_POST['nbdserverip']; -$oldnbdserverip = $_POST['oldnbdserverip']; +#$nfsserverip = $_POST['nfsserverip']; +#$oldnfsserverip = $_POST['oldnfsserverip']; +#$nbdserverip = $_POST['nbdserverip']; +#$oldnbdserverip = $_POST['oldnbdserverip']; $tftpserver = $_POST['tftpserver']; -$nfsserver = $_POST['nfsserver']; -$nbdserver = $_POST['nbdserver']; +#$nfsserver = $_POST['nfsserver']; +#$nbdserver = $_POST['nbdserver']; $oldtftpserverdn = $_POST['oldtftpserverdn']; -$oldnfsserverdn = $_POST['oldnfsserverdn']; -$oldnbdserverdn = $_POST['oldnbdserverdn']; +#$oldnfsserverdn = $_POST['oldnfsserverdn']; +#$oldnbdserverdn = $_POST['oldnbdserverdn']; + +$initbootfile = $_POST['initbootfile']; +$oldinitbootfile = $_POST['oldinitbootfile']; $delfsuri = $_POST['delfsuri']; $addfsuri = $_POST['addfsuri']; - $fstype = $_POST['fstype']; $fsip = $_POST['fsip']; $fspath = $_POST['fspath']; -$initbootfile = $_POST['initbootfile']; -$oldinitbootfile = $_POST['oldinitbootfile']; - $host_array = get_hosts($auDN,array("dn","hostname","ipaddress")); $rbsDN = $_POST['rbsdn']; @@ -133,12 +132,15 @@ if ( $rbsoffer != "none" && $rbsoffer != $oldrbsoffer ){ ##################################### -# Server ändern über IP Feld +# TFTP Server ändern +# über IP Feld +/*if ( $tftpserverip == $oldtftpserverip ){ + # $mesg = "keine Aenderung<br>"; +} -if ( $tftpserverip != "" && $tftpserverip != $oldtftpserverip ){ - - if ($syntax->check_ip_syntax($tftpserverip)){ +if ( $tftpserverip != "" && $oldtftpserverip == "" ){ + if ($syntax->check_ip_syntax($tftpserverip)){ $tftpserverip = htmlentities($tftpserverip); $mesg .= "Suche nach dem Rechner mit IP ".$tftpserverip." :<br>"; @@ -147,11 +149,11 @@ if ( $tftpserverip != "" && $tftpserverip != $oldtftpserverip ){ $hostip = $hostipexp[0]; if ($tftpserverip == $hostip){ $entrytftp ['tftpserverip'] = $tftpserverip; - if (ldap_mod_replace($ds,$rbsDN,$entrytftp)){ + if (ldap_mod_add($ds,$rbsDN,$entrytftp)){ adjust_dhcpnextserver($tftpserverip, $rbsDN); - $mesg .= "Treffer: Rechner ".$host['hostname']."<br>TFTP Server erfolgreich geändert<br>"; + $mesg .= "Treffer: Rechner ".$host['hostname']."<br>TFTP Server erfolgreich eingetragen<br>"; }else{ - $mesg .= "Fehler beim ändern des TFTP Servers!<br>"; + $mesg .= "Fehler beim Eintragen des TFTP Servers!<br>"; } break; }else{ @@ -164,64 +166,26 @@ if ( $tftpserverip != "" && $tftpserverip != $oldtftpserverip ){ } } -####################################### -# Fileserver URI anlegen - -if ( $addfsuri[1] != "" ){ - # tests: ipsyntax, und spezifische URI-Syntax-Checks... - if( $syntax->check_ip_syntax($addfsuri[1]) ){ - - $newfsuri = $addfsuri[0]."://".$addfsuri[1].$addfsuri[2]; - echo "FS URI <b>".$newfsuri."</b> anlegen<br>"; - - $entryfsadd ['fileserveruri'] = $newfsuri; - if(ldap_mod_add($ds,$rbsDN,$entryfsadd)){ - $mesg = "FS URI erfolgreich eingetragen<br><br>"; - }else{ - $mesg = "Fehler beim eintragen der FS URI<br><br>"; - } - } - else{echo "Falsche IP Syntax<br><br>";} -} - -##################################### -# Fileserver URIs löschen -if ( count($delfsuri) != 0 ){ - echo "Fileserver URI löschen<br>"; - - $i = 0; - foreach ($delfsuri as $fsuri){ - $entry['fileserveruri'][$i] = $fsuri; - $i++; - } - #print_r($entry); echo "<br><br>"; - - if ($result = ldap_mod_del($ds,$rbsDN,$entry)){ - $mesg = "Zu löschende Fileserver URIs erfolgreich gelöscht<br><br>"; - }else{ - $mesg = "Fehler beim löschen der Fileserver URIs<br><br>"; - } -} - -if ( $nfsserverip != "" && $nfsserverip != $oldnfsserverip ){ +if ( $tftpserverip != "" && $tftpserverip != $oldtftpserverip ){ - if ($syntax->check_ip_syntax($nfsserverip)){ - $nfsserverip = htmlentities($nfsserverip); + if ($syntax->check_ip_syntax($tftpserverip)){ + $tftpserverip = htmlentities($tftpserverip); - $mesg .= "Suche nach dem Rechner mit IP ".$nfsserverip." :<br>"; + $mesg .= "Suche nach dem Rechner mit IP ".$tftpserverip." :<br>"; foreach ($host_array as $host){ $hostipexp = explode('_',$host['ipaddress']); $hostip = $hostipexp[0]; - if ($nfsserverip == $hostip){ - $entrytnfs ['nfsserverip'] = $nfsserverip; - if (ldap_mod_replace($ds,$rbsDN,$entrytnfs)){ - $mesg .= "Treffer: Rechner ".$host['hostname']."<br>NFS Server erfolgreich geändert<br>"; + if ($tftpserverip == $hostip){ + $entrytftp ['tftpserverip'] = $tftpserverip; + if (ldap_mod_replace($ds,$rbsDN,$entrytftp)){ + adjust_dhcpnextserver($tftpserverip, $rbsDN); + $mesg .= "Treffer: Rechner ".$host['hostname']."<br>TFTP Server erfolgreich geändert<br>"; }else{ - $mesg .= "Fehler beim ändern des NFS Servers!<br>"; + $mesg .= "Fehler beim ändern des TFTP Servers!<br>"; } break; }else{ - $mesg .= "Rechner ".$host['hostname'].": keine Übereinstimmung mit eingegebener IP ".$nfsserverip."!<br>"; + $mesg .= "Rechner ".$host['hostname'].": keine Übereinstimmung mit eingegebener IP ".$tftpserverip."!<br>"; } } } @@ -230,78 +194,29 @@ if ( $nfsserverip != "" && $nfsserverip != $oldnfsserverip ){ } } -if ( $nbdserverip != "" && $nbdserverip != $oldnbdserverip ){ - - if ($syntax->check_ip_syntax($nbdserverip)){ - $nbdserverip = htmlentities($nbdserverip); - - $mesg .= "Suche nach dem Rechner mit IP ".$nbdserverip." :<br>"; - foreach ($host_array as $host){ - $hostipexp = explode('_',$host['ipaddress']); - $hostip = $hostipexp[0]; - if ($nbdserverip == $hostip){ - $entrytnbd ['nbdserverip'] = $nbdserverip; - if (ldap_mod_replace($ds,$rbsDN,$entrytnbd)){ - $mesg .= "Treffer: Rechner ".$host['hostname']."<br>NBD Server erfolgreich geändert<br>"; - }else{ - $mesg .= "Fehler beim ändern des NBD Servers!<br>"; - } - break; - }else{ - $mesg .= "Rechner ".$host['hostname'].": keine Übereinstimmung mit eingegebener IP ".$nbdserverip."!<br>"; - } - } - } - else{ - $mesg .= "Falsche IP Syntax!<br>"; +if ( $tftpserverip == "" && $oldtftpserverip != "" ){ + $entrytftp ['tftpserverip'] = array(); + if (ldap_mod_del($ds,$rbsDN,$entrytftp)){ + adjust_dhcpnextserver($tftpserverip, $rbsDN); + $mesg .= "Treffer: Rechner ".$host['hostname']."<br>TFTP Server erfolgreich gelöscht<br>"; + }else{ + $mesg .= "Fehler beim löschen des TFTP Servers!<br>"; } -} - -##################################### -# Server ändern über Hostname +}*/ +#über Selectbox an verfügbaren alternativen Rechnern mit IPs if ($tftpserver != "none" && $tftpserver != $oldtftpserverdn){ - $host = get_host_ip($tftpserver); $hostipexp = explode('_',$host['ipaddress']); - $hostip = $hostipexp[0]; - $entrytftp ['tftpserverip'] = $hostip; + $entrytftp ['tftpserverip'] = $hostipexp[0]; if (ldap_mod_replace($ds,$rbsDN,$entrytftp)){ - adjust_dhcpnextserver($tftpserverip, $rbsDN); + adjust_dhcpnextserver($hostipexp[0], $rbsDN); $mesg .= "TFTP Server erfolgreich geändert<br>"; }else{ $mesg .= "Fehler beim ändern des TFTP Servers!<br>"; - } - + } } -if ($nfsserver != "none" && $nfsserver != $oldnfsserverdn){ - - $host = get_host_ip($nfsserver); - $hostipexp = explode('_',$host['ipaddress']); - $hostip = $hostipexp[0]; - $entrynfs ['nfsserverip'] = $hostip; - if (ldap_mod_replace($ds,$rbsDN,$entrynfs)){ - $mesg .= "NFS Server erfolgreich geändert<br>"; - }else{ - $mesg .= "Fehler beim ändern des NFS Servers!<br>"; - } - -} - -if ($nbdserver != "none" && $nbdserver != $oldnbdserverdn){ - - $host = get_host_ip($nbdserver); - $hostipexp = explode('_',$host['ipaddress']); - $hostip = $hostipexp[0]; - $entrytnbd ['nbdserverip'] = $hostip; - if (ldap_mod_replace($ds,$rbsDN,$entrytnbd)){ - $mesg .= "NBD Server erfolgreich geändert<br>"; - }else{ - $mesg .= "Fehler beim ändern des NBD Servers!<br>"; - } - -} ##################################### # Init Boot File @@ -344,6 +259,45 @@ if ( $initbootfile != "" && $initbootfile != $oldinitbootfile ){ } +####################################### +# Fileserver URI anlegen + +if ( $addfsuri[1] != "" ){ + # tests: ipsyntax, und spezifische URI-Syntax-Checks... + if( $syntax->check_ip_syntax($addfsuri[1]) ){ + + $newfsuri = $addfsuri[0]."://".$addfsuri[1].$addfsuri[2]; + echo "FS URI <b>".$newfsuri."</b> anlegen<br>"; + + $entryfsadd ['fileserveruri'] = $newfsuri; + if(ldap_mod_add($ds,$rbsDN,$entryfsadd)){ + $mesg = "FS URI erfolgreich eingetragen<br><br>"; + }else{ + $mesg = "Fehler beim eintragen der FS URI<br><br>"; + } + } + else{echo "Falsche IP Syntax<br><br>";} +} + +##################################### +# Fileserver URIs löschen + +if ( count($delfsuri) != 0 ){ + echo "Fileserver URI löschen<br>"; + + $i = 0; + foreach ($delfsuri as $fsuri){ + $entry['fileserveruri'][$i] = $fsuri; + $i++; + } + #print_r($entry); echo "<br><br>"; + + if ($result = ldap_mod_del($ds,$rbsDN,$entry)){ + $mesg = "Zu löschende Fileserver URIs erfolgreich gelöscht<br><br>"; + }else{ + $mesg = "Fehler beim löschen der Fileserver URIs<br><br>"; + } +} ##################################### diff --git a/ldap-site-mngmt/webinterface/styles.css b/ldap-site-mngmt/webinterface/styles.css index e53676af..f2def7f0 100644 --- a/ldap-site-mngmt/webinterface/styles.css +++ b/ldap-site-mngmt/webinterface/styles.css @@ -163,6 +163,16 @@ h4 { padding-left: 10px; margin: 5px; } +.tftp_form_selectbox { + font-family: Arial; + font-size: 10pt; + border-style: solid; + border-width: 1px 1px; + border-color: #000000; + width: 250; + padding-left: 10px; + margin: 5px; +} .rootfs_form_selectbox { font-family: Arial; font-size: 10pt; |