bourny Posted February 15, 2013 Posted February 15, 2013 I have ran many AD queries in the past using some of the AD functions and includes I found on the forum. I am trying to now query AD for a list of groups a computer account is a member of. This seems to be defying me, Can anyone suggest the best way to return a list of groups a computer account is a member of.
Moderators JLogan3o13 Posted February 15, 2013 Moderators Posted February 15, 2013 Hi, bourny. It sounds like you're already using the If you take a look at the different functions of the latest UDF, I believe the _AD_RecursiveGetMemberOf function will do what you would like. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
bourny Posted February 18, 2013 Author Posted February 18, 2013 Thanks, That worked fine. Does not return anything if there is just the Domain computers group but returns any additional groups. Had tried the _AdIsMemberOf and _AdGetUserGroups Thanks for the time you spent looking at this for me.
water Posted February 18, 2013 Posted February 18, 2013 _AD_GetUserGroups should have worked too. If you pass the computer name as SamAccountName you have to add a dollar sign at the end.$aUser = _AD_GetUserGroups(@ComputerName & "$")This returns a list of groups the computer is an immediate member of.To get a recursive list of group membership use _AD_RecursiveGetMemberOf. 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
amphoric Posted June 1, 2017 Posted June 1, 2017 How would i use $aUser = _AD_GetUserGroups(@ComputerName & "$") But only show the 'CN' within a list box, not the entire string. Thanks
water Posted June 1, 2017 Posted June 1, 2017 (edited) _AD_GetuserGroups always returns the FQDN of the group. But you could use _AD_GetObjectsInOU to query all groups where @ComputerName & "$" is a member and let the function return the Displayname of the group. Example: Edited June 1, 2017 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
amphoric Posted June 1, 2017 Posted June 1, 2017 Thanks Water, Im struggling to get this to work :/... Could you please give me an example of what the code might be? I have the following code to bring back all groups within a certain OU, but unsure how I can specify only for a certain ComputerName and bring back the results from the certain OU. _ad_GetObjectsInOU($sOU , '(&(ObjectsCategory=group) (distinguishedName=*))', 2, "CN") Cheers
water Posted June 1, 2017 Posted June 1, 2017 Example for the current user: #include <AD.au3> _AD_Open() Global $sCN = _AD_SamAccountNameToFQDN(@Username) Global $aResult = _AD_GetObjectsInOU("", "(&(objectClass=group)(member=" & $sCN & "))", 2, "cn") _AD_Close() _ArrayDisplay($aResult) 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
amphoric Posted June 1, 2017 Posted June 1, 2017 Ahh perfect! You hero! I have got it working now thank you very much for your help!!! How would i specify it to only check within a single OU though? Thanks
water Posted June 1, 2017 Posted June 1, 2017 Specify the OU to check as parameter 1. 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
water Posted June 1, 2017 Posted June 1, 2017 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
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