added getRDNAttributes()

This commit is contained in:
Roland Gruber 2004-10-06 18:17:22 +00:00
parent 5aaab188d9
commit 921a0e1639
6 changed files with 115 additions and 14 deletions

View File

@ -120,7 +120,34 @@ The resulting LDAP filter will look like this:
is only used for base modules. Standard modules do not need to
implement it.</span><br>
<br>
<h3>2.1.5. get_dependencies*</h3>
<h3>2.1.5. get_RDNAttributes*</h3>
<br>
<table style="text-align: left; width: 300px; height: 30px;" border="0"
cellspacing="2" cellpadding="2">
<tbody>
<tr>
<td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
style="font-weight: bold;">function get_RDNAttributes()</span><br>
</td>
</tr>
</tbody>
</table>
<br>
Returns a hash array containing a list of possible LDAP attributes that
can be used to form the RDN (Relative Distinguished Name).<br>
<span style="font-weight: bold;"></span><br>
The keys of the array are the LDAP attributes, the values are the
priority <span style="font-style: italic;">("low"/"normal"/"high")</span>.<br>
Attributes with higher priority are placed higher in the drop down box
for the RDN selection.<br>
<br>
<span style="font-weight: bold;">Example: <span
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>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px; font-weight: bold;">
@ -151,7 +178,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.6. get_metaData()</h3>
<h3>2.1.7. get_metaData()</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px;">
@ -170,7 +197,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.7. get_configOptions()*</h3>
<h3>2.1.8. get_configOptions()*</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px;">
@ -198,7 +225,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.8. get_configDescriptions()*</h3>
<h3>2.1.9. get_configDescriptions()*</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px;">
@ -225,7 +252,7 @@ array with this format:<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 'descriptions' =&gt; array('option1'
=&gt; 'description1', ...))</span><br>
<br>
<h3>2.1.9. check_configOptions*</h3>
<h3>2.1.10. check_configOptions*</h3>
<br>
<table style="text-align: left; width: 400px; height: 30px;" border="0"
cellspacing="2" cellpadding="2">
@ -255,7 +282,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.10. get_scope()</h3>
<h3>2.1.11. get_scope()</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
style="text-align: left; width: 300px;">
@ -276,7 +303,8 @@ baseModule and should not be overwritten.</span><br>
<br>
<br>
<br>
<h3>2.2. Class functions</h3>
<h3>2.2. Functions which are called inside of an account container<br>
</h3>
<h3>2.2.1. init</h3>
<br>
<table cellpadding="2" cellspacing="2" border="0"
@ -685,7 +713,16 @@ array("user", "host")</span><br style="font-weight: bold;">
'objectClass=posixAccount', 'and' =&gt; '(!(uid=*$))')<br>
<br>
</span>
<h3>6.4 get_dependencies()<br>
<h3>6.4 get_RDNAttributes()</h3>
&nbsp;&nbsp;&nbsp; "RDN" =&gt; array<br>
<br>
<span style="font-weight: bold;">&nbsp;&nbsp; Example:</span><span
style="font-style: italic; font-weight: bold;"> array('uid' =&gt;
'normal', 'cn' =&gt; 'low')<br>
<br>
</span>
<span style="font-style: italic; font-weight: bold;"></span>
<h3>6.5 get_dependencies()<br>
</h3>
&nbsp;&nbsp;&nbsp; "dependencies" =&gt; array<br>
<br>
@ -697,7 +734,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.5 get_profileOptions()<br>
<h3>6.6 get_profileOptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "profile_options" =&gt; array<br>
<br>
@ -706,7 +743,7 @@ array("user", "host")</span><br style="font-weight: bold;">
return value of get_profileOptions().<br>
<br>
</span></span>
<h3>6.6 check_profileOptions()<br>
<h3>6.7 check_profileOptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "profile_checks" =&gt; array<br>
<br>
@ -781,7 +818,7 @@ head, 2 =&gt; message text, 3 =&gt; additional variables)</li>
</ul>
</ul>
<br>
<h3>6.7 get_configOptions()<br>
<h3>6.8 get_configOptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "config_options" =&gt; array('user' =&gt; array,
'host' =&gt; array, 'all' =&gt; array)<br>
@ -797,7 +834,7 @@ the
return value of get_configOptions().<br>
<br>
</span></span>
<h3>6.8 get_configDescriptions()<br>
<h3>6.9 get_configDescriptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "config_descriptions" =&gt; array<br>
<br>
@ -806,7 +843,7 @@ return value of get_configOptions().<br>
return value of get_configDescriptions().<br>
<br>
</span></span>
<h3>6.9 check_configOptions()<br>
<h3>6.10 check_configOptions()<br>
</h3>
&nbsp;&nbsp;&nbsp; "config_checks" =&gt; array('user' =&gt; array,
'host' =&gt; 'array', 'all' =&gt; array)<br>

View File

@ -189,6 +189,20 @@ class baseModule {
else return get_class($this);
}
/**
* Returns a list of possible LDAP attributes which can be used to form the RDN.
*
* The returned elements have this form: <attribute> => <priority>
* <br> <attribute> is the name of the LDAP attribute
* <br> <priority> defines the priority of the attribute (can be "low", "normal", "high")
*
* @return array list of attributes
*/
function get_RDNAttributes() {
if (isset($this->meta['RDN'])) return $this->meta['RDN'];
else return array();
}
/**
* This function returns a list with all depending and conflicting modules.
*
@ -489,7 +503,6 @@ class baseModule {
}
}
// TODO implement missing interface
}

View File

@ -115,6 +115,51 @@ function get_ldap_filter($scope) {
else return "(&" . implode("", $filters['and']) . ")";
}
/**
* Returns a list of LDAP attributes which can be used to form the RDN.
*
* The list is already sorted by the priority given by the nodules.
*
* @param string $scope account type (user, group, host)
* @return array list of LDAP attributes
*/
function getRDNAttributes($scope) {
$mods = getAvailableModules($scope);
$return = array();
$attrs_low = array();
$attrs_normal = array();
$attrs_high = array();
for ($i = 0; $i < sizeof($mods); $i++) {
// get list of attributes
$module = new $mods[$i]($scope);
$attrs = $module->get_RDNAttributes();
$keys = array_keys($attrs);
// sort attributes
for ($k = 0; $k < sizeof($keys); $k++) {
switch ($attrs[$keys[$k]]) {
case "low":
$attrs_low[] = $keys[$k];
break;
case "normal":
$attrs_normal[] = $keys[$k];
break;
case "high":
$attrs_high[] = $keys[$k];
break;
default:
$attrs_low[] = $keys[$k];
break;
}
}
}
// merge arrays
$return = $attrs_high;
for ($i = 0; $i < sizeof($attrs_normal); $i++) $return[] = $attrs_normal[$i];
for ($i = 0; $i < sizeof($attrs_low); $i++) $return[] = $attrs_low[$i];
$return = array_values(array_unique($return));
return $return;
}
/**
* Returns a hash array (module name => dependencies) of all user module dependencies
*

View File

@ -73,6 +73,8 @@ class inetOrgPerson extends baseModule {
$return["account_types"] = array("user");
// alias name
$return["alias"] = _('Personal');
// RDN attribute
$return["RDN"] = array("cn" => "low");
// module dependencies
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array('account'));
// profile elements

View File

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

View File

@ -230,6 +230,8 @@ class posixGroup extends baseModule {
}
// alias name
$return["alias"] = _('Unix');
// RDN attribute
$return["RDN"] = array("cn" => "normal");
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array('inetOrgPerson', 'account', 'sambaDomain'));
// configuration options