You need to map the directory tree, as you move through it, so you can check to see if you have previously explored a DN, some Active Directories contain looped group inclusions.  So you'll need to guard against it.

This solution also doesn't require recursion.

In some pseudo code

def getGroupsOfDN(userDN)

     groups = []
     groupsExplored = []
     groupsToExplore = []


     current = userDN
     groupsToExplore &lt;&lt; userDN

     while(!groupsToExplore.empty?)


        ldapentry = ldap_lookup(current)

        if (!ldapentry.nil?)
           groups &lt;&lt; current
           current_groups = ldapentry.getAttributes("memberOf")
           current_groups.each do |groupDN|
              if(groupsExplored.indexOf(groupDN) != -1)
                 groupsToExplore &lt;&lt; groupDN
                 groupsExplored &lt;&lt; groupDN
              end
           end
        end

        groupsToExplore.remove(current)
        if (!groupsToExplore.empty?)
           current = groupsToExplore.get(0)            
     end
     return groups
end


AD via LDAP - How can I return all ancestor groups from a query?
I am purchasing a flat in Brisbane, Queensland Australia. Prior to purchase, I had the building inspected and they've noted that the balcony balustrade doesn't meet height requirements for my jurisdiction. 

Specifically:


The balcony is more than 1 meter above the ground.
The balustrade is not quite 1 meter high.


The structure was built in the 1970s, prior to the regulations being put into place. If I take ownership of the property as is, am I obligated to replace the balustrade?
