added fix for wrong spelled object classes

This commit is contained in:
Roland Gruber 2006-04-05 15:48:27 +00:00
parent c949bd8f86
commit 79a8a315a6
18 changed files with 184 additions and 30 deletions

View File

@ -229,9 +229,52 @@ is set dynamically<br>
</table>
<br>
<br>
<h2><br>
<h2>6. Managed object classes<br>
</h2>
<h2></h2>
You can tell LAM what object classes are managed by your module.<br>
LAM will then check the spelling of the objectClass attributes and
correct it automatically. This is useful if other applications (e.g.
smbldap-tools) also create accounts and the spelling is differnt.<br>
<br>
<span style="font-weight: bold; text-decoration: underline;">Example:</span><br>
<br>
The <span style="font-style: italic;">ieee802Device</span> module
manages one object class.<br>
<br>
<table style="width: 100%; text-align: left;" class="mod-code"
border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top;">&nbsp;&nbsp;&nbsp; /**<br>
&nbsp;&nbsp;&nbsp; * Returns meta data that is interpreted by parent
class<br>
&nbsp;&nbsp;&nbsp; *<br>
&nbsp;&nbsp;&nbsp; * @return array array with meta data<br>
&nbsp;&nbsp;&nbsp; */<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">function</span>
get_metaData() {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $return = array();<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // manages host accounts<br>
<span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; </span>$return["account_types"] = array("host");<br
style="color: rgb(255, 0, 0);">
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // alias name<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;$return["alias"] = _("MAC
address");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // module dependencies<br>
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; &nbsp;$return['dependencies'] = array('depends' =&gt;
array('account'), 'conflicts' =&gt; array());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // managed object classes<br>
<span style="color: rgb(255, 0, 0);">&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp; &nbsp;$return['objectClasses'] = array('ieee802Device');</span><br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return $return;<br>
&nbsp;&nbsp;&nbsp; }<br>
</td>
</tr>
</tbody>
</table>
<br>
<br>
<span style="font-weight: bold;"></span>

View File

