3
* Copyright (c) 2008 Zivios, LLC.
5
* This file is part of Zivios.
7
* Zivios is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* Zivios is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with Zivios. If not, see <http://www.gnu.org/licenses/>.
20
* @package mod_default
21
* @copyright Copyright (c) 2008 Zivios, LLC. (http://www.zivios.org)
22
* @license http://www.zivios.org/legal/license
23
* @version $Id: EMSSudoItem.php 911 2008-08-25 11:06:13Z fkhan $
26
class EMSSudoItem extends EMSSecurityObject
28
private $serviceclass,$computer,$userarray,$grouparray;
29
public function __construct(Ecl_LdapObject $lobj)
31
parent::__construct($lobj);
32
$param = $this->addParameter('cn','SudoItemName',1);
34
$this->addParameter('sudocommand','Sudo Command',1);
35
$this->addParameter('sudohost','Sudo Host',1);
36
$this->addParameter('sudouser','Sudo User',1);
37
$this->addParameter('emsplugins','Ems Plugin attached',1);
42
public function setHost(EMSComputer $computer)
44
$this->setProperty('sudohost',$computer->getProperty('cn'));
48
public function linkToService(Ecl_Service_Plugin $servplug)
50
$this->setProperty('emsplugins',get_class($servplug));
51
$this->setProperty('sudocommand',$servplug->getAdminCommandArray());
55
public function addUser(EMSUser $user,Ecl_Transaction_Handler $handler=null)
57
$userparm = $this->getParameter('sudouser');
58
$userparm->addValue($user->getProperty('uid'));
61
public function addGroup(EMSGroup $group,Ecl_Transaction_Handler $handler=null)
63
$groupparm = $this->getProperty('sudouser');
64
$groupparm->addValue('%'.$group->getProperty('cn'));
65
return parent::update($handler);
68
public function removeUser(EMSUser $user)
70
$userparm = $this->getParameter("sudouser");
71
$userparm->removeValue($user->getProperty('uid'));
74
public function removeGroup(EMSGroup $group)
78
public function makeDn($parent)
80
$class = $this->getProperty('emsplugins');
81
$host = $this->getProperty('sudohost');
82
$parentdn = $parent->getdn();
83
$dn = $this->getrdn()."=".$class."__".$host.",".$parent->getdn();
84
Ecl_Log::debug("Making DN for sudo item returned $dn");
88
public function getrdn()
95
public function add(EMSObject $parent,Ecl_Transaction_Handler $handler=null)
97
if ($handler == null) {
98
$handler = $this->getTransaction();
100
if (get_class($this) == 'EMSSudoItem') {
101
$class = $this->getProperty('emsplugins');
102
$host = $this->getProperty('sudohost');
103
$cn = $class."__".$host;
104
$this->setProperty('cn',$cn);
105
$this->addObjectClass('emssudoitem');
106
$this->addObjectClass('sudorole');
107
$this->addObjectClass('emsignore');
111
if ($this->getProperty('emsdescription') == null) {
112
$this->setProperty('emsdescription','Sudo Entry');
115
$this->setProperty('emstype',self::TYPE_SUDOI);
116
return parent::add($parent,$handler);