LDAP group backend: If a group filter is not configured, do not do anything. Fixes oc-867
This commit is contained in:
parent
0468f53f73
commit
86279bc192
|
@ -25,10 +25,15 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
|
||||||
// //group specific settings
|
// //group specific settings
|
||||||
protected $ldapGroupFilter;
|
protected $ldapGroupFilter;
|
||||||
protected $ldapGroupMemberAssocAttr;
|
protected $ldapGroupMemberAssocAttr;
|
||||||
|
protected $configured = false;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->ldapGroupFilter = OCP\Config::getAppValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)');
|
$this->ldapGroupFilter = OCP\Config::getAppValue('user_ldap', 'ldap_group_filter', '(objectClass=posixGroup)');
|
||||||
$this->ldapGroupMemberAssocAttr = OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember');
|
$this->ldapGroupMemberAssocAttr = OCP\Config::getAppValue('user_ldap', 'ldap_group_member_assoc_attribute', 'uniqueMember');
|
||||||
|
|
||||||
|
if(empty($this->ldapGroupFilter) || empty($this->ldapGroupMemberAssocAttr)) {
|
||||||
|
$this->configured = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +45,9 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
|
||||||
* Checks whether the user is member of a group or not.
|
* Checks whether the user is member of a group or not.
|
||||||
*/
|
*/
|
||||||
public function inGroup($uid, $gid) {
|
public function inGroup($uid, $gid) {
|
||||||
|
if(!$this->configured) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$dn_user = OC_LDAP::username2dn($uid);
|
$dn_user = OC_LDAP::username2dn($uid);
|
||||||
$dn_group = OC_LDAP::groupname2dn($gid);
|
$dn_group = OC_LDAP::groupname2dn($gid);
|
||||||
// just in case
|
// just in case
|
||||||
|
@ -79,6 +87,9 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
|
||||||
* if the user exists at all.
|
* if the user exists at all.
|
||||||
*/
|
*/
|
||||||
public function getUserGroups($uid) {
|
public function getUserGroups($uid) {
|
||||||
|
if(!$this->configured) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
$userDN = OC_LDAP::username2dn($uid);
|
$userDN = OC_LDAP::username2dn($uid);
|
||||||
if(!$userDN) {
|
if(!$userDN) {
|
||||||
return array();
|
return array();
|
||||||
|
@ -111,6 +122,10 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
|
||||||
* @returns array with user ids
|
* @returns array with user ids
|
||||||
*/
|
*/
|
||||||
public function usersInGroup($gid) {
|
public function usersInGroup($gid) {
|
||||||
|
if(!$this->configured) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$groupDN = OC_LDAP::groupname2dn($gid);
|
$groupDN = OC_LDAP::groupname2dn($gid);
|
||||||
if(!$groupDN) {
|
if(!$groupDN) {
|
||||||
return array();
|
return array();
|
||||||
|
@ -149,6 +164,10 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
|
||||||
* Returns a list with all groups
|
* Returns a list with all groups
|
||||||
*/
|
*/
|
||||||
public function getGroups() {
|
public function getGroups() {
|
||||||
|
if(!$this->configured) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$ldap_groups = OC_LDAP::fetchListOfGroups($this->ldapGroupFilter, array(OC_LDAP::conf('ldapGroupDisplayName'), 'dn'));
|
$ldap_groups = OC_LDAP::fetchListOfGroups($this->ldapGroupFilter, array(OC_LDAP::conf('ldapGroupDisplayName'), 'dn'));
|
||||||
$groups = OC_LDAP::ownCloudGroupNames($ldap_groups);
|
$groups = OC_LDAP::ownCloudGroupNames($ldap_groups);
|
||||||
return $groups;
|
return $groups;
|
||||||
|
|
Loading…
Reference in New Issue