@ -123,7 +123,27 @@ The resulting LDAP filter will look like this:
style="font-style: italic;">return "('or' =&gt;
'(objectClass=posixAccount)', 'and' =&gt; '(!(uid=*$))')"</span></span><br>
<span style="font-weight: bold; color: rgb(255, 0, 0);"></span><br>
<h3>2.1.5. get_RDNAttributes*</h3>
<h3>2.1.5. getManagedObjectClasses*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; text-align: center;"><span
style="font-weight: bold;">function getManagedObjectClasses()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns an array of object class names which are managed by this module.<br>
<span style="font-weight: bold;"></span><br>
This is used to fix spelling errors in LDAP-Entries (e.g. if
"posixACCOUNT" is read instead of "posixAccount" from LDAP).<br>
<br>
<span style="font-weight: bold;">Example: <span
style="font-style: italic;">return "('posixAccount')"</span></span><br>
<span style="font-weight: bold; color: rgb(255, 0, 0);"></span><br>
<h3>2.1.6. get_RDNAttributes*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -147,8 +167,8 @@ for the RDN selection.<br>
style="font-style: italic;">return "('uid' =&gt;
'normal', 'cn' =&gt; 'low')"</span></span><br>
<br>
<span style="font-weight: bold; color: rgb(255, 0, 0);"></span><br>
<h3>2.1.6. get_dependencies*</h3>
<span style="font-weight: bold; color: rgb(255, 0, 0);"></span>
<h3>2.1.7. get_dependencies*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -178,7 +198,7 @@ your module depends on one of these modules.<br>
=&gt; array("exim"));</span><br
style="font-weight: bold; font-style: italic;">
<br>
<h3>2.1.7. get_metaData()</h3>
<h3>2.1.8. get_metaData()</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -195,7 +215,7 @@ Returns an hash array including meta data for the baseModule.<br>
<span style="font-weight: bold;">Example: return array("is_base" =&gt;
true);</span><br style="font-weight: bold;">
<br>
<h3>2.1.8. get_configOptions()*</h3>
<h3>2.1.9. get_configOptions()*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -224,7 +244,7 @@ as keywords to load and save settings. We recommend to use the module
name as prefix for them (e.g. posixAccount_homeDirectory) to avoid
naming confilcts.<br>
<br>
<h3>2.1.9. get_configDescriptions()*</h3>
<h3>2.1.10. get_configDescriptions()*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -249,7 +269,7 @@ array with this format:<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 'descriptions' =&gt; array('option1'
=&gt; 'description1', ...))</span><br>
<br>
<h3>2.1.10. check_configOptions*</h3>
<h3>2.1.11. check_configOptions*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -277,7 +297,7 @@ If no errors occured the function returns an empty array.<span
style="font-weight: bold;"></span><br>
<br style="font-weight: bold;">
<span style="font-weight: bold;"></span>
<h3>2.1.11. get_scope()</h3>
<h3>2.1.12. get_scope()</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -294,7 +314,7 @@ Returns the account type (user/group/host) of this module object.<br>
<span style="font-weight: bold;">This function is provided by the
baseModule and should not be overwritten.</span><br>
<br>
<h3>2.1.12. get_uploadColumns*</h3>
<h3>2.1.13. get_uploadColumns*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -339,7 +359,7 @@ all values of this column must be different values <span
</li>
</ul>
<br>
<h3>2.1.13. get_uploadPreDepends*</h3>
<h3>2.1.14. get_uploadPreDepends*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -355,7 +375,7 @@ Returns a list of module names which must be processed before this
module at builing accounts.<br>
The named modules may not be active, LAM will check this automatically.<br>
<br>
<h3>2.1.14. build_uploadAccounts</h3>
<h3>2.1.15. build_uploadAccounts</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -382,7 +402,7 @@ format is the same as used for ldap_add().<br>
Returns an array which contains sub arrays to generate StatusMessages
if any errors occured.<br>
<br>
<h3>2.1.15. do_uploadPostActions</h3>
<h3>2.1.16. do_uploadPostActions</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -428,7 +448,7 @@ array()</span>&nbsp;&nbsp; // List of arrays which are used to generate
StatusMessages<br>
&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">)</span><br>
<br>
<h3>2.1.16. get_profileOptions*</h3>
<h3>2.1.17. get_profileOptions*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -452,7 +472,7 @@ as keywords to load and save profiles. We recommend to use the module
name as prefix for them (e.g. posixAccount_homeDirectory) to avoid
naming confilcts.<br>
<br>
<h3>2.1.17. check_profileOptions*</h3>
<h3>2.1.18. check_profileOptions*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -476,7 +496,7 @@ head, 2 =&gt; message text, 3 =&gt; additional variables).<br>
If no errors occured the function returns an empty array.<span
style="font-weight: bold;"></span><br>
<br>
<h3>2.1.18. load_profile*</h3>
<h3>2.1.19. load_profile*</h3>
<br>
<table border="0" cellpadding="2" cellspacing="2">
<tbody>
@ -934,9 +954,9 @@ of string. This is the list of pre selected elements, must contain
values that are also in <span style="font-style: italic;">options</span>.</li>
<li><span style="font-weight: bold;">descriptiveOptions:</span>
Boolean value, if set to true then all elements in options
must be arrays themselves (array(<span
style="font-style: italic;">value</span>, <span
style="font-style: italic;">description</span>)) (default: false)<br>
must be arrays themselves (array(<span style="font-style: italic;">value</span>,
<span style="font-style: italic;">description</span>)) (default:
false)<br>
</li>
<li><span style="font-weight: bold;">size:</span> The size of the
select field, if set to 1 a dropdown box will be displayed.</li>
@ -1247,7 +1267,15 @@ array("user", "host")</span><br style="font-weight: bold;">
'objectClass=posixAccount', 'and' =&gt; '(!(uid=*$))')<br>
<br>
</span>
<h3>6.4 get_RDNAttributes()</h3>
<h3>6.4 getManagedObjectClasses()</h3>
&nbsp;&nbsp;&nbsp; "objectClasses" =&gt; array<br>
<br>
<span style="font-weight: bold;">&nbsp;&nbsp; Example:</span><span
style="font-style: italic; font-weight: bold;"> array('posixAccount')<br>
<br>
</span>
<span style="font-style: italic; font-weight: bold;"></span>
<h3>6.5 get_RDNAttributes()</h3>
&nbsp;&nbsp;&nbsp; "RDN" =&gt; array<br>
<br>
<span style="font-weight: bold;">&nbsp;&nbsp; Example:</span><span
@ -1256,7 +1284,7 @@ array("user", "host")</span><br style="font-weight: bold;">
<br>
</span>
<span style="font-style: italic; font-weight: bold;"></span>
<h3>6.5 get_dependencies()<br>
<h3>6.6 get_dependencies()<br>
</h3>
&nbsp;&nbsp;&nbsp; "dependencies" =&gt; array<br>
<br>
@ -1268,7 +1296,7 @@ array("user", "host")</span><br style="font-weight: bold;">
=&gt; array("exim")</span></span><span
style="font-style: italic; font-weight: bold;">)<br>
</span><br>
<h3>6.6 get_profileOptions()<br>
<h3>6.7 get_profileOptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "profile_options" =&gt; array<br>
<br>
@ -1277,7 +1305,7 @@ array("user", "host")</span><br style="font-weight: bold;">
return value of get_profileOptions().<br>
<br>
</span></span>
<h3>6.7 check_profileOptions()<br>
<h3>6.8 check_profileOptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "profile_checks" =&gt; array<br>
<br>
@ -1352,7 +1380,7 @@ head, 2 =&gt; message text, 3 =&gt; additional variables)</li>
</ul>
</ul>
<br>
<h3>6.8 load_profile()<br>
<h3>6.9 load_profile()<br>
</h3>
&nbsp;&nbsp;&nbsp; "profile_mappings" =&gt; array('profile_identifier1'
=&gt; 'LDAP_attribute1', 'profile_identifier2' =&gt; 'LDAP_attribute2')<br>
@ -1361,7 +1389,7 @@ head, 2 =&gt; message text, 3 =&gt; additional variables)</li>
$this-&gt;attributes.<br>
<span style="font-weight: bold;"><span style="font-style: italic;"><br>
</span></span>
<h3>6.9 get_configOptions()<br>
<h3>6.10 get_configOptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "config_options" =&gt; array('user' =&gt; array,
'host' =&gt; array, 'all' =&gt; array)<br>
@ -1377,7 +1405,7 @@ the
return value of get_configOptions().<br>
<br>
</span></span>
<h3>6.10 get_configDescriptions()<br>
<h3>6.11 get_configDescriptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "config_descriptions" =&gt; array<br>
<br>
@ -1386,7 +1414,7 @@ return value of get_configOptions().<br>
return value of get_configDescriptions().<br>
<br>
</span></span>
<h3>6.11 check_configOptions()<br>
<h3>6.12 check_configOptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "config_checks" =&gt; array('user' =&gt; array,
'host' =&gt; 'array', 'all' =&gt; array)<br>
@ -1400,14 +1428,14 @@ the other values only if they are inside the <span
check_profileOptions().<br>
<br>
</span></span>
<h3>6.12 get_uploadColumns()</h3>
<h3>6.13 get_uploadColumns()</h3>
"upload_columns" =&gt; array()<br>
<span style="font-weight: bold;"><br>
<span style="font-style: italic;">Syntax for array is the same as for
the
return value of get_uploadColumns().<br>
</span></span><br>
<h3>6.13 get_uploadPreDepends()</h3>
<h3>6.14 get_uploadPreDepends()</h3>
"upload_preDepends" =&gt; array()<br>
<span style="font-weight: bold;"><br>
<span style="font-style: italic;">Syntax for array is the same as for

