Translations of this page:

How to add an object type in the types we can add into an ogroup

This is intended to serve as an example of plugin modification. Here the point was to be able to add DSA accounts into object groups.

First, we had to add them in the object types listed in the object selection screen (the list you see when you click the button to add a member in a group). This is quite easy, we just add our type to the list:

--- ./include/select/objectSelect/class_objectSelect.inc    2016-09-26 10:22:08.316429999 +0000
+++ ./include/select/objectSelect/class_objectSelect.inc    2016-09-26 10:22:49.444429999 +0000
@@ -23,7 +23,7 @@
 {
   protected $objectTypes = array(
     'user', 'application',  'terminal', 'workstation',
-    'winstation', 'server', 'printer',  'phone'
+    'winstation', 'server', 'printer',  'phone', 'simpleSecurityObject'
   );
   protected $autoFilterAttributes = array('dn', 'cn', 'uid', 'description');
 }

To know what was the object type, I looked into my plugin and saw that DSA entries were defined in class_simpleSecurityObject.inc with:

'plObjectType'  => array('simpleSecurityObject' => array(

So, now I can add my DSA entries to groups, but these groups appear as containing unknown objects. So I need to assign a letter to DSA entries object type in the ogroup class:

--- ./plugins/admin/groups/class_ogroup.inc    2016-09-26 11:42:38.284429999 +0000
+++ ./plugins/admin/groups/class_ogroup.inc    2016-09-26 10:45:30.012429999 +0000
@@ -147,6 +147,7 @@
     'T' => 'terminal',
     'F' => 'phone',
     'P' => 'printer',
+    'D' => 'simpleSecurityObject'
   ); 

So now my groups have the D letter in gosaGroupObjects but they do not appear in the list anymore because this does not match any existing filter. The last step is to add a filter for these groups:

--- ./plugins/admin/groups/group-filter.xml    2016-09-26 11:43:11.076429999 +0000
+++ ./plugins/admin/groups/group-filter.xml    2016-09-26 11:00:24.476429999 +0000
@@ -10,7 +10,7 @@
   <search>
     <query>
       <backend>LDAP</backend>
-      <filter>(&amp;(|(&amp;(objectClass=posixGroup)(|$PRIMARY$MAIL$SAMBA))$ROLE(&amp;(objectClass=groupOfNames)(|(gosaGroupObjects=[])$USER$GROUP$APPLICATION$SERVER$WORKSTATION$WINDOWS$TERMINAL$PRINTER$PHONE$UNKNOWN)))$NAME)</filter>
+      <filter>(&amp;(|(&amp;(objectClass=posixGroup)(|$PRIMARY$MAIL$SAMBA))$ROLE(&amp;(objectClass=groupOfNames)(|(gosaGroupObjects=[])$USER$GROUP$APPLICATION$SERVER$WORKSTATION$WINDOWS$TERMINAL$PRINTER$PHONE$SIMPLESECURITYOBJECT$UNKNOWN)))$NAME)</filter>
       <attribute>dn</attribute>
       <attribute>objectClass</attribute>
       <attribute>cn</attribute>
@@ -126,6 +126,14 @@

   <element>
     <type>checkbox</type>
+    <tag>SIMPLESECURITYOBJECT</tag>
+    <default>true</default>
+    <unset></unset>
+    <set>(gosaGroupObjects=*D*)</set>
+  </element>
+
+  <element>
+    <type>checkbox</type>
     <tag>UNKNOWN</tag>
     <default>false</default>
     <unset></unset>

And we need to add this filter to the filters, but only if DSA plugin is installed, for this we check if the PHP class simpleSecurityObject, which is inside the plugin, is available.

--- ./plugins/admin/groups/class_groupManagement.inc    2016-09-26 11:43:28.476429999 +0000
+++ ./plugins/admin/groups/class_groupManagement.inc    2016-09-26 11:15:13.520429999 +0000
@@ -139,6 +139,9 @@
     if (class_available('sambaAccount')) {
       $filters[]= array('id'  => 'SAMBA',       'label'  => _('Show samba groups'));
     }
+    if (class_available('simpleSecurityObject')) {
+      $filters[]= array('id'  => 'SIMPLESECURITYOBJECT',       'label'  => _('Show DSA entries'));
+    }
     if (class_available('systemManagement')) {
       $filters = array_merge(
         $filters,
en/documentation_dev/edit_ogroup_object_types.txt · Last modified: 2016/10/03 16:32 by Côme Chilliet
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0