@@ -112,7 +112,9 @@ public function getGroupMembers($resourceOwnerId, $groupId, $startIndex = 0, $co
112
112
$ memberAttribute = $ this ->config ->s ('LdapVootStorage ' )->l ('memberAttribute ' );
113
113
114
114
$ userDn = $ this ->getUserDn ($ resourceOwnerId );
115
-
115
+
116
+ $ groupsProvider = $ this ->config ->s ('LdapVootStorage ' )->l ('groupsProvider ' );
117
+
116
118
// FIXME: make sure the user is member of the group being requested
117
119
118
120
$ filter = '(cn= ' . $ groupId . ') ' ;
@@ -127,6 +129,17 @@ public function getGroupMembers($resourceOwnerId, $groupId, $startIndex = 0, $co
127
129
if (false === $ query ) {
128
130
throw new VootStorageException ("ldap_error " , "directory query for group failed " );
129
131
}
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
+ }
130
143
131
144
$ entry = @ldap_first_entry ($ this ->ldapConnection , $ query );
132
145
if (false === $ entry ) {
@@ -143,7 +156,16 @@ public function getGroupMembers($resourceOwnerId, $groupId, $startIndex = 0, $co
143
156
for ($ i = 0 ; $ i < $ attributes [$ memberAttribute ]["count " ]; $ i ++) {
144
157
// member DN
145
158
// 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
+
147
169
$ userAttributes ['voot_membership_role ' ] = "member " ;
148
170
array_push ($ data , $ userAttributes );
149
171
}
@@ -167,8 +189,19 @@ public function isMemberOf($resourceOwnerId, $startIndex = null, $count = null)
167
189
$ userDn = $ this ->getUserDn ($ resourceOwnerId );
168
190
169
191
$ userGroups = array ();
192
+
193
+ $ groupsProvider = $ this ->config ->s ('LdapVootStorage ' )->l ('groupsProvider ' );
194
+
170
195
/* 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
+
172
205
$ query = @ldap_search ($ this ->ldapConnection , $ this ->config ->s ('LdapVootStorage ' )->l ('groupDn ' ), $ filter );
173
206
if (false === $ query ) {
174
207
throw new VootStorageException ("ldap_error " , "directory query for groups failed " );
0 commit comments