Valnurat Posted June 21, 2022 Posted June 21, 2022 Hello. The below code creates a file with all groups an employee is member of as first requested on each line. Not sorted. So the file contains this: DSTSN,Share,Allround,Workday,Festi DSKVK,Allround,Festi How can I sort the same metadata so it looks like this: DSTSN,Share ,Allround ,Workday ,Festi DSKVK, ,Allround , ,Festi #include <AD.au3> Const $sFilePath = StringReplace(@ScriptFullPath,"au3","txt") Global $aGroups, $aUsers, $sOU = "", $sGroups, $hFileOpen = FileOpen($sFilePath, $FO_APPEND) ; Open the file for writing (append to the end of a file) and store the handle to a variable. If $hFileOpen = -1 Then MsgBox($MB_SYSTEMMODAL, "", "An error occurred whilst writing the temporary file.") EndIf ; Open Connection to the Active Directory _AD_Open() If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended) $sOU = InputBox('Get members from groups', 'Please enter OU as Fully Qualified Domain Name (FQDN)', "OU=Users,OU=so,OU=dk,OU=company,DC=ad,DC=company,DC=org") If _AD_ObjectExists($sOU) Then $aUsers = _AD_GetObjectsInOU($sOU) _ArrayDelete($aUsers, 0) For $c = 0 To 10 ;UBound($aUsers)-1 If _AD_ObjectExists($aUsers[$c]) Then $aGroups = _AD_GetUserGroups($aUsers[$c]) _ArrayDelete($aGroups, 0) For $i = 0 to UBound($aGroups)-1 $sGroups &= StringMid($aGroups[$i],4,StringInStr($aGroups[$i],",")-4) & ";" next $sGroups = StringTrimRight($sGroups, 1) FileWrite($hFileOpen, $ausers[$c] & ";" & $sGroups & @CRLF) EndIf $sGroups = "" Next EndIf FileClose($hFileOpen) ; Close Connection to the Active Directory _AD_Close() Yours sincerely Kenneth.
water Posted June 21, 2022 Posted June 21, 2022 Why do you need to sort the groups this way? 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
Valnurat Posted June 22, 2022 Author Posted June 22, 2022 23 hours ago, water said: Why do you need to sort the groups this way? Good question so I talked to the person who wanted this and we found another solution. So just discard this issue. Yours sincerely Kenneth.
water Posted June 22, 2022 Posted June 22, 2022 If you want to compare membership in AD groups (=permissions) for multiple persons, departments etc. you could have a look at my ADAudit tool: 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