reduced LDAP queries
This commit is contained in:
parent
55fc2b7117
commit
7657b37bad
|
@ -2,6 +2,7 @@ December 2010 3.3.0
|
||||||
- additional usability enhancements
|
- additional usability enhancements
|
||||||
- new IMAP module ("Mailbox (imapAccess)") allows to create/delete user mailboxes
|
- new IMAP module ("Mailbox (imapAccess)") allows to create/delete user mailboxes
|
||||||
- PDF export: higher resolution for logos
|
- PDF export: higher resolution for logos
|
||||||
|
- reduced number of LDAP queries
|
||||||
- fixed bugs:
|
- fixed bugs:
|
||||||
-> ignore comment lines in shells file (3107124)
|
-> ignore comment lines in shells file (3107124)
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,8 @@ class sambaGroupMapping extends baseModule {
|
||||||
private $rids;
|
private $rids;
|
||||||
/** Array of sambaGroupTypes */
|
/** Array of sambaGroupTypes */
|
||||||
private $sambaGroupTypes;
|
private $sambaGroupTypes;
|
||||||
|
/** cache for domain list */
|
||||||
|
private $cachedDomainList = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new module for Samba 3 groups.
|
* Creates a new module for Samba 3 groups.
|
||||||
|
@ -113,6 +115,46 @@ class sambaGroupMapping extends baseModule {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array containing all input columns for the file upload.
|
||||||
|
*
|
||||||
|
* Calling this method does not require the existence of an enclosing {@link accountContainer}.<br>
|
||||||
|
* <br>
|
||||||
|
* This funtion returns an array which contains subarrays which represent an upload column.
|
||||||
|
* <b>Syntax of column arrays:</b>
|
||||||
|
* <br>
|
||||||
|
* <br> array(
|
||||||
|
* <br> string: name, // fixed non-translated name which is used as column name (should be of format: <module name>_<column name>)
|
||||||
|
* <br> string: description, // short descriptive name
|
||||||
|
* <br> string: help, // help ID
|
||||||
|
* <br> string: example, // example value
|
||||||
|
* <br> string: values, // possible input values (optional)
|
||||||
|
* <br> string: default, // default value (optional)
|
||||||
|
* <br> boolean: required // true, if user must set a value for this column
|
||||||
|
* <br> boolean: unique // true if all values of this column must be different values (optional, default: "false")
|
||||||
|
* <br> )
|
||||||
|
*
|
||||||
|
* @param array $selectedModules list of selected account modules
|
||||||
|
* @return array column list
|
||||||
|
*
|
||||||
|
* @see baseModule::get_metaData()
|
||||||
|
*/
|
||||||
|
public function get_uploadColumns($selectedModules) {
|
||||||
|
$return = parent::get_uploadColumns($selectedModules);
|
||||||
|
$domains = $this->getDomains();
|
||||||
|
$domainNames = array();
|
||||||
|
for ($i = 0; $i < sizeof($domains); $i++) $domainNames[] = $domains[$i]->name;
|
||||||
|
$return[] = array(
|
||||||
|
'name' => 'sambaGroupMapping_domain',
|
||||||
|
'description' => _('Samba domain name'),
|
||||||
|
'help' => 'sambaDomainName',
|
||||||
|
'example' => $domainNames[0],
|
||||||
|
'values' => implode(", ", $domainNames),
|
||||||
|
'required' => true
|
||||||
|
);
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this function the LDAP account is built up.
|
* In this function the LDAP account is built up.
|
||||||
*
|
*
|
||||||
|
@ -124,7 +166,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
*/
|
*/
|
||||||
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
|
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
|
||||||
// search existing Samba 3 domains
|
// search existing Samba 3 domains
|
||||||
$domains = search_domains();
|
$domains = $this->getDomains();
|
||||||
$nameToSID = array();
|
$nameToSID = array();
|
||||||
// get domain SIDs
|
// get domain SIDs
|
||||||
for ($i = 0; $i < sizeof($domains); $i++) {
|
for ($i = 0; $i < sizeof($domains); $i++) {
|
||||||
|
@ -198,7 +240,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
}
|
}
|
||||||
$return = new htmlTable();
|
$return = new htmlTable();
|
||||||
if (in_array('sambaGroupMapping', $this->attributes['objectClass'])) {
|
if (in_array('sambaGroupMapping', $this->attributes['objectClass'])) {
|
||||||
$sambaDomains = search_domains();
|
$sambaDomains = $this->getDomains();
|
||||||
if (sizeof($sambaDomains) == 0) {
|
if (sizeof($sambaDomains) == 0) {
|
||||||
StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), '');
|
StatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.'), '');
|
||||||
return array();
|
return array();
|
||||||
|
@ -285,18 +327,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
// upload fields
|
// upload fields
|
||||||
// search existing Samba 3 domains
|
// search existing Samba 3 domains
|
||||||
if (isset($_SESSION['loggedIn']) && ($_SESSION['loggedIn'] === true)) {
|
if (isset($_SESSION['loggedIn']) && ($_SESSION['loggedIn'] === true)) {
|
||||||
$domains = search_domains();
|
|
||||||
$domainNames = array();
|
|
||||||
for ($i = 0; $i < sizeof($domains); $i++) $domainNames[] = $domains[$i]->name;
|
|
||||||
$return['upload_columns'] = array(
|
$return['upload_columns'] = array(
|
||||||
array(
|
|
||||||
'name' => 'sambaGroupMapping_domain',
|
|
||||||
'description' => _('Samba domain name'),
|
|
||||||
'help' => 'sambaDomainName',
|
|
||||||
'example' => $domainNames[0],
|
|
||||||
'values' => implode(", ", $domainNames),
|
|
||||||
'required' => true
|
|
||||||
),
|
|
||||||
array(
|
array(
|
||||||
'name' => 'sambaGroupMapping_name',
|
'name' => 'sambaGroupMapping_name',
|
||||||
'description' => _('Samba display name'),
|
'description' => _('Samba display name'),
|
||||||
|
@ -373,7 +404,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
function get_profileOptions() {
|
function get_profileOptions() {
|
||||||
$return = new htmlTable();
|
$return = new htmlTable();
|
||||||
// get list of domains
|
// get list of domains
|
||||||
$sambaDomains = search_domains();
|
$sambaDomains = $this->getDomains();
|
||||||
$sambaDomainNames = array();
|
$sambaDomainNames = array();
|
||||||
for ($i = 0; $i < count($sambaDomains); $i++ ) {
|
for ($i = 0; $i < count($sambaDomains); $i++ ) {
|
||||||
// extract names
|
// extract names
|
||||||
|
@ -393,7 +424,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
function load_profile($profile) {
|
function load_profile($profile) {
|
||||||
if (isset($profile['sambaGroupMapping_sambaDomainName'][0])) {
|
if (isset($profile['sambaGroupMapping_sambaDomainName'][0])) {
|
||||||
// get list of domains
|
// get list of domains
|
||||||
$sambaDomains = search_domains();
|
$sambaDomains = $this->getDomains();
|
||||||
for ($i = 0; $i < sizeof($sambaDomains); $i++) {
|
for ($i = 0; $i < sizeof($sambaDomains); $i++) {
|
||||||
if ($sambaDomains[$i]->name == $profile['sambaGroupMapping_sambaDomainName'][0]) {
|
if ($sambaDomains[$i]->name == $profile['sambaGroupMapping_sambaDomainName'][0]) {
|
||||||
$this->attributes['sambaSID'][0] = $sambaDomains[$i]->SID . "-0";
|
$this->attributes['sambaSID'][0] = $sambaDomains[$i]->SID . "-0";
|
||||||
|
@ -453,7 +484,7 @@ class sambaGroupMapping extends baseModule {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$sambaDomains = search_domains();
|
$sambaDomains = $this->getDomains();
|
||||||
if (sizeof($sambaDomains) == 0) {
|
if (sizeof($sambaDomains) == 0) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -514,6 +545,19 @@ class sambaGroupMapping extends baseModule {
|
||||||
}
|
}
|
||||||
return $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
|
return $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of existing Samba 3 domains.
|
||||||
|
*
|
||||||
|
* @return array list of samba3domain objects
|
||||||
|
*/
|
||||||
|
private function getDomains() {
|
||||||
|
if ($this->cachedDomainList != null) {
|
||||||
|
return $this->cachedDomainList;
|
||||||
|
}
|
||||||
|
$this->cachedDomainList = search_domains();
|
||||||
|
return $this->cachedDomainList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,8 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
/* cache to reduce LDAP queries */
|
/* cache to reduce LDAP queries */
|
||||||
private $cachedHostList = null;
|
private $cachedHostList = null;
|
||||||
private $cachedGroupSIDList = null;
|
private $cachedGroupSIDList = null;
|
||||||
|
/** cache for domain list */
|
||||||
|
private $cachedDomainList = null;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -711,7 +713,7 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$errors = array();
|
$errors = array();
|
||||||
$sambaDomains = search_domains();
|
$sambaDomains = $this->getDomains();
|
||||||
if (sizeof($sambaDomains) == 0) {
|
if (sizeof($sambaDomains) == 0) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -1025,7 +1027,7 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get Domain SID from user SID
|
// Get Domain SID from user SID
|
||||||
$sambaDomains = search_domains();
|
$sambaDomains = $this->getDomains();
|
||||||
if (sizeof($sambaDomains) == 0) {
|
if (sizeof($sambaDomains) == 0) {
|
||||||
$return->addElement(new htmlStatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.')), true);
|
$return->addElement(new htmlStatusMessage("ERROR", _('No Samba 3 domains found in LDAP! Please create one first.')), true);
|
||||||
return $return;
|
return $return;
|
||||||
|
@ -1497,7 +1499,7 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
$return->addElement(new htmlTableExtendedInputField(_('Samba workstations'), 'sambaSamAccount_userWorkstations', '', 'workstations'), true);
|
$return->addElement(new htmlTableExtendedInputField(_('Samba workstations'), 'sambaSamAccount_userWorkstations', '', 'workstations'), true);
|
||||||
}
|
}
|
||||||
// domains
|
// domains
|
||||||
$sambaDomains = search_domains();
|
$sambaDomains = $this->getDomains();
|
||||||
$sambaDomainNames = array();
|
$sambaDomainNames = array();
|
||||||
for ($i = 0; $i < count($sambaDomains); $i++) {
|
for ($i = 0; $i < count($sambaDomains); $i++) {
|
||||||
$sambaDomainNames[] = $sambaDomains[$i]->name;
|
$sambaDomainNames[] = $sambaDomains[$i]->name;
|
||||||
|
@ -1519,7 +1521,7 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
elseif ($this->get_scope() == 'host') {
|
elseif ($this->get_scope() == 'host') {
|
||||||
// domains
|
// domains
|
||||||
$sambaDomains = search_domains();
|
$sambaDomains = $this->getDomains();
|
||||||
$sambaDomainNames = array();
|
$sambaDomainNames = array();
|
||||||
for ($i = 0; $i < count($sambaDomains); $i++) {
|
for ($i = 0; $i < count($sambaDomains); $i++) {
|
||||||
$sambaDomainNames[] = $sambaDomains[$i]->name;
|
$sambaDomainNames[] = $sambaDomains[$i]->name;
|
||||||
|
@ -1582,7 +1584,7 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
// domain -> change SID
|
// domain -> change SID
|
||||||
if (isset($this->attributes['sambaSID'][0])) {
|
if (isset($this->attributes['sambaSID'][0])) {
|
||||||
if (isset($profile['sambaSamAccount_sambaDomainName'][0]) && ($profile['sambaSamAccount_sambaDomainName'][0] != "")) {
|
if (isset($profile['sambaSamAccount_sambaDomainName'][0]) && ($profile['sambaSamAccount_sambaDomainName'][0] != "")) {
|
||||||
$domains = search_domains();
|
$domains = $this->getDomains();
|
||||||
$domSID = '';
|
$domSID = '';
|
||||||
// find domain SID
|
// find domain SID
|
||||||
for ($i = 0; $i < sizeof($domains); $i++) {
|
for ($i = 0; $i < sizeof($domains); $i++) {
|
||||||
|
@ -1602,7 +1604,7 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
}
|
}
|
||||||
// primary group
|
// primary group
|
||||||
if (isset($profile['sambaSamAccount_sambaDomainName'][0])) {
|
if (isset($profile['sambaSamAccount_sambaDomainName'][0])) {
|
||||||
$domains = search_domains();
|
$domains = $this->getDomains();
|
||||||
$domSID = '';
|
$domSID = '';
|
||||||
// find domain SID
|
// find domain SID
|
||||||
for ($i = 0; $i < sizeof($domains); $i++) {
|
for ($i = 0; $i < sizeof($domains); $i++) {
|
||||||
|
@ -1731,7 +1733,7 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
|
function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
|
||||||
$errors = array();
|
$errors = array();
|
||||||
// get list of Samba 3 domains
|
// get list of Samba 3 domains
|
||||||
$domains = search_domains();
|
$domains = $this->getDomains();
|
||||||
// get list of Unix groups and their sambaSID + gidNumber
|
// get list of Unix groups and their sambaSID + gidNumber
|
||||||
$groupList = searchLDAPByFilter('objectClass=posixGroup', array('cn', 'sambaSID', 'gidNumber'), array('group'));
|
$groupList = searchLDAPByFilter('objectClass=posixGroup', array('cn', 'sambaSID', 'gidNumber'), array('group'));
|
||||||
$groups_cn = array();
|
$groups_cn = array();
|
||||||
|
@ -2222,6 +2224,19 @@ class sambaSamAccount extends baseModule implements passwordService {
|
||||||
return $this->cachedGroupSIDList;
|
return $this->cachedGroupSIDList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of existing Samba 3 domains.
|
||||||
|
*
|
||||||
|
* @return array list of samba3domain objects
|
||||||
|
*/
|
||||||
|
private function getDomains() {
|
||||||
|
if ($this->cachedDomainList != null) {
|
||||||
|
return $this->cachedDomainList;
|
||||||
|
}
|
||||||
|
$this->cachedDomainList = search_domains();
|
||||||
|
return $this->cachedDomainList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue