当前位置: 首页>>代码示例>>PHP>>正文


PHP Host::setAD方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:bramverstraten,项目名称:fogproject,代码行数:71,代码来源:HostManagementPage.class.php


注:本文中的Host::setAD方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。