Skip to content

Commit

Permalink
fixes possible override of uniqueMember by autodetection
Browse files Browse the repository at this point in the history
* uniqueMember was the default so we did not know whether this setting is
  desired or the initial value
* autodetection of the user-group association attribute runs only when it
  was not set (as far as we knew)
* the default is now empty
* thus LDAPProvider might return this value as well (in exceptional cases)
* if a group base is given (edge case), use this instead of general base
* resolves #12682

Signed-off-by: Arthur Schiwon <[email protected]>
  • Loading branch information
blizzz committed May 17, 2019
1 parent 528eb1b commit 3372bcc
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ OCA = OCA || {};
run: function(model, configID) {
// TODO: might be better with configuration marker as uniqueMember
// is a valid value (although probably less common then member and memberUid).
if(model.configuration.ldap_group_member_assoc_attribute && model.configuration.ldap_group_member_assoc_attribute !== 'uniqueMember') {
if(model.configuration.ldap_group_member_assoc_attribute && model.configuration.ldap_group_member_assoc_attribute !== '') {
// a value is already set. Don't overwrite and don't ask LDAP
// without reason.
return false;
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ public function getDefaults() {
'ldap_quota_def' => '',
'ldap_quota_attr' => '',
'ldap_email_attr' => '',
'ldap_group_member_assoc_attribute' => 'uniqueMember',
'ldap_group_member_assoc_attribute' => '',
'ldap_cache_ttl' => 600,
'ldap_uuid_user_attribute' => 'auto',
'ldap_uuid_group_attribute' => 'auto',
Expand Down
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/LDAPProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public function getLDAPEmailField($uid) {
/**
* Get the LDAP type of association between users and groups
* @param string $gid group id
* @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber'
* @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber', ''
* @throws \Exception if group id was not found in LDAP
*/
public function getLDAPGroupMemberAssoc($gid) {
Expand Down
6 changes: 3 additions & 3 deletions apps/user_ldap/lib/Wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ private function checkHost() {
* @throws \Exception
*/
private function detectGroupMemberAssoc() {
$possibleAttrs = array('uniqueMember', 'memberUid', 'member', 'gidNumber');
$possibleAttrs = ['uniqueMember', 'memberUid', 'member', 'gidNumber'];
$filter = $this->configuration->ldapGroupFilter;
if(empty($filter)) {
return false;
Expand All @@ -803,7 +803,7 @@ private function detectGroupMemberAssoc() {
if(!$cr) {
throw new \Exception('Could not connect to LDAP');
}
$base = $this->configuration->ldapBase[0];
$base = $this->configuration->ldapBaseGroups[0] ?: $this->configuration->ldapBase[0];
$rr = $this->ldap->search($cr, $base, $filter, $possibleAttrs, 0, 1000);
if(!$this->ldap->isResource($rr)) {
return false;
Expand All @@ -812,7 +812,7 @@ private function detectGroupMemberAssoc() {
while(is_resource($er)) {
$this->ldap->getDN($cr, $er);
$attrs = $this->ldap->getAttributes($cr, $er);
$result = array();
$result = [];
$possibleAttrsCount = count($possibleAttrs);
for($i = 0; $i < $possibleAttrsCount; $i++) {
if(isset($attrs[$possibleAttrs[$i]])) {
Expand Down
2 changes: 1 addition & 1 deletion lib/public/LDAP/ILDAPProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function getLDAPEmailField($uid);
/**
* Get the LDAP attribute name for the type of association betweeen users and groups
* @param string $gid group id
* @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber'
* @return string the configuration, one of: 'memberUid', 'uniqueMember', 'member', 'gidNumber', ''
* @throws \Exception if group id was not found in LDAP
* @since 13.0.0
*/
Expand Down

0 comments on commit 3372bcc

Please sign in to comment.