From c7b4e4a81d7f38c0f1f927f6804ef281c4f67dcd Mon Sep 17 00:00:00 2001 From: Tarik Gasmi Date: Tue, 31 Jul 2007 07:29:53 +0000 Subject: Actualized LDAP SiteManagement Code - Web Interface, DHCP Generationscript git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1284 95ad53e4-c205-0410-b2fa-d234c58c8868 --- .../generation-scripts/dhcp_generate.pl | 73 ++++-- .../webinterface/computers/dhcphost_change.php | 8 +- .../webinterface/computers/host_change.php | 5 +- .../webinterface/computers/host_delete.php | 1 + .../webinterface/computers/hwhost_change.php | 15 +- .../webinterface/computers/rbshost_change.php | 5 +- .../webinterface/dhcp/delete_confirm.php | 2 + ldap-site-mngmt/webinterface/dhcp/dhcp.dwt | 15 +- ldap-site-mngmt/webinterface/dhcp/dhcp.php | 2 + .../webinterface/dhcp/dhcp_footer.inc.php | 1 + .../webinterface/dhcp/dhcp_header.inc.php | 1 + ldap-site-mngmt/webinterface/dhcp/dhcp_menu.php | 111 +++++---- ldap-site-mngmt/webinterface/dhcp/dhcp_start.dwt | 19 +- ldap-site-mngmt/webinterface/dhcp/dhcppool.dwt | 106 ++++++++ ldap-site-mngmt/webinterface/dhcp/dhcppool.php | 132 ++++++++++ ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php | 98 ++++++++ .../webinterface/dhcp/dhcppools_change.php | 277 +++++++++++++++++++++ ldap-site-mngmt/webinterface/dhcp/dhcpservice.php | 2 + .../webinterface/dhcp/dhcpservice_add.php | 2 +- .../webinterface/dhcp/dhcpservice_change.php | 6 +- .../webinterface/dhcp/dhcpservice_delete.php | 2 +- ldap-site-mngmt/webinterface/dhcp/dhcpsubnet.dwt | 16 +- ldap-site-mngmt/webinterface/dhcp/dhcpsubnet.php | 19 +- .../webinterface/dhcp/dhcpsubnet_add.php | 25 +- .../webinterface/dhcp/dhcpsubnet_change.php | 4 +- .../webinterface/dhcp/dhcpsubnet_delete.php | 6 +- ldap-site-mngmt/webinterface/dhcp/dhcpsubnets.dwt | 20 +- ldap-site-mngmt/webinterface/dhcp/dhcpsubnets.php | 55 +++- .../webinterface/dhcp/ip_blocks.inc.php | 68 +++++ ldap-site-mngmt/webinterface/dhcp/ipblocks.dwt | 11 + .../webinterface/dhcp/new_dhcpsubnet.dwt | 33 +-- .../webinterface/dhcp/new_dhcpsubnet.php | 35 ++- ldap-site-mngmt/webinterface/dhcp/no_dhcp.dwt | 12 +- ldap-site-mngmt/webinterface/dhcp/no_dhcp.php | 2 + .../webinterface/ip/ip_rechner_change.php | 25 +- ldap-site-mngmt/webinterface/lib/commonlib.inc.php | 10 +- ldap-site-mngmt/webinterface/lib/config.inc.php | 7 +- .../webinterface/lib/dhcp_management_functions.php | 107 ++++++-- .../webinterface/lib/ip_management_functions.php | 214 +++++++++++++++- ldap-site-mngmt/webinterface/lib/ldap.inc.php | 53 ++++ .../webinterface/lib/rbs_management_functions.php | 92 +++++-- ldap-site-mngmt/webinterface/rbs/rbservice.dwt | 14 +- ldap-site-mngmt/webinterface/rbs/rbservice.php | 26 +- .../webinterface/rbs/rbservice_change.php | 212 ++++++---------- ldap-site-mngmt/webinterface/styles.css | 10 + 45 files changed, 1572 insertions(+), 387 deletions(-) create mode 100644 ldap-site-mngmt/webinterface/dhcp/dhcppool.dwt create mode 100644 ldap-site-mngmt/webinterface/dhcp/dhcppool.php create mode 100644 ldap-site-mngmt/webinterface/dhcp/dhcppool_add.php create mode 100644 ldap-site-mngmt/webinterface/dhcp/dhcppools_change.php create mode 100644 ldap-site-mngmt/webinterface/dhcp/ip_blocks.inc.php create mode 100644 ldap-site-mngmt/webinterface/dhcp/ipblocks.dwt (limited to 'ldap-site-mngmt') 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 "
"; echo "submenuNR:"; print_r($sbmnr); echo "

