summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8b0060a)
raw | patch | inline | side by side (parent: 8b0060a)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 24 Jun 2009 13:50:49 +0000 (13:50 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 24 Jun 2009 13:50:49 +0000 (13:50 +0000) |
-provides uniqe IPs now.
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13786 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13786 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/systems/admin/systems/class_termDNS.inc | patch | blob | history |
diff --git a/gosa-plugins/systems/admin/systems/class_termDNS.inc b/gosa-plugins/systems/admin/systems/class_termDNS.inc
index ef6f8252a6e8e8a7dd865b64230438044418027c..a1aa50bcdcf43ddc85ac28e378f78ec649e1ffeb 100644 (file)
foreach($this->Zones as $key => $name){
if($name == $this->dnsEntry['zoneName']){
$net = DNS::FlipIp(str_replace(".in-addr.arpa","",DNS::getNameFromMix($key)));
- $this->ipHostNumber = $this->generateRandomIp($net);
+ $this->ipHostNumber = $this->generateRandomIP($net);
}
}
}
{
$str = $net;
$cnt = 4;
- while(substr_count($str,".") < 3 && $cnt > 0){
- $str .= ".".rand(0,255);
- $str = preg_replace("/\.\.*/",".",$str);
- $str = trim($str,". ");
- $cnt --;
+
+ // first gather all IPs
+ $ldap = $this->config->get_ldap_link();
+ $ocs =
+ "(objectClass=goFonHardware)".
+ "(objectClass=goServer)".
+ "(objectClass=GOhard)".
+ "(objectClass=gotoTerminal)".
+ "(objectClass=gotoWorkstation)".
+ "(objectClass=gotoPrinter)".
+ "(objectClass=ipHost)";
+ $list = array();
+ $ldap->search("(&(|{$ocs})(ipHostNumber={$net}*))",array("ipHostNumber"));
+ while($attrs = $ldap->fetch()){
+ $list[] = $attrs['ipHostNumber'][0];
}
- return($str);
+
+ // Set starting ip.
+ $ip_data = preg_split("/\./",$net);
+ for($i=0;$i<4;$i++){
+ if(!isset($ip_data[$i])) $ip_data[$i] = 0;
+ }
+
+ // Search the next free and valid ip.
+ while(in_array(implode(".",$ip_data),$list) || $ip_data[3] <= 1){
+ $ip_data[3] ++ ;
+ if($ip_data[3] > 255){
+ $ip_data[3] = 1 ;
+ $ip_data[2] ++ ;
+ }
+ if($ip_data[2] > 255){
+ $ip_data[2] = 1 ;
+ $ip_data[1] ++ ;
+ }
+ if($ip_data[1] > 255){
+ $ip_data[1] = 1 ;
+ $ip_data[0] ++ ;
+ }
+ if($ip_data[0] > 255) break;
+ }
+
+ return(implode(".",$ip_data));
}