View File

@ -664,6 +664,17 @@ class baseModule {
function display_html_delete(&$post) {
return 0;
}
/**
* Returns a list of managed object classes for this module.
* This is used to fix incorrect spelled object class names.
*
* @return array list of object classes
*/
function getManagedObjectClasses() {
if (isset($this->meta['objectClasses']) && is_array($this->meta['objectClasses'])) return $this->meta['objectClasses'];
else return array();
}
}

View File

@ -1376,6 +1376,8 @@ class accountContainer {
$attrNames = array_keys($attr);
for ($i = 0; $i < sizeof($attrNames); $i++) unset($attr[$attrNames[$i]]['count']);
unset($attr['count']);
// fix spelling errors
$attr = $this->fixLDAPAttributes($attr, $modules);
// get binary attributes
$binaryAttr = array('jpegPhoto');
for ($i = 0; $i < sizeof($binaryAttr); $i++) {
@ -1399,7 +1401,50 @@ class accountContainer {
// sort module buttons
$this->sortModules();
return 0;
}
/**
* Fixes spelling errors in the attribute names.
*
* @param array $attributes LDAP attributes
* @param array $modules list of active modules
* @return array fixed attributes
*/
function fixLDAPAttributes($attributes, $modules) {
if (!is_array($attributes)) return $attributes;
$keys = array_keys($attributes);
// get correct object class names
$objectClasses = array();
foreach ($modules as $module) {
$moduleObj = new $module($this->type);
$objectClasses = array_merge($objectClasses, $moduleObj->getManagedObjectClasses());
}
// check object classes
for ($i = 0; $i < sizeof($keys); $i++) {
if (strtolower($keys[$i]) == 'objectclass') {
// fix object class attribute
if ($keys[$i] != 'objectClass') {
$temp = $attributes[$keys[$i]];
unset($attributes[$keys[$i]]);
$attributes['objectClass'] = $temp;
}
// fix object classes
for ($attrClass = 0; $attrClass < sizeof($attributes['objectClass']); $attrClass++) {
for ($modClass = 0; $modClass < sizeof($objectClasses); $modClass++) {
if (strtolower($attributes['objectClass'][$attrClass]) == strtolower($objectClasses[$modClass])) {
if ($attributes['objectClass'][$attrClass] != $objectClasses[$modClass]) {
unset($attributes['objectClass'][$attrClass]);
$attributes['objectClass'][] = $objectClasses[$modClass];
}
break;
}
}
}
break;
}
}
return $attributes;
}
/**
* This function will prepare the object for a new account.

View File

@ -59,6 +59,8 @@ class account extends baseModule {
$return["RDN"] = array("uid" => "low");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('account');
// available PDF fields
$return['PDF_fields'] = array(
'description'

View File

@ -47,6 +47,8 @@ class ieee802Device extends baseModule {
$return["alias"] = _("MAC address");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('ieee802Device');
// help Entries
$return['help'] = array(
'mac' => array(

View File

@ -47,6 +47,8 @@ class inetLocalMailRecipient extends baseModule {
$return["alias"] = _("Mail routing");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('inetLocalMailRecipient');
// help Entries
$return['help'] = array(
'routingAdr' => array(

View File

@ -96,6 +96,8 @@ class inetOrgPerson extends baseModule {
$return["ldap_filter"] = array('or' => "(objectClass=inetOrgPerson)");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('inetOrgPerson');
// profile elements
$return['profile_options'] = array(
array(

View File

@ -73,6 +73,8 @@ class kolabUser extends baseModule {
$return['dependencies'] = array('depends' => array('inetOrgPerson'), 'conflicts' => array());
// LDAP filter
$return["ldap_filter"] = array('or' => "(objectClass=kolabInetOrgPerson)");
// managed object classes
$return['objectClasses'] = array('kolabInetOrgPerson');
// profile options
$return['profile_options'] = array(
array(
@ -242,7 +244,6 @@ class kolabUser extends baseModule {
*/
function load_attributes($attr) {
$this->attributes['objectClass'] = array();
$this->attributes['macAddress'] = array();
$this->orig['objectClass'] = array();
$this->orig['kolabInvitationPolicy'] = array();
// load Kolab attributes

View File

@ -48,6 +48,8 @@ class ldapPublicKey extends baseModule {
$return["alias"] = _("SSH public key");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('ldapPublicKey');
// help Entries
$return['help'] = array(
'key' => array(

View File

@ -53,6 +53,8 @@ class nisMailAlias extends baseModule {
$return["RDN"] = array("cn" => "normal");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('nisMailAlias');
// help Entries
$return['help'] = array(
'alias' => array(

View File

@ -123,6 +123,8 @@ class posixAccount extends baseModule {
$return["alias"] = _("Unix");
// RDN attributes
$return["RDN"] = array("uid" => "normal", "cn" => "low");
// managed object classes
$return['objectClasses'] = array('posixAccount');
// profile checks
$return['profile_checks']['posixAccount_homeDirectory'] = array('type' => 'ext_preg', 'regex' => 'homeDirectory',
'error_message' => $this->messages['homeDirectory'][0]);

View File

@ -307,6 +307,8 @@ class posixGroup extends baseModule {
$return["RDN"] = array("cn" => "normal");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('posixGroup');
// configuration options
$return['config_options']['group'] = array(
array(

View File

@ -105,6 +105,8 @@ class sambaAccount extends baseModule {
$return["alias"] = _('Samba 2');
// module dependencies
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('sambaAccount');
// profile options
if ($this->get_scope() == 'user') {
// set Unix password for Samba

View File

@ -53,6 +53,8 @@ class sambaDomain extends baseModule {
$return["ldap_filter"] = array('or' => "(objectClass=sambaDomain)");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('sambaDomain');
// help Entries
$return['help'] = array(
'domainName' => array(

View File

@ -232,6 +232,8 @@ class sambaGroupMapping extends baseModule {
$return["alias"] = _('Samba 3');
// module dependencies
$return['dependencies'] = array('depends' => array('posixGroup'), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('sambaGroupMapping');
// available PDF fields
$return['PDF_fields'] = array(
'gidNumber',

View File

@ -124,6 +124,8 @@ class sambaSamAccount extends baseModule {
$return["RDN"] = array("sambaSID" => "low");
// module dependencies
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('sambaSamAccount');
// profile checks
$return['profile_checks']['sambaSamAccount_smbhome'] = array(
'type' => 'ext_preg',

View File

@ -68,6 +68,8 @@ class shadowAccount extends baseModule {
$return["alias"] = _('Shadow');
// module dependencies
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
// managed object classes
$return['objectClasses'] = array('shadowAccount');
// lists for expiration date
$day = array(); $mon = array(); $year = array();
for ( $i=1; $i<=31; $i++ ) $day[] = $i;