";*/ -$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 "
"; if ($result = ldap_mod_replace($ds,$hostDN,$entrydhcp)){ + update_dhcpmtime(); $mesg = "Rechner erfolgreich in DHCP ".$dhcpcn." [Abt.: ".$dhcpau."] angemeldet

"; }else{ $mesg = "Fehler beim ändern des DHCP Dienstes zu ".$dhcpcn."!

"; @@ -63,6 +64,7 @@ if ($dhcp != "none" && $dhcp != $olddhcp){ } echo "DHCP add "; print_r($entrydhcp); echo "
"; if ($result = ldap_mod_add($ds,$hostDN,$entrydhcp)){ + update_dhcpmtime(); $mesg = "Rechner erfolgreich in DHCP ".$dhcpcn." [Abt.: ".$dhcpau."] angemeldet

"; }else{ $mesg = "Fehler beim ändern des DHCP Dienstes zu ".$dhcpcn."!

"; @@ -78,6 +80,7 @@ if ($dhcp != "none" && $dhcp != $olddhcp){ #} echo "DHCP delete "; echo "
"; if ($result = ldap_mod_del($ds,$hostDN,$entrydhcp)){ + update_dhcpmtime(); $mesg = "Rechner erfolgreich aus DHCP gelöscht

"; }else{ $mesg = "Fehler beim löschen aus DHCP Dienst!

"; @@ -96,6 +99,7 @@ if ($fixedaddress != "none" && $fixedaddress != $oldfixedaddress){ if ($oldfixedaddress != ""){ echo "Fixed Address ändern"; echo "
"; if ($result = ldap_mod_replace($ds,$hostDN,$entryfixadd)){ + update_dhcpmtime(); $mesg = "Option Fixed-Address erfolgreich auf ".$fixedaddress." geändert

"; }else{ $mesg = "Fehler beim ändern der Option Fixed-Address auf ".$fixedaddress."!

"; @@ -103,6 +107,7 @@ if ($fixedaddress != "none" && $fixedaddress != $oldfixedaddress){ }else{ echo "Fixed Address auf IP Adresse setzen"; echo "
"; if ($result = ldap_mod_add($ds,$hostDN,$entryfixadd)){ + update_dhcpmtime(); $mesg = "Option Fixed-Address erfolgreich auf ".$fixedaddress." gesetzt

"; }else{ $mesg = "Fehler beim setzen der Option Fixed-Address auf ".$fixedaddress."!

"; @@ -112,6 +117,7 @@ if ($fixedaddress != "none" && $fixedaddress != $oldfixedaddress){ $entryfixadd ['dhcpoptfixed-address'] = array(); echo "No Fixed Address"; echo "
"; if ($result = ldap_mod_del($ds,$hostDN,$entryfixadd)){ + update_dhcpmtime(); $mesg = "Option Fixed-Address erfolgreich gelöscht

"; }else{ $mesg = "Fehler beim löschen der Option Fixed-Address!

"; 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 "
"; echo "submenuNR:"; print_r($submenu); echo "

"; */ -$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

"; # 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

"; + adjust_hostip_tftpserverip($oldip,""); }else{ $mesg = "Fehler beim loeschen der IP

"; } @@ -388,6 +390,7 @@ if (count($entrydel) != 0 ){ */ +update_dhcpmtime(); $mesg .= "
Sie werden automatisch auf die vorherige Seite zurückgeleitet.
Falls nicht, klicken Sie hier back"; 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 ".$hostname." erfolgreich gelöscht!

"; } 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 "

"; -/* -echo "new hostname:"; print_r($hostname); echo "
"; -echo "old hostname:"; print_r($oldhostname); echo "
"; -echo "new mac:"; print_r($mac); echo "
"; -echo "old mac:"; print_r($oldmac); echo "
"; -echo "new ip:"; print_r($ip); echo "
"; -echo "old ip:"; print_r($oldip); echo "
"; -echo "new desc:"; print_r($desc); echo "
"; -echo "old desc:"; print_r($olddesc); echo "

"; -echo "Host DN:"; print_r($hostDN); echo "
"; -echo "submenuNR:"; print_r($submenu); echo "

