diff --git a/all/modules/ldap_integration/ldapgroups.inc b/all/modules/ldap_integration/ldapgroups.inc
old mode 100644
new mode 100755
index 8217700..dbfa714
--- a/all/modules/ldap_integration/ldapgroups.inc
+++ b/all/modules/ldap_integration/ldapgroups.inc
@@ -112,12 +112,51 @@ function _ldapgroups_detect_groups($user) {
     }
   }
 
+  /**
+   *  Recursive function to find nested groups
+   *
+   *  @param string $dn
+   *  @param object $_ldapgroups_ldap -> the current ldapgroups object
+   *  @param string $ldapgroups_attr -> which attribute holds the group DNs
+   *  @param bool $is_user_dn -> whether $dn is the user DN, rather than a group DN
+   *  @return array of group DNs this user is a member of.  May contain duplicates.
+   */
+  function _ldap_recursive_groups($dn, $_ldapgroups_ldap, $ldapgroups_attr, $is_user_dn=false) {
+    $group_children = $_ldapgroups_ldap->retrieveMultiAttribute($dn, $ldapgroups_attr);
+    if (empty($group_children)) {
+      return $is_user_dn ? array() : array($dn);
+    }
+    else {
+      $group_grandchildren = array($dn); // Add parent $dn too
+      foreach ($group_children as $child) {
+		$group_grandchildren = array_merge($group_grandchildren,
+		  _ldap_recursive_groups($child, $_ldapgroups_ldap, $ldapgroups_attr));
+      }
+      return $group_grandchildren;
+    }
+  }
+
+  // HACKED Strategy 2: groups in user attributes with nested group support
+  $attrib_groups = array();
+  if (_ldapgroups_ldap_info($user, 'ldapgroups_in_attr')) {
+    foreach (_ldapgroups_ldap_info($user, 'ldapgroups_attr') as $attribute) {
+      $attrib_groups = array_merge($attrib_groups, $_ldapgroups_ldap->retrieveMultiAttribute($user->ldap_dn, $attribute));
+
+      // Add nested groups
+      $child_groups = _ldap_recursive_groups($user->ldap_dn, $_ldapgroups_ldap, $attribute, true);
+      $attrib_groups = array_values(array_unique(array_merge($attrib_groups, $child_groups)));
+
+	}
+  }
+
+/*
   // Strategy 2: groups in user attributes.
   $attrib_groups = array();
   if (_ldapgroups_ldap_info($user, 'ldapgroups_in_attr')) {
     foreach (_ldapgroups_ldap_info($user, 'ldapgroups_attr') as $attribute)
       $attrib_groups = array_merge($attrib_groups, $_ldapgroups_ldap->retrieveMultiAttribute($user->ldap_dn, $attribute));
   }
+*/
 
   // Strategy 3: groups as entries.
   $entries_groups = array();
