I am querying Active Directory via LDAP (from Java and PHP) to build a list of all groups that a user is a member of. This list must contain all least all groups (organizational-units optional) that contain groups the user is directly a member of. For example:

User1 is a member of GroupA, GroupB, and GroupC.

GroupA is a member of GroupD.

I am looking for a way to construct an LDAP query that will return GroupA, GroupB, GroupC, and GroupD all at once.

My current implementation is below, but I am looking for a more efficient way to gather this information.

Current Naive Implementation (In pseudo-code)

user = ldap_search('samaccountname=johndoe', baseDN);
allGroups = array();
foreach (user.getAttribute('memberOf') as groupDN) {
    allGroups.push(groupDN);
    allGroups = allGroups.merge(getAncestorGroups(groupDN));
}

function getAncestorGroups(groupDN) {
    allGroups = array();
    group = ldap_lookup(groupDN);
    parents = group.getAttribute('memberOf');
    foreach (parents as groupDN) {
        allGroups.push(groupDN);
        allGroups = allGroups.merge(getAncestorGroups(groupDN));
    }
    return allGroups;
}



Question: Does the original jutsu user feel anything when a shadow clone is dispersed forcefully?
Answer: You basically answered your own question. It is indeed stated that Naruto receives the experience, mental stress and chakra of the clone. When a clone is destroyed, it, of course, had mental stress (as it just got attacked and killed).

Most of the times you do not see this, either because Naruto is used to this and has an immense capacity to endure this, or because the technique would become meaningless if he could not use it due to all the stress. (I suspect the latter)

Although, during the training where he uses his clones to decrease the training duration, it became clear that is was very hard on him due to the mental stress he received of his clones.