2003-12-21 14:52:23 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
$Id$
|
|
|
|
|
|
|
|
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
|
|
|
|
Copyright (C) 2003 Tilo Lutz
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Variables in basearray which are no objects:
|
2003-12-27 11:21:00 +00:00
|
|
|
* type: Type of account. Can be user, group, host, domain
|
2003-12-21 14:52:23 +00:00
|
|
|
* attributes: List of all attributes, how to get them and are theiy required or optional
|
|
|
|
* dn: current DN without uid= or cn=
|
|
|
|
* dn_orig: old DN if account was loaded with uid= or cn=
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* This class contains all account LDAP attributes
|
|
|
|
* and funtioncs required to deal with account
|
|
|
|
* account can only be created when it should be added
|
|
|
|
* to an array.
|
2003-12-27 11:21:00 +00:00
|
|
|
* $base is the name of account_container in session
|
2003-12-21 14:52:23 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
class account {
|
|
|
|
// Constructor
|
|
|
|
function account($base) {
|
2003-12-27 11:21:00 +00:00
|
|
|
// Get local copy of name of account_container in session
|
|
|
|
$this->base = $base;
|
|
|
|
// Do some error checks
|
2003-12-21 14:52:23 +00:00
|
|
|
if (!$base) trigger_error(_('Please create a base object with $var = new accountContainer();'), E_USER_ERROR);
|
|
|
|
if (!is_string($base)) trigger_error(_('Please create a new module object with $accountContainer->add_objectClass(\'account\');'), E_USER_ERROR);
|
|
|
|
if ($_SESSION[$this->base]->get_type() != 'host') trigger_error(_('account can only be used for hosts.'), E_USER_WARNING);
|
2003-12-27 11:21:00 +00:00
|
|
|
// load attribtues which are used in account objectClass
|
2003-12-30 17:09:15 +00:00
|
|
|
$this->orig = $_SESSION[$this->base]->get_module_attributes('account');
|
2003-12-21 14:52:23 +00:00
|
|
|
$this->attributes = $_SESSION[$this->base]->get_module_attributes('account');
|
2003-12-27 11:21:00 +00:00
|
|
|
// Add objectClass to attributes
|
2003-12-21 14:52:23 +00:00
|
|
|
$this->attributes['objectClass'][0] = 'account';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Variables
|
2003-12-27 11:21:00 +00:00
|
|
|
// name of account_container in session so we can read other classes in account_container
|
2003-12-21 14:52:23 +00:00
|
|
|
var $base;
|
|
|
|
// This variable contains all account attributes
|
|
|
|
var $attributes;
|
|
|
|
/* If an account was loaded all attributes are kept in this array
|
|
|
|
* to compare it with new changed attributes
|
|
|
|
*/
|
|
|
|
var $orig;
|
|
|
|
|
2003-12-30 15:36:30 +00:00
|
|
|
function get_alias() {
|
|
|
|
return _('account');
|
|
|
|
}
|
|
|
|
|
2003-12-21 14:52:23 +00:00
|
|
|
/* This function returns a list with all required modules
|
|
|
|
*/
|
2003-12-30 15:36:30 +00:00
|
|
|
function get_dependencies($scope) {
|
|
|
|
if ($scope=='host') return array('require' => array('main'), 'conflict' => array('inetOrgPerson', 'posixGroup', 'sambaDomain') );
|
|
|
|
return -1;
|
2003-12-21 14:52:23 +00:00
|
|
|
}
|
|
|
|
|
2003-12-27 11:21:00 +00:00
|
|
|
/* This function returns true if all required attributes from other
|
|
|
|
* modules are set. This is required to prevent undefined states
|
|
|
|
*/
|
2003-12-21 14:52:23 +00:00
|
|
|
function module_ready() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-12-27 11:21:00 +00:00
|
|
|
/* 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');
|
|
|
|
}
|
|
|
|
|
2004-01-14 20:33:25 +00:00
|
|
|
/*
|
|
|
|
*/
|
|
|
|
function get_help($id) {
|
|
|
|
switch ($id) {
|
|
|
|
case "description":
|
|
|
|
return array ("ext" => "FALSE", "Headline" => _("Description"),
|
|
|
|
"Text" => _("Host Description."));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-12-30 15:36:30 +00:00
|
|
|
/* This function returns all ldap attributes
|
|
|
|
* which are part of account and returns
|
|
|
|
* also their values.
|
2003-12-21 14:52:23 +00:00
|
|
|
*/
|
2003-12-30 15:36:30 +00:00
|
|
|
function get_attributes() {
|
|
|
|
return $this->attributes;
|
2003-12-21 14:52:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* This function loads all attributes into the object
|
|
|
|
* $attr is an array as it's retured from ldap_get_attributes
|
|
|
|
*/
|
|
|
|
function load_attributes($attr) {
|
2003-12-30 17:09:15 +00:00
|
|
|
// Load attributes which are displayed
|
2003-12-21 14:52:23 +00:00
|
|
|
// unset count entries
|
|
|
|
unset ($attr['count']);
|
|
|
|
$attributes = array_keys($attr);
|
|
|
|
foreach ($attributes as $attribute) unset ($attr[$attribute]['count']);
|
|
|
|
// unset double entries
|
|
|
|
for ($i=0; $i<count($attr); $i++)
|
|
|
|
if (isset($attr[$i])) unset($attr[$i]);
|
|
|
|
foreach ($attributes as $attribute) {
|
2003-12-30 17:09:15 +00:00
|
|
|
if (isset($this->attributes[$attribute])) {
|
2003-12-21 14:52:23 +00:00
|
|
|
// decode as unicode
|
2003-12-30 17:09:15 +00:00
|
|
|
$this->attributes[$attribute] = $attr[$attribute];
|
|
|
|
for ($i=0; $i<count($this->attributes[$attribute]); $i++) {
|
|
|
|
$this->attributes[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
|
|
|
|
$this->orig[$attribute][$i] = utf8_decode ($this->attributes[$attribute][$i]);
|
|
|
|
}
|
2003-12-21 14:52:23 +00:00
|
|
|
}
|
|
|
|
}
|
2003-12-27 11:21:00 +00:00
|
|
|
// Add objectClass to orig because we don't want to add objectClass if it's already set
|
2003-12-21 14:52:23 +00:00
|
|
|
$this->orig['objectClass'][0] = 'account';
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-12-27 11:21:00 +00:00
|
|
|
/* This function returns an array with 4 entries:
|
|
|
|
* array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr), 'lamdaemon' => array(cmds)), DN2 .... )
|
2003-12-21 14:52:23 +00:00
|
|
|
* 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
|
2003-12-27 11:21:00 +00:00
|
|
|
* lamdaemon are lamdaemon commands to modify homedir, quotas, ...
|
2003-12-21 14:52:23 +00:00
|
|
|
*/
|
|
|
|
function save_attributes() {
|
2003-12-27 11:21:00 +00:00
|
|
|
// Get easy attributes
|
2003-12-21 14:52:23 +00:00
|
|
|
$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
|
2003-12-27 11:21:00 +00:00
|
|
|
// Return attributes
|
2003-12-21 14:52:23 +00:00
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
2003-12-30 15:36:30 +00:00
|
|
|
function delete_attributes($post) {
|
2004-01-10 11:47:48 +00:00
|
|
|
return 0;
|
2003-12-30 15:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write variables into object and do some regexp checks
|
2003-12-21 14:52:23 +00:00
|
|
|
*/
|
2003-12-30 15:36:30 +00:00
|
|
|
function proccess_attributes($post) {
|
|
|
|
// Load attributes
|
|
|
|
$this->attributes['description'][0] = $post['description'];
|
|
|
|
return 0;
|
2003-12-21 14:52:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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) {
|
|
|
|
echo "<table border=0 width=\"100%\">\n<tr>\n";
|
|
|
|
echo "<tr>\n";
|
|
|
|
echo "<td>" . _('Description') . "</td>\n";
|
2003-12-30 15:36:30 +00:00
|
|
|
echo "<td><input name=\"description\" type=\"text\" size=\"30\" maxlength=\"255\" value=\"".$this->attributes['description'][0]."\"></td>\n";
|
2004-01-14 20:33:25 +00:00
|
|
|
echo "<td><a href=\"../help.php?HelpNumber=description&module=account\" target=\"lamhelp\">" . _('Help') . "</a></td>\n";
|
2003-12-21 14:52:23 +00:00
|
|
|
echo "</tr>\n";
|
|
|
|
echo "</table>\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-12-30 15:36:30 +00:00
|
|
|
function display_html_delete($post) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-12-21 14:52:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|