diff --git a/gosa-plugins/samba/admin/systems/samba/class_winGeneric.inc b/gosa-plugins/samba/admin/systems/samba/class_winGeneric.inc
index 6a907f6a0f0d0b12845845650b537e7d490cd681..56943662cd4b9cdf341355be1f571b2c4280b606 100644 (file)
var $orig_cn;
var $orig_base;
+ var $baseSelector;
/* attribute list for save action */
var $ignore_account= TRUE;
"shadowInactive","uid","cn","sn","givenName","homeDirectory","sambaSID",
"sambaPrimaryGroupSID","displayName", "sambaPwdMustChange",
"sambaNTPassword","sambaPwdLastSet","sambaAcctFlags");
- var $objectclasses= array("posixAccount","person","organizationalPerson","inetOrgPerson","gosaAccount","shadowAccount","sambaSamAccount","top");
+ var $objectclasses= array("posixAccount","person","organizationalPerson","inetOrgPerson","shadowAccount","sambaSamAccount","top");
var $view_logged = FALSE;
plugin::plugin ($config, $dn, $parent);
$this->netConfigDNS = new termDNS($this->config,$this,$this->objectclasses,FALSE,"uid");
$this->netConfigDNS->cn = preg_replace("/\\\$\$/","",$this->uid);
- $this->netConfigDNS->objectclasses=array("ipHost","ieee802Device");
$this->netConfigDNS->MACisMust = FALSE;
$this->netConfigDNS->IPisMust = FALSE;
+ // The combination of the used objectClasses may differ, remember the initial ones.
+ if(isset($this->attrs['objectClass'])){
+ $this->objectclasses = array();
+ for($i=0; $i < $this->attrs['objectClass']['count'] ; $i++ ){
+ $this->objectclasses[] = $this->attrs['objectClass'][$i];
+ }
+ }
+
/* Set base */
if ($this->dn == "new"){
- $ui= get_userinfo();
- $this->base= dn2base($ui->dn);
+ $ui = get_userinfo();
+ $this->base= dn2base(session::global_is_set("CurrentMainBase")?"cn=dummy,".session::global_get("CurrentMainBase"):$ui->dn);
$this->cn= "";
+ } elseif(class_available("ArpNewDevice") &&
+ preg_match("/".preg_quote(get_ou("ArpNewDevice", "systemIncomingRDN"), '/')."/i", $this->dn)){
+ $this->base= preg_replace ("/^[^,]+,".preg_quote(get_ou("ArpNewDevice", "systemIncomingRDN"), '/')."/i", "", $this->dn);
} else {
$this->base= preg_replace ("/^[^,]+,".preg_quote(get_winstations_ou(), '/')."/i", "", $this->dn);
}
$this->orig_dn= $this->dn;
$this->orig_base= $this->base;
$this->orig_cn= $this->cn;
+
+ /* Instanciate base selector */
+ $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base);
+ $this->baseSelector->setSubmitButton(false);
+ $this->baseSelector->setHeight(300);
+ $this->baseSelector->update(true);
}
return($display);
}
- /* Base select dialog */
- $once = true;
- foreach($_POST as $name => $value){
- if(preg_match("/^chooseBase/",$name) && $once){
- $once = false;
- $this->dialog = new baseSelectDialog($this->config,$this);
- $this->dialog->setCurrentBase($this->base);
- }
- }
-
- /* Dialog handling */
- if(is_object($this->dialog)){
- /* Must be called before save_object */
- $this->dialog->save_object();
-
- if($this->dialog->isClosed()){
- $this->dialog = false;
- }elseif($this->dialog->isSelected()){
-
- /* A new base was selected, check if it is a valid one */
- $tmp = $this->get_allowed_bases();
- if(isset($tmp[$this->dialog->isSelected()])){
- $this->base = $this->dialog->isSelected();
- }
-
- $this->dialog= false;
- }else{
- return($this->dialog->execute());
- }
- }
-
/* Fill templating stuff */
$smarty= get_smarty();
- $smarty->assign("bases" , $this->get_allowed_bases());
+
$tmp = $this->plInfo();
foreach($tmp['plProvidedAcls'] as $name => $translated){
/* Assign attributes */
foreach ($this->attributes as $attr){
- $smarty->assign("$attr", $this->$attr);
+ $smarty->assign("$attr", set_post($this->$attr));
}
- $smarty->assign("base_select", $this->base);
+ $smarty->assign("base", $this->baseSelector->render());
/* Show main page */
$str = $this->netConfigDNS->execute();
$this->netConfigDNS->save_object();
- /* Set new base if allowed */
- $tmp = $this->get_allowed_bases();
- if(isset($_POST['base'])){
- if(isset($tmp[$_POST['base']])){
- $this->base= $_POST['base'];
+ /* Refresh base */
+ if ($this->acl_is_moveable($this->base)){
+ if (!$this->baseSelector->update()) {
+ msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG);
+ }
+ if ($this->base != $this->baseSelector->getBase()) {
+ $this->base= $this->baseSelector->getBase();
+ $this->is_modified= TRUE;
}
}
+
}
/* Call common method to give check the hook */
$message= plugin::check();
$message= array_merge($message, $this->netConfigDNS->check());
- $this->dn= "cn=".$this->uid.",".get_ou('sambaMachineAccountRDN').$this->base;
+ $this->dn= "cn=".$this->uid.",".get_ou("wingeneric", "sambaMachineAccountRDN").$this->base;
if(!$this->acl_is_createable()){
$message[]= msgPool::permCreate();
}
}
+ // Check if a wrong base was supplied
+ if(!$this->baseSelector->checkLastBaseUpdate()){
+ $message[]= msgPool::check_base();;
+ }
+
/* Check if we are allowed to create or move this object
*/
if($this->orig_dn == "new" && !$this->acl_is_createable($this->base)){
$this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
}
+ $curOcs = $this->attrs['objectClass'];
+ $this->cleanup();
+
+ // Prepare list of object classes
+ $ocs = array();
+ if(!empty($this->netConfigDNS->macAddress)){
+ $ocs [] = 'ieee802Device';
+ }else{
+ $curOcs = array_remove_entries(array('ieee802Device'), $curOcs);
+ $this->attrs['macAddress'] = array();
+ }
+ if(!empty($this->netConfigDNS->ipHostNumber)){
+ $ocs [] = 'ipHost';
+ }else{
+ $curOcs = array_remove_entries(array('ipHost'), $curOcs);
+ $this->attrs['ipHostNumber'] = array();
+ }
+
+ $this->attrs['objectClass']=$curOcs;
+
/* Write back to ldap */
$ldap= $this->config->get_ldap_link();
if ($this->orig_dn == 'new'){
}
$ldap->cd($this->dn);
- $this->cleanup();
$ldap->modify ($this->attrs);
new log("modify","winworkstation/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
$this->handle_post_events("modify");
}
- $this->netConfigDNS->cn = preg_replace("/\\\$\$/","",$this->uid);
- $this->netConfigDNS->save();
if (!$ldap->success()){
msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, 0, get_class()));
}
- /* Optionally execute a command after we're done */
- $this->postcreate();
+ // Prepare list of object classes
+ $ocs = array();
+ if(!empty($this->netConfigDNS->macAddress)){
+ $ocs [] = 'ieee802Device';
+ }
+ if(!empty($this->netConfigDNS->ipHostNumber)){
+ $ocs [] = 'ipHost';
+ }
+
+ $this->netConfigDNS->objectclasses=$ocs;
+ $this->netConfigDNS->cn = preg_replace("/\\\$\$/","",$this->uid);
+ $this->netConfigDNS->save();
}
/* Return plugin informations for acl handling
#FIXME FAIscript seams to ununsed within this class... */
static function plInfo()
{
- return (array(
- "plShortName" => _("Win generic"),
- "plDescription" => _("Windows workstation generic"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 0,
- "plSection" => array("administration"),
- "plCategory" => array("winworkstation" => array("description" => _("Win workstation"),
- "objectClass" => "gotoWorkstation")),
+ return (array(
+ "plShortName" => _("Win generic"),
+ "plDescription" => _("Windows workstation generic"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 0,
+ "plSection" => array("administration"),
+ "plCategory" => array("winworkstation" => array("description" => _("Win workstation"),
+ "objectClass" => "gotoWorkstation")),
+
+ "plRequirements"=> array(
+ 'ldapSchema' => array(
+ 'posixAccount' => '',
+ 'organizationalPerson' => '',
+ 'person' => '',
+ 'inetOrgPerson' => '',
+ 'gosaAccount' => '>=2.7',
+ 'shadowAccount' => '',
+ 'sambaSamAccount' => ''
+ ),
+ 'onFailureDisablePlugin' => array(get_class())
+ ),
+
+
+ "plProperties" =>
+ array(
+ array(
+ "name" => "sambaMachineAccountRDN",
+ "type" => "rdn",
+ "default" => "ou=winstations,ou=systems,",
+ "description" => _("RDN for samba machine account storage."),
+ "check" => "gosaProperty::isRdn",
+ "migrate" => "migrate_sambaMachineAccountRDN",
+ "group" => "plugin",
+ "mandatory" => FALSE
+ )
+ ),
+
"plProvidedAcls"=> array(
"cn" => _("Name"),
"base" => _("Base"),