* but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MMC; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ require "modules/samba/includes/machines.inc.php"; require "modules/samba/includes/samba.inc.php"; require "modules/samba/mainSidebar.php"; require "graph/navbar.inc.php"; if (isset($_POST["baddmach"])) { $machine = $_POST["machine"]; $comment = stripslashes($_POST["comment"]); add_machine($machine, $comment); if (!isXMLRPCError()) { new NotifyWidgetSuccess(sprintf(_T("Computer %s successfully added"), $machine)); header("Location: " . urlStrRedirect("samba/machines/index")); exit; } } $p = new PageGenerator(_T("Add a computer")); $p->setSideMenu($sidemenu); $p->display(); $f = new ValidatingForm(); $f->addSummary(_T("The computer name can only contains letters lowercase and numbers, and must begin with a letter.")); $f->push(new Table()); $f->add(new TrFormElement(_T("Computer name"), new NetbiosInputTpl("machine")), array("value" => $machine, "required" => True)); $f->add(new TrFormElement(_T("Comment"), new InputTpl("comment")), array("value" => $comment)); $f->pop();
function add_service($serviceName, $machine, $force) { global $ldapConnection; global $hostGroups; if (!isset($hostGroups[$machine])) { if (add_machine($machine) === false) { echo "Error - machine account {$machine} cannot be created"; exit; } } $servicePassword = generate_ssha(); $newService = array(); $newService['cn'] = $serviceName; $newService['userPassword'] = $servicePassword['hash']; $newService['objectClass'][0] = 'organizationalRole'; $newService['objectClass'][1] = 'simpleSecurityObject'; if (isset($hostGroups[$machine][$serviceName])) { if ($force == true) { $addResult = ldap_modify($ldapConnection, "cn={$serviceName},ou={$machine},ou=machines,dc=netsoc,dc=dit,dc=ie", $newService); } else { echo "Error - service {$serviceName} on machine {$machine} already exists!\n"; return false; } } else { $addResult = ldap_add($ldapConnection, "cn={$serviceName},ou={$machine},ou=machines,dc=netsoc,dc=dit,dc=ie", $newService); } if (!$addResult) { echo "ERROR - Adding of service {$serviceName} account for machine: {$machine} failed!\n"; return false; } return $servicePassword['plaintext']; }