add_objectClass(\'sambaGroupMapping\');'), E_USER_ERROR); $this->base = $base; // sambaGroupMapping is only a valid objectClass for user and host if ($_SESSION[$this->base]->get_type() != 'group') trigger_error(_('sambaGroupMapping can only be used for groups.'), E_USER_WARNING); // Add Array with all attributes and type $this->attributes = $_SESSION[$this->base]->get_module_attributes('sambaGroupMapping'); $_SESSION[$this->base]->add_attributes ('sambaGroupMapping'); $this->alias = _('sambaGroupMapping'); // Make references to attributes which already esists in ldap $newattributes = array_keys($this->attributes); $module = array_keys($_SESSION[$this->base]->module); // fixme *** do we have to unset module posixAccuont itself for ($i=0; $ibase]->module[$module[$i]]->attributes[$attribute])) $this->attributes[$attribute] =& $_SESSION[$this->base]->module[$module[$i]]->attributes[$attribute]; } $this->orig = $this->attributes ; $this->attributes['objectClass'][0] = 'sambaGroupMapping'; $this->rids = array ( _('Domain Admins') => 512, _('Domain Users') => 513, _('Domain Guests') => 514, _('Domain Computers') => 515, _('Domain Controllers') => 516, _('Domain Certificate Admins') => 517, _('Domain Schema Admins') => 518, _('Domain Enterprise Admins') => 519, _('Domain Policy Admins') => 520 ); } // Variables // Alias Name. This name is shown in the menu instead of sambaGroupMapping var $alias; // name of accountContainer so we can read other classes in accuontArray var $base; // This variable contains all inetOrgPerson attributes var $attributes; /* If an account was loaded all attributes are kept in this array * to compare it with new changed attributes */ var $orig; // Array of well known rids var $rids; /* This function returns a list with all required modules */ function dependencies() { return array('posixGroup'); } function module_ready() { if ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]=='') return false; return true; } /* Write variables into object and do some regexp checks */ function proccess_attributes($post) { // Get Domain SID from name $sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix()); for ($i=0; $iname) { $SID = $sambaDomains[$i]->SID; $RIDbase = $sambaDomain[$i]->RIDbase; } // Load attributes $this->attributes['displayName'][0] = $post['form_sambaGroupMapping_displayName']; $this->attributes['sambaGroupType'][0] = 2; $rids = array_keys($this->rids); $wrid = false; for ($i=0; $iattributes['sambaSID'][0] = $SID."-".$this->rids[$rids[$i]]; // Do a check if special grou pis unique if ($_SESSION[$_SESSION[$this->base]->cache]->in_cache($SID."-".$this->rids[$rids[$i]], 'sambaSID', 'group')) $errors[] = array('ERROR', _('Special Group'),sprintf( _('There can be only one group %s.'), $rids[$i])); } } if (!$wrid) $this->attributes['sambaSID'][0] = $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2)+$RIDbase+1; // Return error-messages if (is_array($errors)) return $errors; return 0; } /* This function loads all attributes into the object * $attr is an array as it's retured from ldap_get_attributes */ function load_attributes($attr) { // Load attributes which are displayed // unset count entries unset ($attr['count']); $attributes = array_keys($attr); foreach ($attributes as $attribute) unset ($attr[$attribute]['count']); // unset double entries for ($i=0; $iattributes[$attribute])) { // decode as unicode $this->attributes[$attribute] = $attr[$attribute]; for ($i=0; $iattributes[$attribute]); $i++) $this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]); } } // Values are kept as copy so we can compare old attributes with new attributes $this->attributes['objectClass'][0] = 'sambaGroupMapping'; $this->orig = $this->attributes; return 0; } /* This function returns an array with 3 entries: * array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... ) * DN is the DN to change. It may be possible to change several DNs, * e.g. create a new user and add him to some groups via attribute memberUid * add are attributes which have to be added to ldap entry * remove are attributes which have to be removed from ldap entry * modify are attributes which have to been modified in ldap entry */ function save_attributes() { // Get Domain SID from name $sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix()); // Get Domain-SID from group SID $domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-")); for ($i=0; $iSID) $SID = $sambaDomains[$i]->SID; $names = array_keys($this->rids); $wrid=false; for ($i=0; $iattributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) { $wrid=true; } if (!$wrid) $this->attributes['sambaSID'][0] == $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+1+$RIDbase); $return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig); return $return; } /* This function returns all ldap attributes * which are part of sambaGroupMapping and returns * also their values. */ function get_attributes() { return $this->attributes; } /* This function will create the html-page * to show a page with all attributes. * It will output a complete html-table */ function display_html_attributes($post) { // Get Domain SID from name $sambaDomains = $_SESSION[$_SESSION[$this->base]->ldap]->search_domains($_SESSION[$_SESSION[$this->base]->config]->get_domainSuffix()); // Get Domain-SID from group SID $domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-")); for ($i=0; $iname; if ($domainSID==$sambaDomains[$i]->SID) { $SID = $sambaDomains[$i]->SID; $sel_domain = $sambaDomains[$i]->name; } } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
" . _("Display name") . "attributes['displayName'][0]."\">" . _('Help') . "
" . _('Special group') . "" . _('Help') . "
" . _('Domain') . "" . _('Help') . "
\n"; return 0; } } ?>