gcue Posted May 2, 2012 Share Posted May 2, 2012 (edited) i am trying to pull the members of group A. sometimes group A has a nested group B in as a member. this sometimes carries onto several nested groups *bleh*. i am trying to build an array of members and which parent group they belong to. i am trying to find the most efficient way of doing this... here's what I have so far but this only handles up to 3 nested groups. problem is im finding some groups have more than a few nested groups! hope this makes sense.. appreciate the help! expandcollapse popupFor $y = 0 To UBound($members) - 1 ;a list of memebers from Group A If $members[$y] = "" Then ContinueLoop $member_count += 1 If StringInStr($members[$y], "@") = 0 And StringInStr($members[$y], "CN=") = 0 Then ;this is how i know if the Group A member is also a group (hence referred to as Group B) $members_2 = GetGroup_Members($members[$y]) ;pulls members of nested Group B For $z = 0 To UBound($members_2) - 1 If $members_2[$z] = "" Then ContinueLoop $member_count += 1 If StringInStr($members_2[$z], "@") = 0 And StringInStr($members_2[$z], "CN=") = 0 Then ;again this is how i know if the Group B member is also a group (hence referred to as Group C) $members_3 = GetGroup_Members($members_2[$z]) ;pulls members of nested Group C (member of Group B) For $a = 0 To UBound($members_3) - 1 If $members_3[$a] = "" Then ContinueLoop $member_count += 1 ReDim $contacts[UBound($contacts) + 1][3] $contacts[UBound($contacts) - 1][0] = $group_name $contacts[UBound($contacts) - 1][1] = $members_3[$a] $contacts[UBound($contacts) - 1][2] = "PUBLIC_GROUP" Next Else ReDim $contacts[UBound($contacts) + 1][3] $contacts[UBound($contacts) - 1][0] = $group_name $contacts[UBound($contacts) - 1][1] = $members_2[$z] $contacts[UBound($contacts) - 1][2] = "PUBLIC_GROUP" EndIf Next Else ReDim $contacts[UBound($contacts) + 1][3] $contacts[UBound($contacts) - 1][0] = $group_name $contacts[UBound($contacts) - 1][1] = $members[$y] $contacts[UBound($contacts) - 1][2] = "PUBLIC_GROUP" EndIf Next Edited May 2, 2012 by gcue Link to comment Share on other sites More sharing options...
Mechaflash Posted May 2, 2012 Share Posted May 2, 2012 (edited) So you want to look for Joe in group1, and if you find him, search in group1's nested group, and if you find him there another nested group? Do you also have to search a group2 with nested groups as well for the same person? Group 1 (FOUND HIM) Nested 1 (FOUND HIM) Nested 2 (FOUND HIM) Nested 3 (nope... return Nested 2) Group 2 ( FOUND HIM) Nested 1 (nope... return Group 2) Edited May 2, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
gcue Posted May 2, 2012 Author Share Posted May 2, 2012 actually not really looking for someone specific just want to drill down all the nested groups to the point where i have a listing of all the members and not any groups in the member list. Link to comment Share on other sites More sharing options...
water Posted May 2, 2012 Share Posted May 2, 2012 Hi gcue, I assume you are talking about Active Directory groups? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gcue Posted May 2, 2012 Author Share Posted May 2, 2012 no, lotus notes dist list groups =) Link to comment Share on other sites More sharing options...
water Posted May 2, 2012 Share Posted May 2, 2012 A recursively called function should do what you want. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gcue Posted May 2, 2012 Author Share Posted May 2, 2012 (edited) not sure what you mean? you mean a function which repeats the same for loop to save on code lines? im trying to figure out on how to drill down exactly the amount of levels that i need to. no more no less =) in other words get all the members (even from nested groups-an unknown amount of levels) as efficient as possible Edited May 2, 2012 by gcue Link to comment Share on other sites More sharing options...
Mechaflash Posted May 2, 2012 Share Posted May 2, 2012 (edited) Global $fCheckNestedGroup = True Global $sGroupName While $fCheckNestedGroup _CheckNestedGroup($sGroupName) WEnd Func _CheckNestedGroup($s) [ ... your code here to enumerate the group ... ] If [... check for additional nested group ... ] = true then $fCheckNestedGroup = True $sGroupName = $sNestedGroupName Else $fCheckNestedGroup = False EndIf EndFunc Maybe this kind of logic will work? Edited May 2, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
gcue Posted May 2, 2012 Author Share Posted May 2, 2012 ah that seems like it would work.. let me try it.. water, i think this is what you were talking about too thanks water/mechaflash! Link to comment Share on other sites More sharing options...
water Posted May 3, 2012 Share Posted May 3, 2012 gcue,Wikipedia: "Recursion is the process of repeating items in a self-similar way."How it is used in computer sciencie s defined here.For an AutoIt example please check my OutlookEX UDF, function_OL_FolderFind. This function calls itself until all folders have been processed. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gcue Posted May 3, 2012 Author Share Posted May 3, 2012 (edited) very cool solution water - getting stack overflow - hmmm here's what i came up with: Func GetGroup_Members($group_name) $dbView = $db.GetView("Groups") $doc = $dbView.GetDocumentByKey($group_name, True) If Not IsObj($doc) Then Return "INVALID_GROUP" EndIf $members = $doc.GetItemValue("Members") For $y = 0 To UBound($members) - 1 If $members[$y] = "" Then ContinueLoop If StringInStr($members[$y], "@") = 0 And StringInStr($members[$y], "CN=") = 0 Then ;this is how i know the member is a group $members_nested = GetGroup_Members($members[$y]) ;so i pull group members again and add to the same array For $z = 0 To UBound($members_nested) - 1 ReDim $members[UBound($members) + 1] $members[UBound($members) - 1] = $members[$z] Next Else ReDim $members[UBound($members) + 1] $members[UBound($members) - 1] = $members[$y] EndIf Next Return $members EndFunc ;==>GetGroup_Members Edited May 3, 2012 by gcue Link to comment Share on other sites More sharing options...
water Posted May 3, 2012 Share Posted May 3, 2012 (edited) Hi gcue, the initial processing has to be done outside of the function - because you call this function over and over again. You just pass the starting point (the group) to the function. This starting point has always to be of the same type - a group name, group object etc. I think the following part of the code has to be outside the function to "calculate" the starting point. $dbView = $db.GetView("Groups") $doc = $dbView.GetDocumentByKey($group_name, True) If Not IsObj($doc) Then Return "INVALID_GROUP" EndIf $members = $doc.GetItemValue("Members") After the you start the enxt recursion level you have to assign the result ($members_nested) to the total result ($members). Now you assing $members to $members. If you have questions I will provide more details tomorrow. Edited May 3, 2012 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gcue Posted May 3, 2012 Author Share Posted May 3, 2012 hmm not sure i understand what you mean.. that section you're referrign to is how i get the members of a group - dont see how that wouldnt be a part of the recursive function. thanks for your help water - much appreciated! Link to comment Share on other sites More sharing options...
water Posted May 3, 2012 Share Posted May 3, 2012 I see. Then at least $dbView = $db.GetView("Groups")should be outside the function an passed as a parameter. I will check the code and post an example for you to test. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted May 3, 2012 Share Posted May 3, 2012 OK. Here is some is some code for you to play with $dbView = $db.GetView("Groups") $sGrouName = "Group name you want to process" $aResult = GetGroup_Members($dbView, $sGroupName) _ArrayDisplay($aResult) Exit Func GetGroup_Members($dbView, $group_name) $doc = $dbView.GetDocumentByKey($group_name, True) If Not IsObj($doc) Then Return "" $members = $doc.GetItemValue("Members") For $y = 0 To UBound($members) - 1 If $members[$y] = "" Then ContinueLoop If StringInStr($members[$y], "@") = 0 And StringInStr($members[$y], "CN=") = 0 Then ;this is how i know the member is a group $members_nested = GetGroup_Members($dbView, $members[$y]) ;so i pull group members again and add to the same array If IsArray($members_nested) Then $iMembers = UBound($members) ReDim $members[UBound($members) + UBound($members_nested)] For $z = 0 To UBound($members_nested) - 1 $members[$imembers + $z] = $members_nested[$z] Next EndIf Else ReDim $members[UBound($members) + 1] $members[UBound($members) - 1] = $members[$y] EndIf Next Return $members EndFunc ;==>GetGroup_Members My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
gcue Posted May 3, 2012 Author Share Posted May 3, 2012 actually still getting stack overflow.. ill continue to play with it.. thanks =) Link to comment Share on other sites More sharing options...
Mechaflash Posted May 3, 2012 Share Posted May 3, 2012 If you're getting stack overflow errors, you need to slow the process down (i.e. add some sleeps). What's happening is it's looping too quickly and its reading data into memory faster than it can take it out. You're trying to make the fat kid run for his cake. Xandy 1 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” Link to comment Share on other sites More sharing options...
gcue Posted May 3, 2012 Author Share Posted May 3, 2012 hahahhahahahhaha love the analogy - made me laugh for a while ill try it out thanks mechaflash Link to comment Share on other sites More sharing options...
gcue Posted May 3, 2012 Author Share Posted May 3, 2012 still had a stack overflow even with different sleeps in place hmmm Link to comment Share on other sites More sharing options...
water Posted May 3, 2012 Share Posted May 3, 2012 Can you post the exact message? Is it created by AutoIt or the operating system? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now