"; -*/ $seconds = 2; -$url = 'host.php?dn='.$hostDN.'&sbmnr='.$sbmnr; +$url = 'hwhost.php?dn='.$hostDN.'&sbmnr='.$sbmnr; echo " @@ -116,6 +104,7 @@ if (count($entrydel) != 0 ){ } } +update_dhcpmtime(); $mesg .= "
Sie werden automatisch auf die vorherige Seite zurückgeleitet.
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 "
"; echo "submenuNR:"; print_r($sbmnr); echo "

";*/ -$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 "
"; if ($result = ldap_mod_replace($ds,$hostDN,$entryrbs)){ + update_dhcpmtime(); rbs_adjust_host($hostDN, $rbs); $mesg = "Remote Boot Service erfolgreich zu ".$rbscn." [Abt.: ".$rbsau."] geändert

"; }else{ @@ -61,6 +62,7 @@ if ($rbs != "none" && $rbs != $oldrbs){ }else{ echo "RBS add "; print_r($entryrbs); echo "
"; if ($result = ldap_mod_add($ds,$hostDN,$entryrbs)){ + update_dhcpmtime(); rbs_adjust_host($hostDN, $rbs); $mesg = "Remote Boot Service erfolgreich zu ".$rbscn." [Abt.: ".$rbsau."] geändert

"; }else{ @@ -73,6 +75,7 @@ if ($rbs != "none" && $rbs != $oldrbs){ $entryrbs ['dhcpoptfilename'] = array(); echo "RBS delete "; echo "
"; if ($result = ldap_mod_del($ds,$hostDN,$entryrbs)){ + update_dhcpmtime(); $mesg = "Rechner erfolgreich aus RBS gelöscht

"; }else{ $mesg = "Fehler beim löschen aus RBS!

"; 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 " @@ -23,6 +24,7 @@ echo " +

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 @@ - + + + + + +
+
- {NAVIGATION} + {NAVIGATION} -
+ + {IPBLOCKS} + +
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 @@ "no_dhcp.php", + global $template, $START_PATH, $rootAU; + + $mipbs = get_maxipblocks_au($auDN); + #echo "MIPB: "; print_r ($mipbs); echo "
"; + 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 "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 "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 "
"; + #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= " - +   - - + ".$zwisch." + ".$item2['text']."   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 @@ -

Dieses Modul dient der Verwaltung eines DHCP Dienstes und DHCP Subnets, Classes
+

Modul zur Verwaltung von DHCP Subnets, dynamischen Pools und Classes
Benutzen Sie die Navigation links, um die einzelnen Verwaltungsbereiche anzusteuern:

    -
  • DHCP Service

    - ... +
  • DHCP Subnets
    + Verwalten Sie ihre Subnetze ...

  • -
  • DHCP Subnets

    - ... +
  • DHCP Pools
    + Weisen Sie ihren DHCP Subnets IP Ranges zur dynamischen Adressvergabe zu ...

  • -
  • DHCP Classes

    - ... +
  • DHCP Classes
    + Verwalten Sie Klassen von DHCP Objekten ...

+
+

Die Verwaltung von DHCP Hosts, etwa das Eintragen ihrer Rechner im zentralen DHCP Dienst, erfolgt über das
+ Modul Rechner Management. + +

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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +

Dynamische DHCP Pools

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SubnetzIP Ranges (innerhalb Subnetz)Unknown Clients
{SUBNET}/24

+ + Pool löschen (Häkchen setzen)
+ + +    -    + + +
+ + + + +    -    + +
+ +   +
+

Dynamischen DHCP Pool hinzufügen

+ + + + + + + + + + + + + + +
IP Range (innerhalb eines Subnetzes)
+ weitere Ranges können später hinzugefügt werden
Unknown Clients
+ +    -    + + + +
+ +
\ 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 @@ +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 = " + + "; + } + elseif ($pool['dhcpoptignore'] == "unknown-clients") { + $unknownclients = "ignore"; + $ucselectbox = " + + "; + } + else{ + $unknownclients = "deny"; + $ucselectbox = " + + "; + } + + + $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 @@ + + + Computers Management + + + + +
"; + + +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 "
Neue FIPBs erfolgreich eingetragen!
"; + + # DHCP Subnet DN finden + $subnet = implode(".", array($fs[0],$fs[1],$fs[2],"0")); + print_r($subnet);echo"

"; + 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 "

