@@ -112,7 +112,9 @@ public function getGroupMembers($resourceOwnerId, $groupId, $startIndex = 0, $co
112112 $ memberAttribute = $ this ->config ->s ('LdapVootStorage ' )->l ('memberAttribute ' );
113113
114114 $ userDn = $ this ->getUserDn ($ resourceOwnerId );
115-
115+
116+ $ groupsProvider = $ this ->config ->s ('LdapVootStorage ' )->l ('groupsProvider ' );
117+
116118 // FIXME: make sure the user is member of the group being requested
117119
118120 $ filter = '(cn= ' . $ groupId . ') ' ;
@@ -127,6 +129,17 @@ public function getGroupMembers($resourceOwnerId, $groupId, $startIndex = 0, $co
127129 if (false === $ query ) {
128130 throw new VootStorageException ("ldap_error " , "directory query for group failed " );
129131 }
132+
133+ $ all = ldap_get_entries ($ this ->ldapConnection , $ query );
134+
135+ switch ($ groupsProvider ) {
136+ case "posixgroup " :
137+ // we are only interested in group memberuid array
138+ $ attributes = $ all [0 ];
139+ break ;
140+ default :
141+ break ;
142+ }
130143
131144 $ entry = @ldap_first_entry ($ this ->ldapConnection , $ query );
132145 if (false === $ entry ) {
@@ -143,7 +156,16 @@ public function getGroupMembers($resourceOwnerId, $groupId, $startIndex = 0, $co
143156 for ($ i = 0 ; $ i < $ attributes [$ memberAttribute ]["count " ]; $ i ++) {
144157 // member DN
145158 // fetch attributes for this particular user
146- $ userAttributes = $ this ->getUserAttributesByDn ($ attributes [$ memberAttribute ][$ i ]);
159+ switch ($ groupsProvider ) {
160+ case "posixgroup " :
161+ $ user_dn = 'uid= ' . $ attributes [$ memberAttribute ][$ i ] . ', ' . $ this ->config ->s ('LdapVootStorage ' )->l ('peopleDn ' );
162+ $ userAttributes = $ this ->getUserAttributesByDn ($ user_dn );
163+ break ;
164+ default :
165+ $ userAttributes = $ this ->getUserAttributesByDn ($ attributes [$ memberAttribute ][$ i ]);
166+ break ;
167+ }
168+
147169 $ userAttributes ['voot_membership_role ' ] = "member " ;
148170 array_push ($ data , $ userAttributes );
149171 }
@@ -167,8 +189,19 @@ public function isMemberOf($resourceOwnerId, $startIndex = null, $count = null)
167189 $ userDn = $ this ->getUserDn ($ resourceOwnerId );
168190
169191 $ userGroups = array ();
192+
193+ $ groupsProvider = $ this ->config ->s ('LdapVootStorage ' )->l ('groupsProvider ' );
194+
170195 /* get the groups the user is a member of */
171- $ filter = '( ' . $ this ->config ->s ('LdapVootStorage ' )->l ('memberAttribute ' ) . '= ' . $ userDn . ') ' ;
196+ switch ($ groupsProvider ) {
197+ case "posixgroup " :
198+ $ filter = '( ' . $ this ->config ->s ('LdapVootStorage ' )->l ('memberAttribute ' ) . '= ' . $ resourceOwnerId . ') ' ;
199+ break ;
200+ default :
201+ $ filter = '( ' . $ this ->config ->s ('LdapVootStorage ' )->l ('memberAttribute ' ) . '= ' . $ userDn . ') ' ;
202+ break ;
203+ }
204+
172205 $ query = @ldap_search ($ this ->ldapConnection , $ this ->config ->s ('LdapVootStorage ' )->l ('groupDn ' ), $ filter );
173206 if (false === $ query ) {
174207 throw new VootStorageException ("ldap_error " , "directory query for groups failed " );
0 commit comments