@@ -250,13 +250,13 @@ public function getUserEntries($login = null, $countOnly = false, $offset = -1,
250
250
}
251
251
252
252
if (isset ($ searchAttrArray )){
253
- if (count ($ searchAttrArray ) > 1 ){
254
- $ searchAttrFilter = "(| " ;
255
- foreach ($ searchAttrArray as $ attr ){
256
- $ searchAttrFilter .= "( " . $ attr . "= " . $ login . ") " ;
253
+ if (count ($ searchAttrArray ) > 1 ){
254
+ $ searchAttrFilter = "(| " ;
255
+ foreach ($ searchAttrArray as $ attr ){
256
+ $ searchAttrFilter .= "( " . $ attr . "= " . $ login . ") " ;
257
257
}
258
- $ searchAttrFilter .= ") " ;
259
- }
258
+ $ searchAttrFilter .= ") " ;
259
+ }
260
260
else {
261
261
$ searchAttrFilter = "( " . $ searchAttrArray [0 ] . "= " . $ login . ") " ;
262
262
}
@@ -748,14 +748,15 @@ public function updateUserObject(&$userObject)
748
748
$ valueFilters = array_map ("trim " , explode (", " , $ filter ));
749
749
}
750
750
if ($ key == "memberof " ) {
751
-
751
+ if (empty ($ valueFilters )) {
752
+ $ valueFilters = $ this ->getLdapGroupListFromDN ();
753
+ }
752
754
if ($ this ->mappedRolePrefix ) {
753
755
$ rolePrefix = $ this ->mappedRolePrefix ;
754
756
} else {
755
757
$ rolePrefix = "" ;
756
758
}
757
759
758
- /*
759
760
$ userroles = $ userObject ->getRoles ();
760
761
//remove all mapped roles before
761
762
@@ -767,7 +768,6 @@ public function updateUserObject(&$userObject)
767
768
}
768
769
}
769
770
$ userObject ->recomputeMergedRole ();
770
- */
771
771
772
772
foreach ($ memberValues as $ uniqValue => $ fullDN ) {
773
773
$ uniqValueWithPrefix = $ rolePrefix . $ uniqValue ;
@@ -914,4 +914,35 @@ public function saveCountToCache($fileContent)
914
914
file_put_contents ($ this ->getPluginCacheDir () . DIRECTORY_SEPARATOR . $ fileName , serialize ($ fileContent ));
915
915
}
916
916
}
917
- }
917
+
918
+ public function getLdapGroupListFromDN ()
919
+ {
920
+ $ origUsersDN = $ this ->ldapDN ;
921
+ $ origUsersFilter = $ this ->ldapFilter ;
922
+ $ origUsersAttr = $ this ->ldapUserAttr ;
923
+ $ this ->ldapDN = $ this ->ldapGDN ;
924
+ $ this ->ldapFilter = $ this ->ldapGFilter ;
925
+ $ this ->ldapUserAttr = $ this ->ldapGroupAttr ;
926
+
927
+ $ entries = $ this ->getUserEntries ();
928
+ $ returnArray = array ();
929
+ if (is_array ($ entries ) && $ entries ["count " ] > 0 ) {
930
+ unset($ entries ["count " ]);
931
+ foreach ($ entries as $ key => $ entry ) {
932
+ if (isset ($ this ->mappedRolePrefix )){
933
+ $ returnArray [$ this ->mappedRolePrefix . $ entry [$ this ->ldapGroupAttr ][0 ]] = $ this ->mappedRolePrefix . $ entry [$ this ->ldapGroupAttr ][0 ];
934
+ }
935
+ else {
936
+ $ returnArray [$ entry [$ this ->ldapGroupAttr ][0 ]] = $ entry [$ this ->ldapGroupAttr ][0 ];
937
+ }
938
+ }
939
+ }
940
+
941
+ $ this ->dynamicFilter = null ;
942
+ $ this ->ldapDN = $ origUsersDN ;
943
+ $ this ->ldapFilter = $ origUsersFilter ;
944
+ $ this ->ldapUserAttr = $ origUsersAttr ;
945
+
946
+ return $ returnArray ;
947
+ }
948
+ }
0 commit comments