"; + if (count($result[0]) != 0){ + $result = add_dhcppool($result[0]['dn'],$range,$unknownclients,$result[0]['dhcphlpcont']); + if ($result){ + echo "
Dynamischer DHCP Pool erfolgreich eingetragen!
" ; + update_dhcpmtime(); + }else{ + echo "
Fehler beim eintragen des dynamischen DHCP Pools!
"; + # 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!
"; + } + }else{ + echo "
Fehler beim eintragen der FIPBs!
"; + } + }else{ + printf("
IP Range %s ist nicht im verfuegbaren Bereich!
", $range ); + } + }else{ + echo "erster Range Wert grösser als zweiter Range Wert
"; + } + }else{ + echo "Range nicht im gleichen Subnetz
"; + } +}else{ + echo "falsche IP Syntax
"; +} + +$mesg .= "
Sie werden automatisch auf die vorherige Seite zurückgeleitet.
+ Falls nicht, klicken Sie hier back"; +redirect($seconds, $url, $mesg, $addSessionId = TRUE); + +echo "
+"; +?> \ 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 @@ +"; +#print_r($subnet); echo "
"; +#print_r($delpool); echo "

"; +#print_r($oldrange1); echo "
"; +#print_r($oldrange2); echo "
"; +#print_r($range1); echo "
"; +#print_r($range2); echo "
"; +#print_r($rangepooldn); echo "

"; +#print_r($addrange1); echo "
"; +#print_r($addrange2); echo "

"; +#print_r($olduc); echo "

"; +#print_r($uc); echo "

"; + +$mnr = $_POST['mnr']; + +$seconds = 2000; +$url = "dhcppool.php?mnr=".$mnr; + +echo " + + + Computers Management + + + + +
"; + + +for ($i=0;$i 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 "

"; + $add_fipb = ldap_mod_add($ds,$auDN,$modentry); + if ($add_fipb){ + echo "
geloeschte IP Range(s) erfolgreich als neuer FIPB in die AU eingetragen!
" ; + 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 %s erfolgreich gelöscht
", $delpool[$i]); + }else{ + printf("Fehler beim Löschen des Pools %s", $delpool[$i]); + } + }else{ + echo "
Fehler beim eintragen der geloeschten IP Range(s) als neuen FIPB!
DHCP Pool nicht gelöscht
"; + } +} + + +for ($i=0;$i", $pooldn[$i]); + $dhcpoptdel = "dhcpopt".$olduc[$i]; + $entrydel [$dhcpoptdel] = array(); + print_r($entrydel); echo "
"; + ldap_mod_del($ds,$pooldn[$i],$entrydel); + $dhcpoptadd = "dhcpopt".$uc[$i]; + $entryadd [$dhcpoptadd] = "unknown-clients"; + print_r($entryadd); echo "

"; + 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
",$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!
",$addrange1[$i],$addrange2[$i],$net); + }else{ + echo "
Fehler beim eintragen des dynamischen DHCP Pools!
"; + } + + }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
", $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"; + 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 "
diffrange: "; print_r($diffrange); echo "
"; + # 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 "
"; + $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
", $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 "
"; + $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
", $range1[$i],$range2[$i]); + } + } + #else{ + # $mesg = "
Verschieben (Shiften) einer IP Range nicht moeglich!
+ # Nur Vergroessern und Verkleinern moeglich!
"; + # $mesg .= "
Sie werden automatisch auf die vorherige Seite zurückgeleitet.
+ # Falls nicht, klicken Sie hier back"; + # redirect($seconds, $url, $mesg, $addSessionId = TRUE); + #} + } +} + +#print_r($mod_dhcpranges); echo "
"; +#print_r($new_fipbs); echo "

"; +$keys = array_keys($mod_dhcpranges); +foreach ($keys as $pdn){ + #print_r($pdn); echo "
"; + #print_r($mod_dhcpranges[$pdn]); echo "
"; + if ( count($mod_dhcpranges[$pdn]) == 0 ){ + printf("Pool %s löschen
",$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
"; + foreach ($mod_dhcpranges[$pdn] as $rg){ + $modpool ['dhcprange'][] = $rg; + } + #print_r($modpool); echo "
"; + $modpool ['dhcprange'] = merge_ipranges_array($modpool ['dhcprange']); + print_r($modpool); echo "
"; + 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 "
FIPBS anpassen
"; + #print_r($new_fipbs['freeipblock']); echo "
"; + $new_fipbs['freeipblock'] = merge_ipranges_array($new_fipbs['freeipblock']); + print_r($new_fipbs); echo "
"; + 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 .= "
Sie werden automatisch auf die vorherige Seite zurückgeleitet.
+ Falls nicht, klicken Sie hier back"; +redirect($seconds, $url, $mesg, $addSessionId = TRUE); + +echo "
+"; +?> \ 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

