cleanup, doc and todo
This commit is contained in:
parent
3cafcc2d47
commit
87bd5a2bbb
|
@ -52,6 +52,10 @@ class Wizard extends LDAPUtility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief detects the available LDAP groups
|
||||||
|
* @returns the instance's WizardResult instance
|
||||||
|
*/
|
||||||
public function determineGroups() {
|
public function determineGroups() {
|
||||||
if(!$this->checkRequirements(array('ldapHost',
|
if(!$this->checkRequirements(array('ldapHost',
|
||||||
'ldapPort',
|
'ldapPort',
|
||||||
|
@ -71,14 +75,21 @@ class Wizard extends LDAPUtility {
|
||||||
'cn',
|
'cn',
|
||||||
'ldap_userfilter_groups',
|
'ldap_userfilter_groups',
|
||||||
'ldapUserFilterGroups');
|
'ldapUserFilterGroups');
|
||||||
|
|
||||||
|
//TODO: Check, whether member-of-overlay is installed on the LDAP Server
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief detects the available object classes
|
||||||
|
* @returns the instance's WizardResult instance
|
||||||
|
*/
|
||||||
public function determineObjectClasses() {
|
public function determineObjectClasses() {
|
||||||
if(!$this->checkRequirements(array('ldapHost',
|
if(!$this->checkRequirements(array('ldapHost',
|
||||||
'ldapPort',
|
'ldapPort',
|
||||||
'ldapAgentName',
|
'ldapAgentName',
|
||||||
'ldapAgentPassword',
|
'ldapAgentPassword',
|
||||||
'ldapBase',
|
'ldapBase',
|
||||||
|
true
|
||||||
))) {
|
))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -95,41 +106,6 @@ class Wizard extends LDAPUtility {
|
||||||
'ldapUserFilterObjectclass');
|
'ldapUserFilterObjectclass');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function determineFeature($objectclasses, $attr, $dbkey, $confkey) {
|
|
||||||
$cr = $this->getConnection();
|
|
||||||
if(!$cr) {
|
|
||||||
throw new \Excpetion('Could not connect to LDAP');
|
|
||||||
}
|
|
||||||
$p = 'objectclass=';
|
|
||||||
foreach($objectclasses as $key => $value) {
|
|
||||||
$objectclasses[$key] = $p.$value;
|
|
||||||
}
|
|
||||||
$maxEntryObjC = '';
|
|
||||||
$availableFeatures =
|
|
||||||
$this->cumulativeSearchOnAttribute($objectclasses, $attr,
|
|
||||||
true, $maxEntryObjC);
|
|
||||||
if(is_array($availableFeatures)
|
|
||||||
&& count($availableFeatures) > 0) {
|
|
||||||
$this->result->addOptions($dbkey, $availableFeatures);
|
|
||||||
} else {
|
|
||||||
throw new \Exception(self::$l->t('Could not find the desired feature'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$setFeatures = $this->configuration->$confkey;
|
|
||||||
if(is_array($setFeatures) && !empty($setFeatures)) {
|
|
||||||
//something is already configured? pre-select it.
|
|
||||||
$this->result->addChange($dbkey, $setFeatures);
|
|
||||||
} else if(!empty($maxEntryObjC)) {
|
|
||||||
//TODO / FIXME: this is great for objectclasses, but wrong for groups
|
|
||||||
//isolate it in another method and call it from this method's callee
|
|
||||||
//new? pre-select something hopefully sane
|
|
||||||
$maxEntryObjC = str_replace($p, '', $maxEntryObjC);
|
|
||||||
$this->result->addChange($dbkey, $maxEntryObjC);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to determine the port, requires given Host, User DN and Password
|
* Tries to determine the port, requires given Host, User DN and Password
|
||||||
* @returns mixed WizardResult on success, false otherwise
|
* @returns mixed WizardResult on success, false otherwise
|
||||||
|
@ -413,6 +389,50 @@ class Wizard extends LDAPUtility {
|
||||||
return $foundItems;
|
return $foundItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief determines if and which $attr are available on the LDAP server
|
||||||
|
* @param $objectclasses the objectclasses to use as search filter
|
||||||
|
* @param $attr the attribute to look for
|
||||||
|
* @param $dbkey the dbkey of the setting the feature is connected to
|
||||||
|
* @param $confkey the confkey counterpart for the $dbkey as used in the
|
||||||
|
* Configuration class
|
||||||
|
* @param $po boolean, whether the objectClass with most result entries
|
||||||
|
* shall be pre-selected via the result
|
||||||
|
* @returns the instance's WizardResult instance
|
||||||
|
*/
|
||||||
|
private function determineFeature($objectclasses, $attr, $dbkey, $confkey, $po = false) {
|
||||||
|
$cr = $this->getConnection();
|
||||||
|
if(!$cr) {
|
||||||
|
throw new \Excpetion('Could not connect to LDAP');
|
||||||
|
}
|
||||||
|
$p = 'objectclass=';
|
||||||
|
foreach($objectclasses as $key => $value) {
|
||||||
|
$objectclasses[$key] = $p.$value;
|
||||||
|
}
|
||||||
|
$maxEntryObjC = '';
|
||||||
|
$availableFeatures =
|
||||||
|
$this->cumulativeSearchOnAttribute($objectclasses, $attr,
|
||||||
|
true, $maxEntryObjC);
|
||||||
|
if(is_array($availableFeatures)
|
||||||
|
&& count($availableFeatures) > 0) {
|
||||||
|
$this->result->addOptions($dbkey, $availableFeatures);
|
||||||
|
} else {
|
||||||
|
throw new \Exception(self::$l->t('Could not find the desired feature'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$setFeatures = $this->configuration->$confkey;
|
||||||
|
if(is_array($setFeatures) && !empty($setFeatures)) {
|
||||||
|
//something is already configured? pre-select it.
|
||||||
|
$this->result->addChange($dbkey, $setFeatures);
|
||||||
|
} else if($po && !empty($maxEntryObjC)) {
|
||||||
|
//pre-select objectclass with most result entries
|
||||||
|
$maxEntryObjC = str_replace($p, '', $maxEntryObjC);
|
||||||
|
$this->result->addChange($dbkey, $maxEntryObjC);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief appends a list of values fr
|
* @brief appends a list of values fr
|
||||||
* @param $result resource, the return value from ldap_get_attributes
|
* @param $result resource, the return value from ldap_get_attributes
|
||||||
|
|
Loading…
Reference in New Issue