Author: Nathan.Vonnahme
Date: 2010-02-04 02:33:46 +0100 (Thu, 04 Feb 2010)
New Revision: 27532
Modified:
plugins/bhLDAPAuthPlugin/branches/1.1/lib/adLDAP.php
plugins/bhLDAPAuthPlugin/branches/1.1/lib/bhLDAP.php
Log:
improvements to recursive group enumeration
Modified: plugins/bhLDAPAuthPlugin/branches/1.1/lib/adLDAP.php
===================================================================
--- plugins/bhLDAPAuthPlugin/branches/1.1/lib/adLDAP.php 2010-02-04
01:27:06 UTC (rev 27531)
+++ plugins/bhLDAPAuthPlugin/branches/1.1/lib/adLDAP.php 2010-02-04
01:33:46 UTC (rev 27532)
@@ -276,27 +276,37 @@
}
// Retun a complete list of "groups in groups"
- function recursive_groups($group){
- if ($group==NULL){ return (false); }
- $ret_groups=array();
-
- $groups=$this->group_info($group,array("memberof"));
+ // this version hacked by ben
+
+ public function recursive_groups($group){
+ if ($group===NULL){ return (false); }
+
+ $ret_groups=Array($group);
+ $new_groups=Array($group);
+
+ while(count($new_groups)>0) { // The list of groups that need to be
checked for membership
+ $more_groups=Array();
+
+ foreach ($new_groups as $group_name) {
+ $grou...@$this->group_info($group_name,array("memberof")); // Get
groups this group is a member of
+
+ if (array_key_exists("memberof", $groups[0])) {
$groups=$groups[0]["memberof"];
-
if ($groups){
- $group_names=$this->nice_names($groups);
- $ret_groups=array_merge($ret_groups,$group_names);
//final groups to return
-
- foreach ($group_names as $id => $group_name){
-
$child_groups=$this->recursive_groups($group_name);
-
$ret_groups=array_merge($ret_groups,$child_groups);
- }
+ $group_names=$this->nice_names($groups);
+
$more_groups=array_unique(array_merge($more_groups,$group_names)); //final
groups to return
}
+ }
- return ($ret_groups);
+ }
+ $ret_groups = array_unique(array_merge($ret_groups,$more_groups));
// Add the groups to the main list
+ $new_groups=array_diff($more_groups,$ret_groups);
+ }
+ return ($ret_groups);
}
-
+
+
//*****************************************************************************************************************
// USER FUNCTIONS
@@ -357,7 +367,7 @@
if ($recursive){
foreach ($groups as $id => $group_name){
$extra_groups=$this->recursive_groups($group_name);
- $groups=array_merge($groups,$extra_groups);
+
$groups=array_unique(array_merge($groups,$extra_groups));
}
}
Modified: plugins/bhLDAPAuthPlugin/branches/1.1/lib/bhLDAP.php
===================================================================
--- plugins/bhLDAPAuthPlugin/branches/1.1/lib/bhLDAP.php 2010-02-04
01:27:06 UTC (rev 27531)
+++ plugins/bhLDAPAuthPlugin/branches/1.1/lib/bhLDAP.php 2010-02-04
01:33:46 UTC (rev 27532)
@@ -81,7 +81,13 @@
self::debug("checking recursive group memberships");
foreach ($groups as $id => $group_name){
$extra_grou...@$ldap->recursive_groups($group_name);
- $groups=array_merge($groups,$extra_groups);
+
+# $extra_groups=self::recursive_groups($group_name);
+ $groups=array_unique(array_merge($groups,$extra_groups));
+
+ self::debugDump($groups, "fully recursive list of groups for
$username");
+ sort($groups);
+ self::debugDump($groups, "SORTED fully recursive list of groups for
$username");
}
}
@@ -160,6 +166,56 @@
}
+
+
+ // this version hacked by ben
+ public static function XXXXXXrecursive_groups($group){
+ if ($group===NULL){ return (false); }
+
+ $ret_groups=Array($group);
+ $new_groups=Array($group);
+
+ $ldap = self::getLDAP();
+
+
+ # $i = 0;
+ while(count($new_groups)>0) { // The list of groups that need to be
checked for membership
+ self::debugDump($ret_groups, "ret_groups");
+ self::debugDump($new_groups, "descending into these new groups");
+
+ self::debug("FOREACHING new_groups");
+ $more_groups=Array();
+
+# if ($i++ == 2) break;
+ foreach ($new_groups as $group_name) {
+ self::debug("HELLOWORLD $group_name");
+ $grou...@$ldap->group_info($group_name,array("memberof")); // Get
groups this group is a member of
+ self::debugDump($groups, "groups returned by group_info");
+
+ if (array_key_exists("memberof", $groups[0])) {
+ $groups=$groups[0]["memberof"];
+ if ($groups){
+ $group_names=$ldap->nice_names($groups);
+ $more_groups=array_unique(array_merge($more_groups,$group_names));
//final groups to return
+ }
+ }
+
+ }
+ $ret_groups = array_unique(array_merge($ret_groups,$more_groups)); //
Add the groups to the main list
+ self::debug("diffing these:");
+ self::debugDump($more_groups, "more_groups");
+ self::debugDump($ret_groups, "ret_groups");
+ $new_groups=array_diff($more_groups,$ret_groups);
+ }
+ self::debugDump($ret_groups, "REETURENUIVFYING this ret_groups");
+ return ($ret_groups);
+ }
+
+
+
+
+
+
}
//sfeof
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.