new attribute loading mechanism
This commit is contained in:
parent
6f9bdca2ee
commit
52e2ef7c5a
|
@ -88,40 +88,39 @@ class baseModule {
|
|||
*/
|
||||
function init($base) {
|
||||
$this->base = $base;
|
||||
// Create Arrays with ldap attributes
|
||||
$this->attributes = $_SESSION[$this->base]->get_module_attributes(get_class($this));
|
||||
$this->orig = $_SESSION[$this->base]->get_module_attributes(get_class($this), true);
|
||||
$line=-1;
|
||||
for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) {
|
||||
if (strpos(strtolower($_SESSION['ldap']->objectClasses[$i]), strtolower("NAME '".get_class($this)."'"))) $line = $i;
|
||||
}
|
||||
$objectClassName = substr($_SESSION['ldap']->objectClasses[$line], 6+strpos($_SESSION['ldap']->objectClasses[$line], "NAME '"), strlen(get_class($this)) );
|
||||
$this->attributes['objectClass'][0] = $objectClassName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function loads all standard LDAP attributes. It is used
|
||||
* by the modules to reduce code
|
||||
* This function loads the LDAP attributes for this module.
|
||||
*
|
||||
* @param array $attr attribute list
|
||||
* @param array $attributes attribute list
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
// Load attributes which are displayed
|
||||
$objectClassName = $this->attributes['objectClass'];
|
||||
$attributes = array_keys($attr);
|
||||
foreach ($attributes as $attribute) {
|
||||
if (isset($this->attributes[$attribute])) {
|
||||
// decode as unicode
|
||||
$this->attributes[$attribute] = $attr[$attribute];
|
||||
$this->orig[$attribute] = $attr[$attribute];
|
||||
function load_attributes($attributes) {
|
||||
$this->attributes = array();
|
||||
$this->attributes = array();
|
||||
// load object classes
|
||||
if (isset($attributes['objectClass'])) {
|
||||
$this->attributes['objectClass'] = $attributes['objectClass'];
|
||||
$this->orig['objectClass'] = $attributes['objectClass'];
|
||||
}
|
||||
else {
|
||||
$this->attributes['objectClass'] = array();
|
||||
$this->orig['objectClass'] = array();
|
||||
}
|
||||
// add object classes if needed
|
||||
$objectClasses = $this->getManagedObjectClasses();
|
||||
for ($i = 0; $i < sizeof($objectClasses); $i++) {
|
||||
if (!in_array($objectClasses[$i], $this->attributes['objectClass'])) $this->attributes['objectClass'][] = $objectClasses[$i];
|
||||
}
|
||||
// load attributes
|
||||
$attributeNames = $this->getManagedAttributes();
|
||||
for ($i = 0; $i < sizeof($attributeNames); $i++) {
|
||||
if (isset($attributes[$attributeNames[$i]])) {
|
||||
$this->attributes[$attributeNames[$i]] = $attributes[$attributeNames[$i]];
|
||||
$this->orig[$attributeNames[$i]] = $attributes[$attributeNames[$i]];
|
||||
}
|
||||
}
|
||||
$this->attributes['objectClass'] = $objectClassName;
|
||||
if (in_array($objectClassName[0], $attr['objectClass']))
|
||||
$this->orig['objectClass'] = $objectClassName;
|
||||
else $this->orig['objectClass'] = array();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,7 +159,7 @@ class baseModule {
|
|||
* @return boolean true if base module
|
||||
*/
|
||||
function is_base_module() {
|
||||
if ($this->meta['is_base'] == true) return true;
|
||||
if (isset($this->meta['is_base']) && ($this->meta['is_base'] == true)) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
@ -360,7 +359,7 @@ class baseModule {
|
|||
$messages = array();
|
||||
$scopes[] = 'all'; // add checks that are independent of scope
|
||||
for ($s = 0; $s < sizeof($scopes); $s++) {
|
||||
if (is_array($this->meta['config_checks'][$scopes[$s]])) {
|
||||
if (isset($this->meta['config_checks'][$scopes[$s]]) && is_array($this->meta['config_checks'][$scopes[$s]])) {
|
||||
$identifiers = array_keys($this->meta['config_checks'][$scopes[$s]]);
|
||||
for ($i = 0; $i < sizeof($identifiers); $i++) {
|
||||
// check if option is required
|
||||
|
@ -690,6 +689,17 @@ class baseModule {
|
|||
else return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of LDAP attributes which are managed by this module.
|
||||
* All attribute names will be renamed to match the given spelling.
|
||||
*
|
||||
* @return array list of attributes
|
||||
*/
|
||||
function getManagedAttributes() {
|
||||
if (isset($this->meta['attributes']) && is_array($this->meta['attributes'])) return $this->meta['attributes'];
|
||||
else return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of required PHP extensions.
|
||||
*
|
||||
|
|
|
@ -855,19 +855,19 @@ class accountContainer {
|
|||
}
|
||||
}
|
||||
if ($this->subpage=='finish') {
|
||||
if ($post['createagain']) {
|
||||
if (isset($post['createagain'])) {
|
||||
// open fresh account page
|
||||
unset($_SESSION[$this->base]);
|
||||
metaRefresh("edit.php?type=" . $this->type);
|
||||
exit();
|
||||
}
|
||||
if ($post['backmain']) {
|
||||
if (isset($post['backmain'])) {
|
||||
// Return to account list
|
||||
unset($_SESSION[$this->base]);
|
||||
metaRefresh("../lists/list.php?type=" . $this->type);
|
||||
exit;
|
||||
}
|
||||
if ($post['outputpdf']) {
|
||||
if (isset($post['outputpdf'])) {
|
||||
// Create / display PDf-file
|
||||
createModulePDF(array($_SESSION[$this->base]), $post['pdfStructure']);
|
||||
exit;
|
||||
|
@ -1099,222 +1099,7 @@ class accountContainer {
|
|||
echo "</body>\n";
|
||||
echo "</html>\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add attributes to variable. Syntax is array( attribute = array ( objectClass1 => MUST|MAX, objectClass2 => MUST|MAY ), ... )
|
||||
* @todo remove this function when get_module_attributes() is changed
|
||||
*/
|
||||
function add_attributes($objectClass) {
|
||||
// loop through every existing objectlass and select current objectClass
|
||||
$line=-1;
|
||||
for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) {
|
||||
if (strpos(strtolower($_SESSION['ldap']->objectClasses[$i]), strtolower("NAME '$objectClass'"))) $line = $i;
|
||||
}
|
||||
// Return error if objectClass isn't found
|
||||
if ($line==-1) trigger_error (sprintf(_("ObjectClass %s required but not defined in LDAP."), $objectClass), E_USER_WARNING);
|
||||
// create array with must-attributes
|
||||
// Get startposition in string
|
||||
if (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST (')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MUST (')+6);
|
||||
// Now we have a string with all must-attributes
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ')'));
|
||||
$string = trim($string);
|
||||
$must = explode(" $ ", $string);
|
||||
// Ad must
|
||||
foreach ($must as $attribute) {
|
||||
if (!isset($this->attributes[$attribute])) $this->attributes[$attribute][$objectClass] = 'MUST';
|
||||
else $this->attributes[$attribute][$objectClass] = 'MUST';
|
||||
}
|
||||
}
|
||||
// create array with may-attributes
|
||||
// Get startposition in string
|
||||
if (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY (')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MAY (')+5);
|
||||
// Now we have a string with all must-attributes
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ')'));
|
||||
$string = trim($string);
|
||||
$may = explode(" $ ", $string);
|
||||
// Ad may
|
||||
foreach ($may as $attribute) {
|
||||
if (!isset($this->attributes[$attribute])) $this->attributes[$attribute][$objectClass] = 'MAY';
|
||||
else $this->attributes[$attribute][$objectClass] = 'MAY';
|
||||
}
|
||||
}
|
||||
// Get attributes of subclasses
|
||||
while (strpos($_SESSION['ldap']->objectClasses[$line], "SUP ")) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'SUP ')+4);
|
||||
$subclass = substr($string_withtail, 0, strpos($string_withtail, ' '));
|
||||
// Add account type to object
|
||||
for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) {
|
||||
if (strpos($_SESSION['ldap']->objectClasses[$i], "NAME '$subclass'")) $line = $i;
|
||||
}
|
||||
// Return error if objectClass isn't found
|
||||
if ($line==-1) trigger_error (sprintf(_("ObjectClass %s required but not defined in LDAP."), $objectClass), E_USER_WARNING);
|
||||
// create array with must-attributes
|
||||
// Get startposition in string
|
||||
if (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST (')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MUST (')+6);
|
||||
// Now we have a string with all must-attributes
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ')'));
|
||||
$string = trim($string);
|
||||
$must = explode(" $ ", $string);
|
||||
// Ad must
|
||||
foreach ($must as $attribute) {
|
||||
if (!isset($this->attributes[$attribute])) $this->attributes[$attribute][$objectClass] = 'MUST';
|
||||
else $this->attributes[$attribute][$objectClass] = 'MUST';
|
||||
}
|
||||
}
|
||||
// create array with may-attributes
|
||||
// Get startposition in string
|
||||
if (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY (')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MAY (')+5);
|
||||
// Now we have a string with all must-attributes
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ')'));
|
||||
$string = trim($string);
|
||||
$may = explode(" $ ", $string);
|
||||
// Ad may
|
||||
foreach ($may as $attribute) {
|
||||
if (!isset($this->attributes[$attribute])) $this->attributes[$attribute][$objectClass] = 'MAY';
|
||||
else $this->attributes[$attribute][$objectClass] = 'MAY';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function returns all LDAP attributes which are used by the given object class.
|
||||
* LDAP attributs which are already in use by another object class are passed as reference.
|
||||
* <br>Therefore this function must be called as reference: $result =& ..get_module_attributes
|
||||
*
|
||||
* @param string $objectClass object class name
|
||||
* @param boolean $original If original is true references will be set to original attributes. This are the original attributes
|
||||
* when an LDAP entry is loaded.
|
||||
* @return array list of attributes
|
||||
* @todo Remove this function
|
||||
*/
|
||||
function get_module_attributes($objectClass, $original=false) {
|
||||
// Add account type to object
|
||||
$line=-1;
|
||||
for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) {
|
||||
if (strpos(strtolower($_SESSION['ldap']->objectClasses[$i]), strtolower("NAME '$objectClass'"))) $line = $i;
|
||||
}
|
||||
// Return empty array if no objectClass wasn't found
|
||||
if ($line==-1) return array();
|
||||
if (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST (')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MUST (')+6);
|
||||
// Now we have a string with all must-attributes
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ')'));
|
||||
$string = trim($string);
|
||||
// Add must
|
||||
foreach (explode(" $ ", $string) as $attribute) {
|
||||
$return[$attribute] = array();
|
||||
}
|
||||
}
|
||||
elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST ')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MUST ')+5);
|
||||
// Now we have a string with the must-attribute
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ' '));
|
||||
$string = trim($string);
|
||||
// Add must
|
||||
$return[$string] = array();
|
||||
}
|
||||
// create array with may-attributes
|
||||
// Get startposition in string
|
||||
if (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY (')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MAY (')+5);
|
||||
// Now we have a string with all must-attributes
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ')'));
|
||||
$string = trim($string);
|
||||
// Add may
|
||||
foreach (explode(" $ ", $string) as $attribute) {
|
||||
$return[$attribute] = array();
|
||||
}
|
||||
}
|
||||
elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY ')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MAY ')+4);
|
||||
// Now we have a string with the may-attribute
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ' '));
|
||||
$string = trim($string);
|
||||
// Add must
|
||||
$return[$string] = array();
|
||||
}
|
||||
// Get attributes of subclasses
|
||||
while (strpos($_SESSION['ldap']->objectClasses[$line], "SUP ")) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'SUP ')+4);
|
||||
$subclass = substr($string_withtail, 0, strpos($string_withtail, ' '));
|
||||
// Add account type to object
|
||||
for ($i=0; $i<count($_SESSION['ldap']->objectClasses) || $i==-1; $i++) {
|
||||
if (strpos($_SESSION['ldap']->objectClasses[$i], "NAME '$subclass'")) $line = $i;
|
||||
}
|
||||
// Return error if objectClass isn't found
|
||||
if ($line==-1) trigger_error (sprintf(_("ObjectClass %s required but not defined in LDAP."), $subclass), E_USER_WARNING);
|
||||
// create array with must-attributes
|
||||
// Get startposition in string
|
||||
if (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST (')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MUST (')+6);
|
||||
// Now we have a string with all must-attributes
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ')'));
|
||||
$string = trim($string);
|
||||
// Add must
|
||||
foreach (explode(" $ ", $string) as $attribute) {
|
||||
$return[$attribute] = array();
|
||||
}
|
||||
}
|
||||
elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MUST ')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MUST ')+5);
|
||||
// Now we have a string with the must-attribute
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ' '));
|
||||
$string = trim($string);
|
||||
// Add must
|
||||
$return[$string] = array();
|
||||
}
|
||||
// create array with may-attributes
|
||||
// Get startposition in string
|
||||
if (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY (')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MAY (')+5);
|
||||
// Now we have a string with all must-attributes
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ')'));
|
||||
$string = trim($string);
|
||||
// Add may
|
||||
foreach (explode(" $ ", $string) as $attribute) {
|
||||
$return[$attribute] = array();
|
||||
}
|
||||
}
|
||||
elseif (strpos($_SESSION['ldap']->objectClasses[$line], 'MAY ')) {
|
||||
$string_withtail = substr($_SESSION['ldap']->objectClasses[$line], strpos($_SESSION['ldap']->objectClasses[$line], 'MAY ')+4);
|
||||
// Now we have a string with the may-attribute
|
||||
$string = substr($string_withtail, 0, strpos($string_withtail, ' '));
|
||||
$string = trim($string);
|
||||
// Add must
|
||||
$return[$string] = array();
|
||||
}
|
||||
}
|
||||
|
||||
// make references with attibutes which are used by more than one module
|
||||
$newattributes = array_keys($return);
|
||||
$module = array_keys($this->module);
|
||||
if (!$original) {
|
||||
// Only add attributes when original is false. We don't want to add them twice
|
||||
$this->add_attributes($objectClass);
|
||||
for ($i=0; $i<count($module); $i++) {
|
||||
if ($module[$i]!=$objectClass)
|
||||
foreach ($newattributes as $attribute)
|
||||
if (isset($this->module[$module[$i]]->attributes[$attribute]) && ($attribute!='objectClass'))
|
||||
$return[$attribute] =& $this->module[$module[$i]]->attributes[$attribute];
|
||||
}
|
||||
}
|
||||
else {
|
||||
for ($i=0; $i<count($module); $i++) {
|
||||
if ($module[$i]!=$objectClass)
|
||||
foreach ($newattributes as $attribute)
|
||||
if (isset($this->module[$module[$i]]->orig[$attribute]) && ($attribute!='objectClass'))
|
||||
$return[$attribute] =& $this->module[$module[$i]]->orig[$attribute];
|
||||
}
|
||||
}
|
||||
$return['objectClass'] = array();
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function checks which LDAP attributes have changed while the account was edited.
|
||||
|
@ -1671,16 +1456,18 @@ class accountContainer {
|
|||
|
||||
if (!$stopprocessing) {
|
||||
foreach ($attributes as $DN) {
|
||||
if (is_array($DN['lamdaemon']['command'])) $result = lamdaemon($DN['lamdaemon']['command']);
|
||||
// Error somewhere in lamdaemon
|
||||
if (is_array($result)) {
|
||||
foreach ($result as $singleresult) {
|
||||
if (is_array($singleresult)) {
|
||||
if ($singleresult[0] == 'ERROR') $stopprocessing = true;
|
||||
$temparray[0] = $singleresult[0];
|
||||
$temparray[1] = _($singleresult[1]);
|
||||
$temparray[2] = _($singleresult[2]);
|
||||
$errors[] = $temparray;
|
||||
if (isset($DN['lamdaemon']['command']) && is_array($DN['lamdaemon']['command'])) {
|
||||
$result = lamdaemon($DN['lamdaemon']['command']);
|
||||
// Error somewhere in lamdaemon
|
||||
if (isset($result) && is_array($result)) {
|
||||
foreach ($result as $singleresult) {
|
||||
if (is_array($singleresult)) {
|
||||
if ($singleresult[0] == 'ERROR') $stopprocessing = true;
|
||||
$temparray[0] = $singleresult[0];
|
||||
$temparray[1] = _($singleresult[1]);
|
||||
$temparray[2] = _($singleresult[2]);
|
||||
$errors[] = $temparray;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ class account extends baseModule {
|
|||
$return['objectClasses'] = array('account');
|
||||
// LDAP aliases
|
||||
$return['LDAPaliases'] = array('userid' => 'uid');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('uid', 'description');
|
||||
// available PDF fields
|
||||
$return['PDF_fields'] = array(
|
||||
'description'
|
||||
|
@ -144,21 +146,6 @@ class account extends baseModule {
|
|||
return "enabled";
|
||||
}
|
||||
|
||||
/**
|
||||
* This function loads all attributes into the object.
|
||||
*
|
||||
* @param array $attr an array as it is retured from ldap_get_attributes()
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
parent::load_attributes($attr);
|
||||
// uid is not loaded automatically because it is called userid in schema
|
||||
if (isset($attr['uid'])) {
|
||||
$this->orig['uid'] = $attr['uid'];
|
||||
$this->attributes['uid'] = $attr['uid'];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This function returns an array with 4 entries:
|
||||
* array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr), 'lamdaemon' => array(cmds)), DN2 .... )
|
||||
* DN is the DN to change. It may be possible to change several DNs,
|
||||
|
|
|
@ -49,6 +49,8 @@ class ieee802Device extends baseModule {
|
|||
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
|
||||
// managed object classes
|
||||
$return['objectClasses'] = array('ieee802Device');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('macAddress');
|
||||
// help Entries
|
||||
$return['help'] = array(
|
||||
'mac' => array(
|
||||
|
@ -83,31 +85,6 @@ class ieee802Device extends baseModule {
|
|||
$this->messages['mac'][1] = array('ERROR', _('Account %s:') . ' ieee802Device_mac', 'MAC address is invalid!');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function loads all needed attributes into the object.
|
||||
*
|
||||
* @param array $attr an array as it is retured from ldap_get_attributes
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
$this->attributes['objectClass'] = array();
|
||||
$this->attributes['macAddress'] = array();
|
||||
$this->orig['objectClass'] = array();
|
||||
$this->orig['macAddress'] = array();
|
||||
if (isset($attr['objectClass'])) {
|
||||
$this->attributes['objectClass'] = $attr['objectClass'];
|
||||
$this->orig['objectClass'] = $attr['objectClass'];
|
||||
}
|
||||
if (isset($attr['macAddress'])) {
|
||||
$this->attributes['macAddress'] = $attr['macAddress'];
|
||||
$this->orig['macAddress'] = $attr['macAddress'];
|
||||
}
|
||||
// add object class if needed
|
||||
if (! in_array('ieee802Device', $this->orig['objectClass'])) {
|
||||
$this->attributes['objectClass'][] = 'ieee802Device';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will create the meta HTML code to show a page with all attributes.
|
||||
*
|
||||
|
@ -141,7 +118,7 @@ class ieee802Device extends baseModule {
|
|||
* @return array list of info/error messages
|
||||
*/
|
||||
function process_attributes(&$post) {
|
||||
$this->triggered_messages = array();
|
||||
$errors = array();
|
||||
$this->attributes['macAddress'] = array();
|
||||
// check old MACs
|
||||
if (isset($post['mac_number'])) {
|
||||
|
@ -152,7 +129,7 @@ class ieee802Device extends baseModule {
|
|||
if (!get_preg($post['macAddress' . $i], 'macAddress')) {
|
||||
$message = $this->messages['mac'][0];
|
||||
$message[] = $post['macAddress' . $i];
|
||||
$this->triggered_messages[] = array($message);
|
||||
$errors[] = array($message);
|
||||
}
|
||||
$this->attributes['macAddress'][] = $post['macAddress' . $i];
|
||||
}
|
||||
|
@ -167,16 +144,11 @@ class ieee802Device extends baseModule {
|
|||
else {
|
||||
$message = $this->messages['mac'][0];
|
||||
$message[] = $post['macAddress'];
|
||||
$this->triggered_messages[] = array($message);
|
||||
$errors[] = array($message);
|
||||
}
|
||||
}
|
||||
$this->attributes['macAddress'] = array_unique($this->attributes['macAddress']);
|
||||
if (sizeof($this->triggered_messages) > 0) {
|
||||
return $this->triggered_messages;
|
||||
}
|
||||
else {
|
||||
return array();
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,6 +49,8 @@ class inetLocalMailRecipient extends baseModule {
|
|||
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
|
||||
// managed object classes
|
||||
$return['objectClasses'] = array('inetLocalMailRecipient');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('mailLocalAddress', 'mailHost', 'mailRoutingAddress');
|
||||
// help Entries
|
||||
$return['help'] = array(
|
||||
'routingAdr' => array(
|
||||
|
@ -123,43 +125,6 @@ class inetLocalMailRecipient extends baseModule {
|
|||
$this->messages['host'][1] = array('ERROR', _('Account %s:') . ' inetLocalMailRecipient_server', 'Mail server is invalid!');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function loads all needed attributes into the object.
|
||||
*
|
||||
* @param array $attr an array as it is retured from ldap_get_attributes
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
$this->attributes['objectClass'] = array();
|
||||
$this->attributes['mailLocalAddress'] = array();
|
||||
$this->attributes['mailRoutingAddress'] = array();
|
||||
$this->attributes['mailHost'] = array();
|
||||
$this->orig['objectClass'] = array();
|
||||
$this->orig['mailLocalAddress'] = array();
|
||||
$this->orig['mailRoutingAddress'] = array();
|
||||
$this->orig['mailHost'] = array();
|
||||
if (isset($attr['objectClass'])) {
|
||||
$this->attributes['objectClass'] = $attr['objectClass'];
|
||||
$this->orig['objectClass'] = $attr['objectClass'];
|
||||
}
|
||||
if (isset($attr['mailLocalAddress'])) {
|
||||
$this->attributes['mailLocalAddress'] = $attr['mailLocalAddress'];
|
||||
$this->orig['mailLocalAddress'] = $attr['mailLocalAddress'];
|
||||
}
|
||||
if (isset($attr['mailRoutingAddress'])) {
|
||||
$this->attributes['mailRoutingAddress'] = $attr['mailRoutingAddress'];
|
||||
$this->orig['mailRoutingAddress'] = $attr['mailRoutingAddress'];
|
||||
}
|
||||
if (isset($attr['mailHost'])) {
|
||||
$this->attributes['mailHost'] = $attr['mailHost'];
|
||||
$this->orig['mailHost'] = $attr['mailHost'];
|
||||
}
|
||||
// add object class if needed
|
||||
if (! in_array('inetLocalMailRecipient', $this->orig['objectClass'])) {
|
||||
$this->attributes['objectClass'][] = 'inetLocalMailRecipient';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will create the meta HTML code to show a page with all attributes.
|
||||
*
|
||||
|
@ -168,20 +133,26 @@ class inetLocalMailRecipient extends baseModule {
|
|||
function display_html_attributes(&$post) {
|
||||
$return = array();
|
||||
// mail routing address
|
||||
$routingAddress = '';
|
||||
if (isset($this->attributes['mailRoutingAddress'][0])) $routingAddress = $this->attributes['mailRoutingAddress'][0];
|
||||
$return[] = array(
|
||||
0 => array('kind' => 'text', 'text' => _('Routing address')),
|
||||
1 => array('kind' => 'input', 'name' => 'routingAdr', 'type' => 'text', 'size' => '20', 'value' => $this->attributes['mailRoutingAddress'][0]),
|
||||
1 => array('kind' => 'input', 'name' => 'routingAdr', 'type' => 'text', 'size' => '20', 'value' => $routingAddress),
|
||||
2 => array('kind' => 'help', 'value' => 'routingAdr'));
|
||||
// mail server
|
||||
$mailServer = '';
|
||||
if (isset($this->attributes['mailHost'][0])) $mailServer = $this->attributes['mailHost'][0];
|
||||
$return[] = array(
|
||||
0 => array('kind' => 'text', 'text' => _('Mail server')),
|
||||
1 => array('kind' => 'input', 'name' => 'host', 'type' => 'text', 'size' => '20', 'value' => $this->attributes['mailHost'][0]),
|
||||
1 => array('kind' => 'input', 'name' => 'host', 'type' => 'text', 'size' => '20', 'value' => $mailServer),
|
||||
2 => array('kind' => 'help', 'value' => 'host'));
|
||||
// list current local addresses
|
||||
for ($i = 0; $i < sizeof($this->attributes['mailLocalAddress']); $i++) {
|
||||
$localAdresses = array();
|
||||
if (isset($this->attributes['mailLocalAddress'])) $localAdresses = $this->attributes['mailLocalAddress'];
|
||||
for ($i = 0; $i < sizeof($localAdresses); $i++) {
|
||||
$return[] = array(
|
||||
0 => array('kind' => 'text', 'text' => _('Local address')),
|
||||
1 => array('kind' => 'input', 'name' => 'localAdr' . $i, 'type' => 'text', 'size' => '20', 'value' => $this->attributes['mailLocalAddress'][$i]),
|
||||
1 => array('kind' => 'input', 'name' => 'localAdr' . $i, 'type' => 'text', 'size' => '20', 'value' => $localAdresses[$i]),
|
||||
2 => array('kind' => 'input', 'type' => 'submit', 'name' => 'delAdr' . $i, 'value' => _("Remove")),
|
||||
3 => array('kind' => 'help', 'value' => 'localAdr'));
|
||||
}
|
||||
|
@ -191,7 +162,7 @@ class inetLocalMailRecipient extends baseModule {
|
|||
1 => array('kind' => 'input', 'name' => 'localAdr', 'type' => 'text', 'size' => '20', 'value' => ''),
|
||||
2 => array('kind' => 'input', 'type' => 'submit', 'name' => 'addAdr', 'value' => _("Add")),
|
||||
3 => array('kind' => 'help', 'value' => 'localAdr'),
|
||||
4 => array('kind' => 'input', 'type' => 'hidden', 'value' => sizeof($this->attributes['mailLocalAddress']), 'name' => 'adr_number'));
|
||||
4 => array('kind' => 'input', 'type' => 'hidden', 'value' => sizeof($localAdresses), 'name' => 'adr_number'));
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,10 @@ class inetOrgPerson extends baseModule {
|
|||
$return['LDAPaliases'] = array('commonName' => 'cn', 'surname' => 'sn', 'streetAddress' => 'street',
|
||||
'fax' => 'facsimileTelephoneNumber', 'gn' => 'givenName', 'userid' => 'uid', 'rfc822Mailbox' => 'mail',
|
||||
'mobileTelephoneNumber' => 'mobile');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('uid', 'cn', 'employeeType', 'givenName', 'jpegPhoto', 'mail', 'manager', 'mobile',
|
||||
'host', 'title', 'telephoneNumber', 'facsimileTelephoneNumber', 'street', 'postOfficeBox', 'postalCode', 'postalAddress',
|
||||
'sn', 'userPassword', 'description');
|
||||
// profile elements
|
||||
$return['profile_options'] = array(
|
||||
array(
|
||||
|
@ -485,18 +489,19 @@ class inetOrgPerson extends baseModule {
|
|||
}
|
||||
|
||||
// handle host-attribute in on epice because it's not set by default
|
||||
if (isset($this->attributes['host'])) {
|
||||
if ($_SESSION['ldap']->supports_unix_hosts) {
|
||||
$host = $post['host'];
|
||||
if (!get_preg($host,'unixhost')) {
|
||||
$triggered_messages['host'][] = $this->messages['host'][0];
|
||||
}
|
||||
$hosts = explode(",", $host);
|
||||
$this->attributes['host'] = array();
|
||||
for ($i = 0; $i < sizeof($hosts); $i++)
|
||||
for ($i = 0; $i < sizeof($hosts); $i++) {
|
||||
if ($hosts[$i] != "") {
|
||||
$this->attributes['host'][] = $hosts[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Do some regex-checks and return error if attributes are set to wrong values
|
||||
if (($this->attributes['givenName'][0] != '') && !get_preg($this->attributes['givenName'][0], 'realname')) $triggered_messages['givenName'][] = $this->messages['givenName'][0];
|
||||
if ( !get_preg($this->attributes['sn'][0], 'realname')) $triggered_messages['sn'][] = $this->messages['lastname'][0];
|
||||
|
@ -656,7 +661,7 @@ class inetOrgPerson extends baseModule {
|
|||
1 => array ( 'kind' => 'input', 'name' => 'employeeType', 'type' => 'text', 'size' => '30',
|
||||
'maxlength' => '255', 'value' => $employeeType),
|
||||
2 => array ('kind' => 'help', 'value' => 'employeeType'));
|
||||
if (isset($this->attributes['host'])) {
|
||||
if ($_SESSION['ldap']->supports_unix_hosts) {
|
||||
$hostvalue = "";
|
||||
if (is_array($this->attributes['host'])) {
|
||||
$hostvalue .= implode(",", $this->attributes['host']);
|
||||
|
|
|
@ -75,6 +75,9 @@ class kolabUser extends baseModule {
|
|||
$return["ldap_filter"] = array('or' => "(objectClass=kolabInetOrgPerson)");
|
||||
// managed object classes
|
||||
$return['objectClasses'] = array('kolabInetOrgPerson');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('c', 'alias', 'kolabHomeServer', 'kolabHomeMTA', 'kolabDelegate',
|
||||
'cyrus-userquota', 'kolabInvitationPolicy', 'kolabFreeBusyFuture', 'kolabDeleteflag');
|
||||
// profile options
|
||||
$return['profile_options'] = array(
|
||||
array(
|
||||
|
@ -237,31 +240,6 @@ class kolabUser extends baseModule {
|
|||
$this->messages['quota'][1] = array('ERROR', _('Account %s:') . ' kolabUser_quota', _('Mail quota must be a number!'));
|
||||
}
|
||||
|
||||
/**
|
||||
* This function loads all needed attributes into the object.
|
||||
*
|
||||
* @param array $attr an array as it is retured from ldap_get_attributes
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
$this->attributes['objectClass'] = array();
|
||||
$this->orig['objectClass'] = array();
|
||||
$this->orig['kolabInvitationPolicy'] = array();
|
||||
// load Kolab attributes
|
||||
$attributes = array('objectClass', 'c', 'kolabHomeServer', 'kolabInvitationPolicy',
|
||||
'alias', 'kolabDelegate', 'kolabFreeBusyFuture', 'cyrus-userquota', 'kolabDeleteflag');
|
||||
for ($i = 0; $i < sizeof($attributes); $i++) {
|
||||
if (isset($attr[$attributes[$i]])) {
|
||||
$this->attributes[$attributes[$i]] = $attr[$attributes[$i]];
|
||||
$this->orig[$attributes[$i]] = $attr[$attributes[$i]];
|
||||
}
|
||||
}
|
||||
// add object class if needed
|
||||
if (! in_array('kolabInetOrgPerson', $this->orig['objectClass'])) {
|
||||
$this->attributes['objectClass'][] = 'kolabInetOrgPerson';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of modifications which have to be made to the LDAP account.
|
||||
*
|
||||
|
|
|
@ -50,6 +50,8 @@ class ldapPublicKey extends baseModule {
|
|||
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
|
||||
// managed object classes
|
||||
$return['objectClasses'] = array('ldapPublicKey');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('sshPublicKey');
|
||||
// help Entries
|
||||
$return['help'] = array(
|
||||
'key' => array(
|
||||
|
@ -77,31 +79,6 @@ class ldapPublicKey extends baseModule {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function loads all needed attributes into the object.
|
||||
*
|
||||
* @param array $attr an array as it is retured from ldap_get_attributes
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
$this->attributes['objectClass'] = array();
|
||||
$this->attributes['sshPublicKey'] = array();
|
||||
$this->orig['objectClass'] = array();
|
||||
$this->orig['sshPublicKey'] = array();
|
||||
if (isset($attr['objectClass'])) {
|
||||
$this->attributes['objectClass'] = $attr['objectClass'];
|
||||
$this->orig['objectClass'] = $attr['objectClass'];
|
||||
}
|
||||
if (isset($attr['sshPublicKey'])) {
|
||||
$this->attributes['sshPublicKey'] = $attr['sshPublicKey'];
|
||||
$this->orig['sshPublicKey'] = $attr['sshPublicKey'];
|
||||
}
|
||||
// add object class if needed
|
||||
if (! in_array('ldapPublicKey', $this->orig['objectClass'])) {
|
||||
$this->attributes['objectClass'][] = 'ldapPublicKey';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will create the meta HTML code to show a page with all attributes.
|
||||
*
|
||||
|
|
|
@ -55,6 +55,8 @@ class nisMailAlias extends baseModule {
|
|||
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
|
||||
// managed object classes
|
||||
$return['objectClasses'] = array('nisMailAlias');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('cn', 'rfc822MailMember');
|
||||
// help Entries
|
||||
$return['help'] = array(
|
||||
'alias' => array(
|
||||
|
@ -102,37 +104,6 @@ class nisMailAlias extends baseModule {
|
|||
$this->messages['recipient'][1] = array('ERROR', _('Account %s:') . ' nisMailAlias_recipient', 'Recipient is invalid!');
|
||||
}
|
||||
|
||||
/**
|
||||
* This function loads all needed attributes into the object.
|
||||
*
|
||||
* @param array $attr an array as it is retured from ldap_get_attributes
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
$this->attributes['objectClass'] = array();
|
||||
$this->attributes['rfc822MailMember'] = array();
|
||||
$this->attributes['cn'] = array();
|
||||
$this->orig['objectClass'] = array();
|
||||
$this->orig['rfc822MailMember'] = array();
|
||||
$this->orig['cn'] = array();
|
||||
if (isset($attr['objectClass'])) {
|
||||
$this->attributes['objectClass'] = $attr['objectClass'];
|
||||
$this->orig['objectClass'] = $attr['objectClass'];
|
||||
}
|
||||
if (isset($attr['cn'])) {
|
||||
$this->attributes['cn'] = $attr['cn'];
|
||||
$this->orig['cn'] = $attr['cn'];
|
||||
}
|
||||
if (isset($attr['rfc822MailMember'])) {
|
||||
$this->attributes['rfc822MailMember'] = $attr['rfc822MailMember'];
|
||||
$this->orig['rfc822MailMember'] = $attr['rfc822MailMember'];
|
||||
}
|
||||
// add object class if needed
|
||||
if (! in_array('nisMailAlias', $this->orig['objectClass'])) {
|
||||
$this->attributes['objectClass'][] = 'nisMailAlias';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of modifications which have to be made to the LDAP account.
|
||||
*
|
||||
|
|
|
@ -127,6 +127,9 @@ class posixAccount extends baseModule {
|
|||
$return['objectClasses'] = array('posixAccount');
|
||||
// LDAP aliases
|
||||
$return['LDAPaliases'] = array('commonName' => 'cn', 'userid' => 'uid');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('cn', 'uid', 'uidNumber', 'gidNumber', 'homeDirectory',
|
||||
'userPassword', 'loginShell', 'gecos', 'description');
|
||||
// PHP extensions
|
||||
$return['extensions'] = array('mhash');
|
||||
// profile checks
|
||||
|
@ -451,9 +454,11 @@ class posixAccount extends baseModule {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* This function loads all attributes into the object
|
||||
* $attr is an array as it's retured from ldap_get_attributes
|
||||
*/
|
||||
/**
|
||||
* This function loads all needed LDAP attributes.
|
||||
*
|
||||
* @param array $attr list of attributes
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
parent::load_attributes($attr);
|
||||
// get additional group memberships
|
||||
|
@ -467,7 +472,6 @@ class posixAccount extends baseModule {
|
|||
}
|
||||
}
|
||||
$this->groups_orig = $this->groups;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This function returns an array with 3 entries:
|
||||
|
|
|
@ -231,7 +231,7 @@ class posixGroup extends baseModule {
|
|||
// users who can be added have a uid and gidNumber
|
||||
if (isset($dn_users[$DNs[$i]]['uid'][0]) && isset($dn_users[$DNs[$i]]['gidNumber'][0]) &&
|
||||
// are not already member
|
||||
!in_array($dn_users[$DNs[$i]]['uid'][0], $this->attributes['memberUid']) &&
|
||||
(!isset($this->attributes['memberUid']) || !in_array($dn_users[$DNs[$i]]['uid'][0], $this->attributes['memberUid'])) &&
|
||||
// and do not have this group as their primary group
|
||||
!($this->attributes['gidNumber'][0] == $dn_users[$DNs[$i]]['gidNumber'][0])) {
|
||||
$users[] = $dn_users[$DNs[$i]]['uid'][0];
|
||||
|
@ -311,6 +311,8 @@ class posixGroup extends baseModule {
|
|||
$return['objectClasses'] = array('posixGroup');
|
||||
// LDAP aliases
|
||||
$return['LDAPaliases'] = array('commonName' => 'cn');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('cn', 'gidNumber', 'userPassword', 'memberUid', 'description');
|
||||
// configuration options
|
||||
$return['config_options']['group'] = array(
|
||||
array(
|
||||
|
@ -703,6 +705,7 @@ class posixGroup extends baseModule {
|
|||
* @return array list of info/error messages
|
||||
*/
|
||||
function process_user(&$post) {
|
||||
if (!isset($this->attributes['memberUid'])) $this->attributes['memberUid'] = array();
|
||||
if (isset($post['addusers']) && isset($post['addusers_button'])) { // Add users to list
|
||||
// Add new user
|
||||
$this->attributes['memberUid'] = @array_merge($this->attributes['memberUid'], $post['addusers']);
|
||||
|
|
|
@ -107,6 +107,10 @@ class sambaAccount extends baseModule {
|
|||
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
|
||||
// managed object classes
|
||||
$return['objectClasses'] = array('sambaAccount');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('rid', 'lmPassword', 'ntPassword', 'pwdLastSet', 'logonTime', 'logoffTime',
|
||||
'kickoffTime', 'pwdCanChange', 'pwdMustChange', 'acctFlags', 'displayName', 'smbHome', 'homeDrive',
|
||||
'scriptPath', 'profilePath', 'userWorkstations', 'primaryGroupID', 'domain');
|
||||
// PHP extensions
|
||||
$return['extensions'] = array('mhash');
|
||||
// profile options
|
||||
|
@ -461,8 +465,7 @@ class sambaAccount extends baseModule {
|
|||
if (strpos($this->attributes['acctFlags'][0], "X")) $this->noexpire = true;
|
||||
else $this->noexpire = false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function returns an array with 3 entries:
|
||||
* array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
|
||||
|
|
|
@ -55,6 +55,9 @@ class sambaDomain extends baseModule {
|
|||
$return['dependencies'] = array('depends' => array(), 'conflicts' => array());
|
||||
// managed object classes
|
||||
$return['objectClasses'] = array('sambaDomain');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('sambaDomainName', 'sambaSID', 'sambaNextRid', 'sambaNextGroupRid',
|
||||
'sambaNextUserRid', 'sambaAlgorithmicRidBase');
|
||||
// help Entries
|
||||
$return['help'] = array(
|
||||
'domainName' => array(
|
||||
|
@ -149,35 +152,6 @@ class sambaDomain extends baseModule {
|
|||
$this->messages['RIDbase'][1] = array('ERROR', _('Account %s:') . ' sambaDomain_RIDbase', _('Algorithmic RID base is not a number!'));
|
||||
}
|
||||
|
||||
/**
|
||||
* This function loads all needed attributes into the object.
|
||||
*
|
||||
* @param array $attr an array as it is retured from ldap_get_attributes
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
$attributes = array('sambaAlgorithmicRidBase', 'sambaDomainName', 'sambaNextGroupRid',
|
||||
'sambaNextRid', 'sambaNextUserRid', 'sambaSID');
|
||||
$this->attributes['objectClass'] = array();
|
||||
$this->attributes['macAddress'] = array();
|
||||
$this->orig['objectClass'] = array();
|
||||
$this->orig['macAddress'] = array();
|
||||
if (isset($attr['objectClass'])) {
|
||||
$this->attributes['objectClass'] = $attr['objectClass'];
|
||||
$this->orig['objectClass'] = $attr['objectClass'];
|
||||
}
|
||||
for ($i = 0; $i < sizeof($attributes); $i++) {
|
||||
if (isset($attr[$attributes[$i]])) {
|
||||
$this->attributes[$attributes[$i]] = $attr[$attributes[$i]];
|
||||
$this->orig[$attributes[$i]] = $attr[$attributes[$i]];
|
||||
}
|
||||
}
|
||||
// add object class if needed
|
||||
if (! in_array('sambaDomain', $this->orig['objectClass'])) {
|
||||
$this->attributes['objectClass'][] = 'sambaDomain';
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will create the meta HTML code to show a page with all attributes.
|
||||
*
|
||||
|
|
|
@ -174,29 +174,32 @@ class sambaGroupMapping extends baseModule {
|
|||
return;
|
||||
}
|
||||
// Get Domain-SID from group SID
|
||||
if ($this->attributes['sambaSID'][0]!='')
|
||||
if (isset($this->attributes['sambaSID'][0])) {
|
||||
$domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-"));
|
||||
}
|
||||
for ($i=0; $i<count($sambaDomains); $i++ ) {
|
||||
// List with all valid domains
|
||||
$sambaDomainNames[] = $sambaDomains[$i]->name;
|
||||
if ($domainSID==$sambaDomains[$i]->SID) {
|
||||
if (isset($domainSID) && ($domainSID==$sambaDomains[$i]->SID)) {
|
||||
$SID = $sambaDomains[$i]->SID;
|
||||
$sel_domain = $sambaDomains[$i]->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
$displayName = '';
|
||||
if (isset($this->attributes['displayName'][0])) $displayName = $this->attributes['displayName'][0];
|
||||
$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]),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $displayName),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'displayName' ));
|
||||
|
||||
$names = array_keys($this->rids);
|
||||
$wrid=false;
|
||||
for ($i=0; $i<count($names); $i++) {
|
||||
if ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) {
|
||||
if (isset($this->attributes['sambaSID'][0]) && ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]])) {
|
||||
$selected[] = $names[$i];
|
||||
$wrid=true;
|
||||
}
|
||||
else $options[] = $names[$i];
|
||||
}
|
||||
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') ),
|
||||
|
@ -206,14 +209,16 @@ class sambaGroupMapping extends baseModule {
|
|||
$names = array_keys($this->sambaGroupTypes);
|
||||
$selected = array( _('Domain Group') );
|
||||
for ($i=0; $i<count($names); $i++) {
|
||||
if ($this->attributes['sambaGroupType'][0]==$this->sambaGroupTypes[$names[$i]])
|
||||
$selected = array( $names[$i] );
|
||||
}
|
||||
if (!isset($this->attributes['sambaGroupType'][0])) break;
|
||||
if ($this->attributes['sambaGroupType'][0]==$this->sambaGroupTypes[$names[$i]]) $selected = array( $names[$i] );
|
||||
}
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Group type') ),
|
||||
1 => array ( 'kind' => 'select', 'name' => 'sambaGroupType', 'options' => $names , 'options_selected' => $selected ),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
|
||||
$selectedDomain = array();
|
||||
if (isset($sel_domain)) $selectedDomain = array($sel_domain);
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
||||
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ( $sel_domain ) ),
|
||||
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => $selectedDomain),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
|
||||
|
||||
return $return;
|
||||
|
@ -234,6 +239,8 @@ class sambaGroupMapping extends baseModule {
|
|||
$return['dependencies'] = array('depends' => array('posixGroup'), 'conflicts' => array());
|
||||
// managed object classes
|
||||
$return['objectClasses'] = array('sambaGroupMapping');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('gidNumber', 'sambaSID', 'sambaGroupType', 'displayName', 'sambaSIDList', 'description');
|
||||
// available PDF fields
|
||||
$return['PDF_fields'] = array(
|
||||
'gidNumber',
|
||||
|
@ -396,6 +403,7 @@ class sambaGroupMapping extends baseModule {
|
|||
* @return array list of info/error messages
|
||||
*/
|
||||
function process_attributes(&$post) {
|
||||
$triggered_messages = array();
|
||||
$sambaDomains = search_domains();
|
||||
if (sizeof($sambaDomains) == 0) {
|
||||
return array(array(array("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'))));
|
||||
|
@ -405,11 +413,13 @@ class sambaGroupMapping extends baseModule {
|
|||
$this->attributes['sambaGroupType'][0] = $this->sambaGroupTypes[$post['sambaGroupType']];
|
||||
|
||||
// Get Domain SID from name
|
||||
for ($i=0; $i<count($sambaDomains); $i++ )
|
||||
for ($i=0; $i<count($sambaDomains); $i++ ) {
|
||||
if (!isset($post['sambaDomainName'])) break;
|
||||
if ($post['sambaDomainName'] == $sambaDomains[$i]->name) {
|
||||
$SID = $sambaDomains[$i]->SID;
|
||||
$RIDbase = $sambaDomain[$i]->RIDbase;
|
||||
}
|
||||
$RIDbase = $sambaDomains[$i]->RIDbase;
|
||||
}
|
||||
}
|
||||
// Load attributes
|
||||
$this->attributes['displayName'][0] = $post['displayName'];
|
||||
$rids = array_keys($this->rids);
|
||||
|
@ -430,13 +440,8 @@ class sambaGroupMapping extends baseModule {
|
|||
}
|
||||
}
|
||||
if (!$wrid) $this->attributes['sambaSID'][0] = $SID . "-" . ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+$RIDbase+1);
|
||||
|
||||
// Return error-messages
|
||||
if (count($triggered_messages)!=0) {
|
||||
$this->triggered_messages = $triggered_messages;
|
||||
return $triggered_messages;
|
||||
}
|
||||
else $this->triggered_messages = array();
|
||||
return $triggered_messages;
|
||||
}
|
||||
|
||||
|
||||
|
@ -453,15 +458,19 @@ class sambaGroupMapping extends baseModule {
|
|||
$sambaDomains = search_domains();
|
||||
// Get Domain-SID from group SID
|
||||
$domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-"));
|
||||
for ($i=0; $i<count($sambaDomains); $i++ )
|
||||
if ($domainSID==$sambaDomains[$i]->SID)
|
||||
for ($i=0; $i<count($sambaDomains); $i++ ) {
|
||||
if ($domainSID==$sambaDomains[$i]->SID) {
|
||||
$SID = $sambaDomains[$i]->SID;
|
||||
$RIDbase = $sambaDomains[$i]->RIDbase;
|
||||
}
|
||||
}
|
||||
$names = array_keys($this->rids);
|
||||
$wrid=false;
|
||||
for ($i=0; $i<count($names); $i++)
|
||||
for ($i=0; $i<count($names); $i++) {
|
||||
if ($this->attributes['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);
|
||||
|
||||
|
|
|
@ -126,6 +126,11 @@ class sambaSamAccount extends baseModule {
|
|||
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
|
||||
// managed object classes
|
||||
$return['objectClasses'] = array('sambaSamAccount');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('uid', 'sambaSID', 'sambaLMPassword', 'sambaNTPassword', 'sambaPwdLastSet',
|
||||
'sambaLogonTime', 'sambaLogoffTime', 'sambaKickoffTime', 'sambaPwdCanChange', 'sambaPwdMustChange', 'sambaAcctFlags',
|
||||
'displayName', 'sambaHomePath', 'sambaHomeDrive', 'sambaLogonScript', 'sambaProfilePath',
|
||||
'sambaUserWorkstations', 'sambaPrimaryGroupSID', 'sambaDomainName', 'sambaLogonHours');
|
||||
// PHP extensions
|
||||
$return['extensions'] = array('mhash');
|
||||
// profile checks
|
||||
|
@ -161,14 +166,12 @@ class sambaSamAccount extends baseModule {
|
|||
// available PDF fields
|
||||
$return['PDF_fields'] = array(
|
||||
'displayName',
|
||||
'uid',
|
||||
'sambaHomePath',
|
||||
'sambaHomeDrive',
|
||||
'sambaLogonScript',
|
||||
'sambaProfilePath',
|
||||
'sambaUserWorkstations',
|
||||
'sambaDomainName',
|
||||
'description',
|
||||
'sambaPrimaryGroupSID'
|
||||
);
|
||||
// help Entries
|
||||
|
@ -505,8 +508,7 @@ class sambaSamAccount extends baseModule {
|
|||
if (strpos($this->attributes['sambaAcctFlags'][0], "X")) $this->noexpire = true;
|
||||
else $this->noexpire = false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function returns an array with 3 entries:
|
||||
* array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
|
||||
|
@ -1286,14 +1288,12 @@ class sambaSamAccount extends baseModule {
|
|||
*/
|
||||
function get_pdfEntries() {
|
||||
return array( 'sambaSamAccount_displayName' => array('<block><key>' . _('Display name') . '</key><value' . $this->attributes['displayName'][0] . '</value></block>'),
|
||||
'sambaSamAccount_uid' => array('<block><key>' . _('User name') . '</key><value>' . $this->attributes['uid'][0] . '</value></block>'),
|
||||
'sambaSamAccount_sambaHomePath' => array('<block><key>' . _('Home path') . '</key><value>' . $this->attributes['sambaHomeDrive'][0] . '</value></block>'),
|
||||
'sambaSamAccount_sambaHomeDrive' => array('<block><key>' . _('Home drive') . '</key><value>' . $this->attributes['sambaHomePath'][0] . '</value></block>'),
|
||||
'sambaSamAccount_sambaLogonScript' => array('<block><key>' . _('Logon script') . '</key><value>' . $this->attributes['sambaLogonScript'][0] . '</value></block>'),
|
||||
'sambaSamAccount_sambaProfilePath' => array('<block><key>' . _('Profile path') . '</key><value>' . $this->attributes['sambaProfilePath'][0] . '</value></block>'),
|
||||
'sambaSamAccount_sambaUserWorkstations' => array('<block><key>' . _('Samba workstations') . '</key><value>' . $this->attributes['sambaUserWorkstations'][0] . '</value></block>'),
|
||||
'sambaSamAccount_sambaDomainName' => array('<block><key>' . _('Domain') . '</key><value>' . $this->attributes['sambaDomainName'][0] . '</value></block>'),
|
||||
'sambaSamAccount_description' => array('<block><key>' . _('Description') . '</key><value>' . $this->attributes['description'][0] . '</value></block>'),
|
||||
'sambaSamAccount_sambaPrimaryGroupSID' => array('<block><key>' . _('Windows group') . '</key><value>' . $this->attributes['sambaPrimaryGroupSID'][0] . '</value></block>'));
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,9 @@ class shadowAccount extends baseModule {
|
|||
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
|
||||
// managed object classes
|
||||
$return['objectClasses'] = array('shadowAccount');
|
||||
// managed attributes
|
||||
$return['attributes'] = array('userPassword', 'shadowLastChange', 'shadowMin', 'shadowMax', 'shadowWarning',
|
||||
'shadowInactive', 'shadowExpire');
|
||||
// lists for expiration date
|
||||
$day = array(); $mon = array(); $year = array();
|
||||
for ( $i=1; $i<=31; $i++ ) $day[] = $i;
|
||||
|
@ -142,8 +145,7 @@ class shadowAccount extends baseModule {
|
|||
'shadowLastChange',
|
||||
'shadowWarning',
|
||||
'shadowInactive',
|
||||
'shadowExpire',
|
||||
'description'
|
||||
'shadowExpire'
|
||||
);
|
||||
// help Entries
|
||||
$return['help'] = array (
|
||||
|
@ -246,6 +248,7 @@ class shadowAccount extends baseModule {
|
|||
* @return array list of info/error messages
|
||||
*/
|
||||
function process_attributes(&$post) {
|
||||
$triggered_messages = array();
|
||||
// Load attributes
|
||||
$this->attributes['shadowMin'][0] = $post['shadowMin'];
|
||||
$this->attributes['shadowMax'][0] = $post['shadowMax'];
|
||||
|
@ -258,11 +261,7 @@ class shadowAccount extends baseModule {
|
|||
if ( $this->attributes['shadowMin'][0] > $this->attributes['shadowMax'][0]) $triggered_messages['shadowMin'][] = $this->messages['shadow_cmp'][0];
|
||||
if ( !get_preg($this->attributes['shadowInactive'][0], 'digit2')) $triggered_messages['shadowInactive'][] = $this->messages['inactive'][0];
|
||||
if ( !get_preg($this->attributes['shadowWarning'][0], 'digit')) $triggered_messages['shadowWarning'][] = $this->messages['shadowWarning'][0];
|
||||
if (count($triggered_messages)!=0) {
|
||||
$this->triggered_messages = $triggered_messages;
|
||||
return $triggered_messages;
|
||||
}
|
||||
else $this->triggered_messages = array();
|
||||
return $triggered_messages;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -273,19 +272,29 @@ class shadowAccount extends baseModule {
|
|||
*/
|
||||
function display_html_attributes(&$post) {
|
||||
// Use dd-mm-yyyy format of date because it's easier to read for humans
|
||||
$date = getdate ($this->attributes['shadowExpire'][0]*3600*24);
|
||||
$shAccExpirationDate = 0;
|
||||
if (isset($this->attributes['shadowExpire'][0])) $shAccExpirationDate = $this->attributes['shadowExpire'][0];
|
||||
$date = getdate($shAccExpirationDate*3600*24);
|
||||
|
||||
$shWarning = '';
|
||||
if (isset($this->attributes['shadowWarning'][0])) $shWarning = $this->attributes['shadowWarning'][0];
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password warning') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'shadowWarning', 'type' => 'text', 'size' => '5', 'maxlength' => '4', 'value' => $this->attributes['shadowWarning'][0] ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'shadowWarning', 'type' => 'text', 'size' => '5', 'maxlength' => '4', 'value' => $shWarning),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'shadowWarning' ));
|
||||
$shPwdExpiration = '';
|
||||
if (isset($this->attributes['shadowInactive'][0])) $shPwdExpiration = $this->attributes['shadowInactive'][0];
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password expiration') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'shadowInactive', 'type' => 'text', 'size' => '5', 'maxlength' => '4', 'value' => $this->attributes['shadowInactive'][0] ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'shadowInactive', 'type' => 'text', 'size' => '5', 'maxlength' => '4', 'value' => $shPwdExpiration),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'shadowInactive' ));
|
||||
$shMinAge = '';
|
||||
if (isset($this->attributes['shadowMin'][0])) $shMinAge = $this->attributes['shadowMin'][0];
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Minimum password age') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'shadowMin', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $this->attributes['shadowMin'][0] ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'shadowMin', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $shMinAge),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'shadowMin' ));
|
||||
$shMaxAge = '';
|
||||
if (isset($this->attributes['shadowMax'][0])) $shMaxAge = $this->attributes['shadowMax'][0];
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Maximum password age') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'shadowMax', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $this->attributes['shadowMax'][0] ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'shadowMax', 'type' => 'text', 'size' => '5', 'maxlength' => '5', 'value' => $shMaxAge),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'shadowMax' ));
|
||||
|
||||
for ( $i=1; $i<=31; $i++ ) $mday[] = $i;
|
||||
|
@ -312,8 +321,7 @@ class shadowAccount extends baseModule {
|
|||
return array('shadowAccount_shadowLastChange' => array('<block><key>' . _('Last password change') . '</key><value>' . $this->attributes['shadowLastChange'][0] . '</value></block>'),
|
||||
'shadowAccount_shadowWarning' => array('<block><key>' . _('Password warning') . '</key><value>' . $this->attributes['shadowWarn'][0] . '</value><block>'),
|
||||
'shadowAccount_shadowInactive' => array('<block><key>' . _('Account inactive') . '</key><value>' . $this->attributes['shadowInactive'][0] . '</value></block>'),
|
||||
'shadowAccount_shadowExpire' => array('<block><key>' . _('Password expiration') . '</key><value>' . date('d. m. Y',$this->attributes['shadowExpire'][0]) . '</value></block>'),
|
||||
'shadowAccount_description' => array('<block><key>' . _('Description') . '</key><value>' . $this->attributes['description'][0] . '</value></block>'));
|
||||
'shadowAccount_shadowExpire' => array('<block><key>' . _('Password expiration') . '</key><value>' . date('d. m. Y',$this->attributes['shadowExpire'][0]) . '</value></block>'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue