@@ -67,6 +67,11 @@ class Group_LDAP extends BackendUtility implements \OCP\GroupInterface, IGroupLD
6767 /** @var GroupPluginManager */
6868 protected $ groupPluginManager ;
6969
70+ /**
71+ * @var string $ldapGroupMemberAssocAttr contains the LDAP setting (in lower case) with the same name
72+ */
73+ protected $ ldapGroupMemberAssocAttr ;
74+
7075 public function __construct (Access $ access , GroupPluginManager $ groupPluginManager ) {
7176 parent ::__construct ($ access );
7277 $ filter = $ this ->access ->connection ->ldapGroupFilter ;
@@ -79,6 +84,7 @@ public function __construct(Access $access, GroupPluginManager $groupPluginManag
7984 $ this ->cachedGroupsByMember = new CappedMemoryCache ();
8085 $ this ->cachedNestedGroups = new CappedMemoryCache ();
8186 $ this ->groupPluginManager = $ groupPluginManager ;
87+ $ this ->ldapGroupMemberAssocAttr = strtolower ($ gassoc );
8288 }
8389
8490 /**
@@ -131,12 +137,11 @@ public function inGroup($uid, $gid) {
131137 //usually, LDAP attributes are said to be case insensitive. But there are exceptions of course.
132138 $ members = $ this ->_groupMembers ($ groupDN );
133139
134- if (strtolower ($ this ->access ->connection ->ldapGroupMemberAssocAttr ) !== 'zimbramailforwardingaddress '
135- && strtolower ($ this ->access ->connection ->ldapGroupMemberAssocAttr ) !== 'memberuid ' ) {
136-
140+ if ($ this ->ldapGroupMemberAssocAttr !== 'zimbramailforwardingaddress '
141+ && $ this ->ldapGroupMemberAssocAttr !== 'memberuid ' ) {
137142 $ members = array_keys ($ members );
138- // DNs are returned as keys; todo: this is probably only the case if
139- // nested groups are used and group member attributes are DNs - needs fixing
143+ // DNs are returned as keys; this is probably only the case if
144+ // nested groups are used and/or group member attributes are DNs
140145 }
141146
142147 if (!is_array ($ members ) || count ($ members ) === 0 ) {
@@ -145,14 +150,14 @@ public function inGroup($uid, $gid) {
145150 }
146151
147152 //extra work if we don't get back user DNs
148- switch (strtolower ( $ this ->access -> connection -> ldapGroupMemberAssocAttr ) ) {
153+ switch ($ this ->ldapGroupMemberAssocAttr ) {
149154 case 'memberuid ' :
150155 case 'zimbramailforwardingaddress ' :
151156 $ dns = array ();
152157 $ filterParts = array ();
153158 $ bytes = 0 ;
154159 foreach ($ members as $ mid ) {
155- if (strtolower ( $ this ->access -> connection -> ldapGroupMemberAssocAttr ) === 'zimbramailforwardingaddress ' ) {
160+ if ($ this ->ldapGroupMemberAssocAttr === 'zimbramailforwardingaddress ' ) {
156161 $ parts = explode ('@ ' , $ mid ); //making sure we get only the uid
157162 $ mid = $ parts [0 ];
158163 }
@@ -721,8 +726,8 @@ public function getUserGroups($uid) {
721726 // memberof doesn't support memberuid, so skip it here.
722727 if ((int )$ this ->access ->connection ->hasMemberOfFilterSupport === 1
723728 && (int )$ this ->access ->connection ->useMemberOfToDetectMembership === 1
724- && strtolower ( $ this ->access -> connection -> ldapGroupMemberAssocAttr ) !== 'memberuid '
725- && strtolower ( $ this ->access -> connection -> ldapGroupMemberAssocAttr ) !== 'zimbramailforwardingaddress ' ) {
729+ && $ this ->ldapGroupMemberAssocAttr !== 'memberuid '
730+ && $ this ->ldapGroupMemberAssocAttr !== 'zimbramailforwardingaddress ' ) {
726731 $ groupDNs = $ this ->_getGroupDNsFromMemberOf ($ userDN );
727732 if (is_array ($ groupDNs )) {
728733 foreach ($ groupDNs as $ dn ) {
@@ -746,7 +751,7 @@ public function getUserGroups($uid) {
746751 }
747752
748753 //uniqueMember takes DN, memberuid the uid, so we need to distinguish
749- switch (strtolower ( $ this ->access -> connection -> ldapGroupMemberAssocAttr ) ) {
754+ switch ($ this ->ldapGroupMemberAssocAttr ) {
750755 case 'uniquemember ' :
751756 case 'member ' :
752757 $ uid = $ userDN ;
@@ -807,7 +812,7 @@ private function getGroupsByMember($dn, &$seen = null) {
807812 $ seen [$ dn ] = true ;
808813 $ filter = $ this ->access ->connection ->ldapGroupMemberAssocAttr .'= ' .$ dn ;
809814
810- if (strtolower ( $ this ->access -> connection -> ldapGroupMemberAssocAttr ) === 'zimbramailforwardingaddress ' )
815+ if ($ this ->ldapGroupMemberAssocAttr === 'zimbramailforwardingaddress ' )
811816 //in this case the member entries are email addresses
812817 $ filter .= '@* ' ;
813818
@@ -880,7 +885,7 @@ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
880885 $ groupUsers = array ();
881886 $ attrs = $ this ->access ->userManager ->getAttributes (true );
882887 foreach ($ members as $ member ) {
883- switch (strtolower ( $ this ->access -> connection -> ldapGroupMemberAssocAttr ) ) {
888+ switch ($ this ->ldapGroupMemberAssocAttr ) {
884889 case 'zimbramailforwardingaddress ' :
885890 //we get email addresses and need to convert them to uids
886891 $ parts = explode ('@ ' , $ member );
@@ -969,8 +974,8 @@ public function countUsersInGroup($gid, $search = '') {
969974 }
970975 $ search = $ this ->access ->escapeFilterPart ($ search , true );
971976 $ isMemberUid =
972- (strtolower ( $ this ->access -> connection -> ldapGroupMemberAssocAttr ) === 'memberuid ' ||
973- strtolower ( $ this ->access -> connection -> ldapGroupMemberAssocAttr ) === 'zimbramailforwardingaddress ' );
977+ ($ this ->ldapGroupMemberAssocAttr === 'memberuid ' ||
978+ $ this ->ldapGroupMemberAssocAttr === 'zimbramailforwardingaddress ' );
974979
975980 //we need to apply the search filter
976981 //alternatives that need to be checked:
@@ -983,7 +988,7 @@ public function countUsersInGroup($gid, $search = '') {
983988 $ groupUsers = array ();
984989 foreach ($ members as $ member ) {
985990 if ($ isMemberUid ) {
986- if (strtolower ( $ this ->access -> connection -> ldapGroupMemberAssocAttr ) === 'zimbramailforwardingaddress ' ) {
991+ if ($ this ->ldapGroupMemberAssocAttr === 'zimbramailforwardingaddress ' ) {
987992 //we get email addresses and need to convert them to uids
988993 $ parts = explode ('@ ' , $ member );
989994 $ member = $ parts [0 ];
0 commit comments