本文整理汇总了PHP中Host::setAD方法的典型用法代码示例。如果您正苦于以下问题:PHP Host::setAD方法的具体用法?PHP Host::setAD怎么用?PHP Host::setAD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host::setAD方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_post
/** add_post()
Actually add's the host.
*/
public function add_post()
{
// Hook
$this->HookManager->processEvent('HOST_ADD_POST');
// POST ?
try {
// Error checking
if (empty($_REQUEST['host'])) {
throw new Exception(_('Hostname is required'));
}
if (!$this->getClass('HostManager')->isHostnameSafe($_REQUEST['host'])) {
throw new Exception(_('Please enter a valid hostname'));
}
if (empty($_REQUEST['mac'])) {
throw new Exception(_('MAC Address is required'));
}
$MAC = new MACAddress($_REQUEST['mac']);
if (!$MAC || !$MAC->isValid()) {
throw new Exception(_('MAC Format is invalid'));
}
// Check if host exists with MAC Address.
$Host = $this->getClass('HostManager')->getHostByMacAddresses($MAC);
if ($Host && $Host->isValid()) {
throw new Exception(_('A host with this MAC already exists with Hostname: ') . $Host->get('name'));
}
if ($this->getClass('HostManager')->exists($_REQUEST['host'])) {
throw new Exception(_('Hostname already exists'));
}
// Get all the service id's so they can be enabled.
$ModuleIDs = $this->getClass('ModuleManager')->find('', '', '', '', '', '', '', 'id');
$password = $_REQUEST['domainpassword'];
if ($this->FOGCore->getSetting('FOG_NEW_CLIENT') && $_REQUEST['domainpassword']) {
$password = $this->encryptpw($_REQUEST['domainpassword']);
}
// Define new Image object with data provided
$Host = new Host(array('name' => $_REQUEST['host'], 'description' => $_REQUEST['description'], 'imageID' => $_REQUEST['image'], 'kernel' => $_REQUEST['kern'], 'kernelArgs' => $_REQUEST['args'], 'kernelDevice' => $_REQUEST['dev'], 'useAD' => $_REQUEST["domain"] == "on" ? '1' : '0', 'ADDomain' => $_REQUEST['domainname'], 'ADOU' => $_REQUEST['ou'], 'ADUser' => $_REQUEST['domainuser'], 'ADPass' => $password, 'productKey' => base64_encode($_REQUEST['key'])));
$Host->addModule($ModuleIDs);
$Host->addPriMAC($MAC);
$useAD = isset($_REQUEST['domain']);
$domain = trim($_REQUEST['domainname']);
$ou = trim($_REQUEST['ou']);
$user = trim($_REQUEST['domainuser']);
$pass = trim($_REQUEST['domainpassword']);
$Host->setAD($useAD, $domain, $ou, $user, $pass, true, true);
// Save to database
if ($Host->save()) {
// Hook
$this->HookManager->processEvent('HOST_ADD_SUCCESS', array('Host' => &$Host));
// Log History event
$this->FOGCore->logHistory(sprintf('%s: ID: %s, Name: %s', _('Host added'), $Host->get('id'), $Host->get('name')));
// Set session message
$this->FOGCore->setMessage(_('Host added'));
// Redirect to new entry
$this->FOGCore->redirect(sprintf('?node=%s&sub=edit&%s=%s', $this->REQUEST['node'], $this->id, $Host->get('id')));
} else {
throw new Exception('Database update failed');
}
} catch (Exception $e) {
// Hook
$this->HookManager->processEvent('HOST_ADD_FAIL', array('Host' => &$Host));
// Log History event
$this->FOGCore->logHistory(sprintf('%s add failed: Name: %s, Error: %s', 'Host', $_REQUEST['name'], $e->getMessage()));
// Set session message
$this->FOGCore->setMessage($e->getMessage());
// Redirect to new entry
$this->FOGCore->redirect($this->formAction);
}
}