allow to set the host name (RFE 2898948)
This commit is contained in:
parent
b0e57a1de9
commit
b2c358c770
|
@ -227,6 +227,12 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
|
|||
);
|
||||
// upload fields
|
||||
$return['upload_columns'] = array(
|
||||
array(
|
||||
'name' => 'dhcp_settings_host-name',
|
||||
'description' => _('Host name'),
|
||||
'help' => 'host-name',
|
||||
'example' => _('server01'),
|
||||
),
|
||||
array(
|
||||
'name' => 'dhcp_settings_subnet',
|
||||
'description' => _('Subnet'),
|
||||
|
@ -327,6 +333,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
|
|||
$this->messages['domainname'][4] = array('ERROR', _('Account %s:') . ' dhcp_settings_domainName', _('The domain name needs to have at least 3 characters.'));
|
||||
$this->messages['domainname'][5] = array('ERROR', _('Account %s:') . ' dhcp_settings_domainName', _('The domain name includes invalid characters. Valid characters are A-Z, a-z, 0-9, ".", "_","-".'));
|
||||
$this->messages['host-name'][0] = array('ERROR', _('Host name'), _('Host name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
|
||||
$this->messages['host-name'][1] = array('ERROR', _('Account %s:') . ' dhcp_settings_host-name', _('Host name contains invalid characters. Valid characters are: a-z, A-Z, 0-9 and .-_ !'));
|
||||
}
|
||||
|
||||
/* This function returns an array with 4 entries:
|
||||
|
@ -404,7 +411,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
|
|||
$errors[] = $this->messages['domainname'][2];
|
||||
}
|
||||
}
|
||||
$this->setDHCPOption('domain-name', $_POST['domainname']);
|
||||
$this->setDHCPOption('domain-name', '"' . $_POST['domainname'] . '"');
|
||||
|
||||
// Check DNS
|
||||
if (!empty($_POST['dns'])) {
|
||||
|
@ -477,6 +484,13 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
|
|||
$this->setDHCPOption('netbios-node-type', $_POST['netbios_node_type']);
|
||||
|
||||
if ($this->getAccountContainer()->dn_orig!=$_SESSION['config']->get_suffix('dhcp')) {
|
||||
// check host name
|
||||
if ($_POST['host-name'] != '') {
|
||||
if (!get_preg($_POST['host-name'], 'hostname')) {
|
||||
$errors[] = $this->messages['host-name'][0];
|
||||
}
|
||||
}
|
||||
$this->setDHCPOption('host-name', '"' . $_POST['host-name'] . '"');
|
||||
// Check subnet
|
||||
$_POST['subnet'] = trim($_POST['subnet']);
|
||||
if (!check_ip($_POST['subnet'], true)) {
|
||||
|
@ -535,12 +549,6 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
|
|||
}
|
||||
}
|
||||
|
||||
// host name
|
||||
$return[] = array(
|
||||
array('kind' => 'text', 'text' => _('Host name') . ": "),
|
||||
array('kind' => 'input', 'name' => 'host-name', 'value' => $this->getDHCPOption('host-name')),
|
||||
array('kind' => 'help', 'value' => 'host-name'));
|
||||
|
||||
// Subnet name
|
||||
if ($_SESSION['config']->get_suffix('dhcp') == $this->getAccountContainer()->dn_orig) {
|
||||
$return[] = array(
|
||||
|
@ -549,6 +557,11 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
|
|||
array('kind' => 'help', 'value' => 'subnet'));
|
||||
}
|
||||
else {
|
||||
// host name
|
||||
$return[] = array(
|
||||
array('kind' => 'text', 'text' => _('Host name') . ": "),
|
||||
array('kind' => 'input', 'name' => 'host-name', 'value' => $this->getDHCPOption('host-name')),
|
||||
array('kind' => 'help', 'value' => 'host-name'));
|
||||
$return[] = array(
|
||||
array('kind' => 'text', 'text' => _('Subnet') . ":* "),
|
||||
array('kind' => 'input', 'name' => 'cn', 'value' => $this->attributes['cn'][0]),
|
||||
|
@ -696,7 +709,7 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
|
|||
* @param String $name option name
|
||||
* @return String value
|
||||
*/
|
||||
private function getDHCPOption($name) {
|
||||
public function getDHCPOption($name) {
|
||||
$return = null;
|
||||
if (is_array($this->attributes['dhcpOption'])) {
|
||||
for ($i = 0; $i < sizeof($this->attributes['dhcpOption']); $i++) {
|
||||
|
@ -821,6 +834,17 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
|
|||
// add object class
|
||||
if (!in_array("dhcpOptions", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "dhcpOptions";
|
||||
if (!in_array("dhcpSubnet", $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = "dhcpSubnet";
|
||||
// host name
|
||||
if ($rawAccounts[$i][$ids['dhcp_settings_host-name']] != '') {
|
||||
if (get_preg($rawAccounts[$i][$ids['dhcp_settings_host-name']], 'hostname')) {
|
||||
$partialAccounts[$i]['dhcpOption'][] = 'host-name "' . $rawAccounts[$i][$ids['dhcp_settings_host-name']] . '"';
|
||||
}
|
||||
else {
|
||||
$error = $this->messages['host-name'][1];
|
||||
array_push($error, $i);
|
||||
$messages[] = $error;
|
||||
}
|
||||
}
|
||||
// subnet
|
||||
if (check_ip($rawAccounts[$i][$ids['dhcp_settings_subnet']],true)) {
|
||||
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['dhcp_settings_subnet']];
|
||||
|
|
Loading…
Reference in New Issue