"; + update_dhcpmtime(); }else{ $mesg = "Fehler beim eintragen Selbst-definierte DHCP Option

"; } @@ -175,6 +176,7 @@ if (count($entryadd) != 0 ){ } if(ldap_mod_add($ds,$dhcpDN,$entryadd)){ $mesg = "Attribute ".$addatts." erfolgreich eingetragen

"; + update_dhcpmtime(); }else{ $mesg = "Fehler beim eintragen der Attribute ".$addatts."

"; } @@ -186,6 +188,7 @@ if (count($entrymod) != 0 ){ } if(ldap_mod_replace($ds,$dhcpDN,$entrymod)){ $mesg = "Attribute ".$modatts." erfolgreich geaendert

"; + update_dhcpmtime(); }else{ $mesg = "Fehler beim aendern der Attribute ".$modatts."

"; } @@ -197,6 +200,7 @@ if (count($entrydel) != 0 ){ } if(ldap_mod_del($ds,$dhcpDN,$entrydel)){ $mesg = "Attribute ".$delatts." erfolgreich geloescht

"; + update_dhcpmtime(); }else{ $mesg = "Fehler beim loeschen der Attribute ".$delatts."

"; } 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 @@ + - + + - + - + @@ -96,9 +98,6 @@ - - - @@ -71,8 +72,8 @@

DHCP Subnet   {CN}

<< Zurück zur Übersicht

DHCP Subnet   {CN}

@@ -31,7 +33,7 @@ - @@ -60,7 +62,7 @@
Eingebunden in DHCP Dienst: Service {DHCPSVNOW} / AU {DHCPSVNOWAU}   + {DHCPSVNOW} 

DHCP Optionen des Subnets (Subnet Scope):

@@ -203,6 +202,7 @@ + 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 = "".$dhcpsvnowdn[0]."  [AU: ".$dhcpsvnowdn[2]."]"; +}else{ + $dhcpsvnow = ""; +} # 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 "

"; +#print_r($cn); echo "

"; +#print_r($netmask); echo "

"; +$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 .= "
DHCP Subnet erfolgreich angelegt
"; - $url = "dhcpsubnets.php?mnr=2"; + $url = "dhcpsubnets.php?mnr=".$mnr; }else{ $mesg .= "
Fehler beim anlegen des DHCP Subnets!
"; } }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.
Bitte geben Sie fehlende ein.

"; - $url = "new_dhcpsubnet.php?subnetcn=".$cn."&netmask=".$netmask."&mnr=2"; + $url = "new_dhcpsubnet.php?subnetcn=".$cn."&netmask=".$netmask."&mnr=".$mnr; } $mesg .= "
Sie werden automatisch auf die vorherige Seite zurückgeleitet.
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 .= "
Sie werden automatisch auf die vorherige Seite zurückgeleitet.
Falls nicht, klicken Sie hier back"; 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 " @@ -20,6 +21,7 @@ echo " if ( $subnetDN != ""){ if( delete_dhcpsubnet($subnetDN,$cn)){ $mesg = "Subnet ".$cn." erfolgreich gelöscht!

"; + update_dhcpmtime(); }else{ $mesg = "Fehler beim löschen des Subnets ".$cn." !

"; } 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 @@ - - - + - - + + - - - - - - + + - +

DHCP 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 "

"; + $poollist = "
    "; + foreach ($pools as $pool){ + $poollist .= "
  • "; + if (count($pool['dhcprange']) >1){ + for ($i=0; $i
    "; } + $poollist .= "
"; + + # Dienstzuordnung des Subnetzes + $dhcpservice = ""; if ($subnet['dhcphlpcont'] != ""){ $exp = ldap_explode_dn($subnet['dhcphlpcont'],1); $dhcpservice = $exp[0]."  [".$exp[2]."]"; - }else{ - $dhcpservice = ""; } + $subnetcn = "".$subnet['cn'].""; $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 @@ +"; +#print_r(count($fipb_array)); echo "
"; +$ipblocks = ""; + +# print_r($mipb_array); +if ($mipb_array[0] != "" ){ + if (count($mipb_array) > 1 ){ + $ipblocks .= "
SubnetNetmaskDHCP DienstRangeHostobjekteNetmaskDHCP ServiceDynamic Pools (IP Ranges)
{SUBNETCN}   {NETMASK}  {DHCP} {RANGE}  - - {HOSTS}
- -
{POOLS} 
+ "; + foreach ($mipb_array as $mipb){ + $exp = explode('_',$mipb); + $ipblocks .= " + + "; + } + } + elseif (count($mipb_array) == 1){ + $ipblocks .= "
+

