array('posixGroup'), 'conflicts' => array()); // available PDF fields $return['PDF_fields'] = array( 'gidNumber', 'sambaSID', 'displayName', 'sambaGroupType', 'description'); // upload fields $return['upload_columns'] = array( array( 'name' => 'sambaGroupMapping_domain', 'description' => _('Samba 3 domain name'), 'help' => 'TODO', 'example' => _('domain1'), 'required' => true ), array( 'name' => 'sambaGroupMapping_name', 'description' => _('Samba 3 display name'), 'help' => 'TODO', 'example' => _('Domain administrators'), 'required' => false ), array( 'name' => 'sambaGroupMapping_rid', 'description' => _('Samba 3 rid number'), 'help' => 'TODO', 'example' => 'DOMAIN_ADMINS', 'required' => false ) ); // help Entries $return['help'] = array ( 'displayName' => array ("ext" => "FALSE", "Headline" => _("Display name"), "Text" => _("Windows clients will show display name as group description.")), 'sambaSID' => array ("ext" => "FALSE", "Headline" => _("Windows groupname"), "Text" => _("If you want to use a well known RID you can selcet a well known group.")), 'sambaDomainName' => array ("ext" => "FALSE", "Headline" => _("Domain"), "Text" => _("Windows-Domain of group."). ' '. _("Can be left empty."))); return $return; } // Constructor function init($base) { // call parent init parent::init($base); $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 // 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; function module_ready() { if ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]=='') return false; return true; } /* This functions return true * if all needed settings are done */ function module_complete() { if (!$this->module_ready()) return false; if ($this->attributes['sambaSID'][0] == '') return false; if ($this->attributes['sambaGroupType'][0] == '') return false; return true; } /* This function returns a list of all html-pages in module * This is usefull for mass upload and pdf-files * because lam can walk trough all pages itself and do some * error checkings */ function pages() { return array('attributes'); } /* This function returns all ldap attributes * which are part of sambaGroupMapping and returns * also their values. */ function get_attributes() { return $this->attributes; } /* 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]); $this->orig[$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'; 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['ldap']->search_domains($_SESSION['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); // Add ObjectClass $return[$_SESSION[$this->base]->dn]['notchanged']['objectClass'][0] = 'sambaGroupMapping'; return $return; } function delete_attributes($post) { return 0; } /* Write variables into object and do some regexp checks */ function proccess_attributes($post, $profile=false) { // Load attributes $this->attributes['displayName'][0] = $post['displayName']; $this->attributes['sambaGroupType'][0] = 2; if (!$profile) { // Get Domain SID from name $sambaDomains = $_SESSION['ldap']->search_domains($_SESSION['config']->get_domainSuffix()); for ($i=0; $iname) { $SID = $sambaDomains[$i]->SID; $RIDbase = $sambaDomain[$i]->RIDbase; } // Load attributes $this->attributes['displayName'][0] = $post['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['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]), 'sambaSID'); } } 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 will create the html-page * to show a page with all attributes. * It will output a complete html-table */ function display_html_attributes($post, $profile=false) { // Get Domain SID from name $sambaDomains = $_SESSION['ldap']->search_domains($_SESSION['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; } } $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Display name') ), 1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $this->attributes['displayName'][0]), 2 => array ( 'kind' => 'help', 'value' => 'displayName' )); if (!$profile) { $names = array_keys($this->rids); $wrid=false; for ($i=0; $iattributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) { $selected[] = $names[$i]; $wrid=true; } else $options[] = $names[$i]; } if ($wrid) $options[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0]; else $selected[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0]; $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ), 1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected), 2 => array ( 'kind' => 'help', 'value' => 'sambaSID' )); } $return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ), 1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ( $sel_domain ) ), 2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' )); return $return; } function display_html_delete($post) { return 0; } function get_profileOptions() { $return = array(); // get list of domains $sambaDomains = $_SESSION['ldap']->search_domains($_SESSION['config']->get_domainSuffix()); $sambaDomainNames = array(); for ($i = 0; $i < count($sambaDomains); $i++ ) { // extract names $sambaDomainNames[] = $sambaDomains[$i]->name; } // domain $return[] = array ( 0 => array('kind' => 'text', 'text' => _('Domain')), 1 => array('kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ()), 2 => array('kind' => 'help', 'value' => 'sambaDomainName' )); return $return; } /* * (non-PHPDoc) * @see baseModule#get_pdfEntries */ function get_pdfEntries($account_type = "User") { return array( 'sambaGroupMapping_gidNumber' => array('' . _('GID number') . '' . $this->attributes['gidNumber'][0] . ''), 'sambaGroupMapping_sambaSID' => array('' . _('Windows group') . '' . $this->attributes['sambaSID'][0] . ''), 'sambaGroupMapping_displayName' => array('' . _('Display name') . '' . $this->attributes['displayName'][0] . ''), 'sambaGroupMapping_sambaGroupType' => array('' . _('Samba group type') . '' . $this->attributes['sambaGroupType'][0] . ''), 'sambaGroupMapping_description' => array('' . _('Description') . '' . $this->attributes['description'][0] . '')); } } ?>