Zugewiesene IP Bereiche:

$exp[0]  - $exp[1] 
+ "; + $exp = explode('_',$mipb_array[0]); + $ipblocks .= " + + "; + } + elseif( $fipb_array[0] == "" ){ + $ipblocks .= "
+

Zugewiesener IP Bereich:

$exp[0]  - $exp[1] 
+ "; + } + if (count($fipb_array) > 1 ){ + $ipblocks .= "

Keine IP Adressen mehr verfügbar

+ + "; + foreach ($fipb_array as $fipb){ + $exp = explode('_',$fipb); + $ipblocks .= " + + "; + } + } + elseif (count($fipb_array) == 1){ + $ipblocks .= "
+

Davon noch frei verfügbar:

$exp[0]  - $exp[1] 
+ "; + $exp = explode('_',$fipb_array[0]); + $ipblocks .= " + + "; + } + +} + +if( $mipb_array[0] == "" ){ + $ipblocks .= "
+

Davon noch frei verfügbar:

$exp[0]  - $exp[1] 
+ "; +} +$ipblocks .= "

Ihnen wurden keine IP Adressen zugewiesen

"; + +$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 @@ + + + + + + + + + + +
{IPBLOCKS}
\ 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 @@
AttributWertAttributWert
DHCP Subnet (cn):
(Teil des dn, ohne Leerzeichen eingeben)  
- -
Netmask:
DHCP Subnet (+ Netmask):
+ (Noch freie verfügbare Netze)  
- +
DHCP Dienst wählen: - @@ -46,14 +47,14 @@
- - + + 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; $iassign(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 "
"; @@ -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 @@
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 "
"; -# print_r($oldip);echo "
"; $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 "
"; -# print_r($diff2);echo "
"; -# print_r($tochange);echo "

"; foreach ($tochange as $i){ if ( $oldip[$i] == "" && $newip[$i] != "" ){ echo "neue IP";echo "
";echo "
"; - #print_r($auDN[$i]);echo "
"; - #print_r($hostDN[$i]);echo "
"; echo "
"; echo "alte IP: ";print_r($oldip[$i]);echo "
"; echo "neue IP: ";print_r($newip[$i]);echo "
"; @@ -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
"; + update_dhcpmtime(); }else{$mesg = "Fehler beim eintragen der neuen IP Adresse
";} }else{echo "falsche IP Syntax";} @@ -60,8 +53,6 @@ foreach ($tochange as $i){ elseif ( $oldip[$i] != "" && $newip[$i] != "" ){ echo "aendern IP";echo "
";echo "
"; - #print_r($auDN[$i]);echo "
"; - #print_r($hostDN[$i]);echo "
"; echo "
"; echo "alte IP: ";print_r($oldip[$i]);echo "
"; echo "neue IP: ";print_r($newip[$i]);echo "
"; @@ -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
"; + adjust_hostip_tftpserverip($oldip[$i],$newip[$i]); + update_dhcpmtime(); }else{ $mesg = "Fehler beim aendern der IP Adresse
"; # 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 .= "
Sie werden automatisch auf die vorherige Seite zurückgeleitet.
@@ -91,8 +84,6 @@ foreach ($tochange as $i){ elseif ( $oldip[$i] != "" && $newip[$i] == "" ){ echo "loeschen IP";echo "
";echo "
"; - #print_r($auDN[$i]);echo "
"; - #print_r($hostDN[$i]);echo "
"; echo "
"; echo "alte IP: ";print_r($oldip[$i]);echo "
"; echo "neue IP: ";print_r($newip[$i]);echo "
"; @@ -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
"; + adjust_hostip_tftpserverip($oldip[$i],""); + update_dhcpmtime(); }else{$mesg = "Fehler beim loeschen der IP Adresse
";} $mesg .= "
Sie werden automatisch auf die vorherige Seite zurückgeleitet.
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 "
"; + 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 "
dhcpMTime erfolgreich aktualisiert!
" ; + return 1; + }else{ + echo "
Fehler beim Aktualisieren der dhcpMTime!
" ; + } +} + + # 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 "
"; 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 ".$range1." - ".$range2." erfolgreich im Subnetobjekt eingetragen"; - }else{ - echo "DHCP Range ".$range1." - ".$range2." konnte nicht im Subnetobjekt eingetragen werden!"; - } - return 1; - }else{ - echo "DHCP Range nicht in Subnetz ".$cn." enthalten.
Keine DHCP Range angelegt.
"; - return 1; - } + printf("Subnet %s / %s 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 ".$range1." - ".$range2." erfolgreich im Subnetobjekt eingetragen"; + # }else{ + # echo "DHCP Range ".$range1." - ".$range2." konnte nicht im Subnetobjekt eingetragen werden!"; + # } + # return 1; + #}else{ + # echo "DHCP Range nicht in Subnetz ".$cn." enthalten.
Keine DHCP Range angelegt.
"; + # return 1; + #} }else{ echo "
Fehler beim anlegen des DHCP Subnet Objekts!
"; 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 "
FIPBs erfolgreich angepasst!
" ; 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 "

"; + 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 "

"; + print_r($entrydhcp);echo "

"; + + 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!
"; 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:
"; print_r($host_ips); echo "

"; + + # 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:
"; print_r($dhcps_ips); echo "

"; + + # 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:
"; print_r($dhcpr_ips); echo "

"; + + # 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:
"; print_r($deleg_ips); echo "

"; + + $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("
"); foreach ( $fipb_array as $item ){ - $entry ['FreeIPBlock'][] = $item; - } + $entry ['FreeIPBlock'][] = $item; + } $results = ldap_mod_replace($ds,$auDN,$entry); if ($results) echo "
FIPBs erfolgreich zusammengefasst!

" ; else echo "
Fehler beim eintragen der FIPBs!

"; @@ -376,6 +484,55 @@ function merge_ipranges($auDN) else echo "
Fehler beim eintragen der MIPBs!

"; } +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 "
DHCP Ranges erfolgreich zusammengefasst!

" ; + else echo "
Fehler beim eintragen der DHCP Ranges!

"; +} + +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 "
Neue FIPBs erfolgreich eingetragen!
"; + $rangeentry ['dhcprange'] = $newrange; + print_r($rangeentry);echo "

"; + $result2 = ldap_mod_add($ds,$pooldn,$rangeentry); + if ($result2){ + merge_dhcpranges($pooldn); + #printf("Neue dynamische IP Range %s - %s erfolgreich in Subnetz %s0 eingetragen!
",$addrange1[$i],$addrange2[$i],$net); + return 1; + }else{ + # echo "
Fehler beim eintragen des dynamischen DHCP Pools!
"; + # Range wieder in FIPBs aufnehmen. + $entry2 ['FreeIPBlock'] = $newrange; + ldap_mod_add($ds,$auDN,$entry2); + merge_ipranges($auDN); + return 0; + } + }else{ + echo "
Fehler beim eintragen der FIPBs!
"; + return 0; + } + }else{ + printf("
IP Range %s ist nicht im verfuegbaren Bereich!
", $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 "

"; + $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 "
dhcpMTime erfolgreich aktualisiert!
" ; + }else{ + echo "
Fehler beim Aktualisieren der dhcpMTime!
" ; + } + } } } @@ -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 "
dhcpMTime erfolgreich aktualisiert!
" ; + }else{ + echo "
Fehler beim Aktualisieren der dhcpMTime!
" ; + } + } + } } +# 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 @@ - + + + Hostname: {TFTP}  [IP: {TFTPIP}] - - + 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
"; +} -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." :
"; @@ -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']."
TFTP Server erfolgreich geändert
"; + $mesg .= "Treffer: Rechner ".$host['hostname']."
TFTP Server erfolgreich eingetragen
"; }else{ - $mesg .= "Fehler beim ändern des TFTP Servers!
"; + $mesg .= "Fehler beim Eintragen des TFTP Servers!
"; } 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 ".$newfsuri." anlegen
"; - - $entryfsadd ['fileserveruri'] = $newfsuri; - if(ldap_mod_add($ds,$rbsDN,$entryfsadd)){ - $mesg = "FS URI erfolgreich eingetragen

"; - }else{ - $mesg = "Fehler beim eintragen der FS URI

"; - } - } - else{echo "Falsche IP Syntax

";} -} - -##################################### -# Fileserver URIs löschen -if ( count($delfsuri) != 0 ){ - echo "Fileserver URI löschen
"; - - $i = 0; - foreach ($delfsuri as $fsuri){ - $entry['fileserveruri'][$i] = $fsuri; - $i++; - } - #print_r($entry); echo "

"; - - if ($result = ldap_mod_del($ds,$rbsDN,$entry)){ - $mesg = "Zu löschende Fileserver URIs erfolgreich gelöscht

"; - }else{ - $mesg = "Fehler beim löschen der Fileserver URIs

"; - } -} - -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." :
"; + $mesg .= "Suche nach dem Rechner mit IP ".$tftpserverip." :
"; 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']."
NFS Server erfolgreich geändert
"; + if ($tftpserverip == $hostip){ + $entrytftp ['tftpserverip'] = $tftpserverip; + if (ldap_mod_replace($ds,$rbsDN,$entrytftp)){ + adjust_dhcpnextserver($tftpserverip, $rbsDN); + $mesg .= "Treffer: Rechner ".$host['hostname']."
TFTP Server erfolgreich geändert
"; }else{ - $mesg .= "Fehler beim ändern des NFS Servers!
"; + $mesg .= "Fehler beim ändern des TFTP Servers!
"; } break; }else{ - $mesg .= "Rechner ".$host['hostname'].": keine Übereinstimmung mit eingegebener IP ".$nfsserverip."!
"; + $mesg .= "Rechner ".$host['hostname'].": keine Übereinstimmung mit eingegebener IP ".$tftpserverip."!
"; } } } @@ -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." :
"; - 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']."
NBD Server erfolgreich geändert
"; - }else{ - $mesg .= "Fehler beim ändern des NBD Servers!
"; - } - break; - }else{ - $mesg .= "Rechner ".$host['hostname'].": keine Übereinstimmung mit eingegebener IP ".$nbdserverip."!
"; - } - } - } - else{ - $mesg .= "Falsche IP Syntax!
"; +if ( $tftpserverip == "" && $oldtftpserverip != "" ){ + $entrytftp ['tftpserverip'] = array(); + if (ldap_mod_del($ds,$rbsDN,$entrytftp)){ + adjust_dhcpnextserver($tftpserverip, $rbsDN); + $mesg .= "Treffer: Rechner ".$host['hostname']."
TFTP Server erfolgreich gelöscht
"; + }else{ + $mesg .= "Fehler beim löschen des TFTP Servers!
"; } -} - -##################################### -# 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
"; }else{ $mesg .= "Fehler beim ändern des TFTP Servers!
"; - } - + } } -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
"; - }else{ - $mesg .= "Fehler beim ändern des NFS Servers!
"; - } - -} - -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
"; - }else{ - $mesg .= "Fehler beim ändern des NBD Servers!
"; - } - -} ##################################### # 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 ".$newfsuri." anlegen
"; + + $entryfsadd ['fileserveruri'] = $newfsuri; + if(ldap_mod_add($ds,$rbsDN,$entryfsadd)){ + $mesg = "FS URI erfolgreich eingetragen

"; + }else{ + $mesg = "Fehler beim eintragen der FS URI

"; + } + } + else{echo "Falsche IP Syntax

";} +} + +##################################### +# Fileserver URIs löschen + +if ( count($delfsuri) != 0 ){ + echo "Fileserver URI löschen
"; + + $i = 0; + foreach ($delfsuri as $fsuri){ + $entry['fileserveruri'][$i] = $fsuri; + $i++; + } + #print_r($entry); echo "

"; + + if ($result = ldap_mod_del($ds,$rbsDN,$entry)){ + $mesg = "Zu löschende Fileserver URIs erfolgreich gelöscht

"; + }else{ + $mesg = "Fehler beim löschen der Fileserver URIs

"; + } +} ##################################### 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; -- cgit v1.2.3-55-g7522
OptionWert(e)OptionWert(e)
-

Dieses Modul dient der Verwaltung des DHCP Dienstes und DHCP Subnetzen.
+

Verwaltung von DHCP Subnets, Pools (und Classes).

- Sie verfügen über keine kompletten Netzwerke!
+ Sie verfügen über keine IP Adressen, so dass Sie keine dieser Objekte + anlegen bzw. verwalten können.
+
- 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
+ Modul Rechner Management.

     
TFTP Server:   - - TFTP Root +
{TFTP}ändern: - - + PXE Path