Valnurat Posted August 19, 2016 Posted August 19, 2016 Hi. Can someone help me with some code to get info from AD and into a ComboBox. I'm using this UDF: How do you get AD user object with the StaffManager attributes = True? I think I have to use: _AD_GetObjectsInOU($sOU[, $sFilter = "(name=*)"[, $iSearchScope = 2[, $sDataToRetrieve = "sAMAccountName"[, $sSortBy = "sAMAccountName"[, $bCount = False[, $vReturnNull = True]]]]]) but I don't know how. Yours sincerely Kenneth.
water Posted August 19, 2016 Posted August 19, 2016 Something like (untested): $aObjects = _AD_GetObjectsInOU("", "(&(objectcategory=person)(objectclass=user)(StaffManager=True))", 2, "sAMAccountName,distinguishedName,displayname", "displayname") 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 August 19, 2016 Author Posted August 19, 2016 (edited) #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <AD.au3> #include <Array.au3> Main() Func Main() _AD_Open() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") GUICtrlCreateCombo("Sample Combo", 250, 80, 120, 100) $aObject = _AD_GetObjectsInOU("","(&(objectclass=person)(StaffManager=True))",2,"sAMAccountName,distinguishedName,displayname", "displayname") _ArrayDisplay($aObject,"") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idOK MsgBox($MB_SYSTEMMODAL, "", "test") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) _AD_Close() EndFunc I tried this, but I don't get anything in the _arrayDisplay. SOLVED: I need to use big letters in the "True". Like this "TRUE" Edited August 19, 2016 by Valnurat SOLVED Yours sincerely Kenneth.
water Posted August 19, 2016 Posted August 19, 2016 What's the value of @error and @extended after _AD_GetObjectsInOU? 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 August 19, 2016 Author Posted August 19, 2016 I fixed it. I just needed to use "TRUE" instead. But how do I add the result into my ComboBox? Yours sincerely Kenneth.
water Posted August 19, 2016 Posted August 19, 2016 Use GUICtrlSetData as seen in the example for GUICtrlCreateCombo. 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 August 22, 2016 Author Posted August 22, 2016 I've looked at GUICtrlSetData and I understand that input should be with the pipe character (|) as separator. In the _AD_GetObjectsInOU remarks it says "Multi-value attributes are returned as a string with the pipe character (|) as separator". So why does GUICtrlSetData not work? #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=x86\Create Consultant.Exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <AD.au3> #include <Array.au3> Main() Func Main() _AD_Open() ; Create a GUI with various controls. Local $hGUI = GUICreate("Example") Local $idComboBox = GUICtrlCreateCombo("Sample Combo", 250, 80, 120, 100) local $aObject = _AD_GetObjectsInOU("OU=Users,OU=so,OU=dk,OU=company,DC=AD,DC=company,DC=ORG","(&(objectclass=person)(StaffManager=TRUE))",2,"sAMAccountName,distinguishedName,displayname", "displayname") ; Add additional items to the combobox. GUICtrlSetData($idComboBox, $aObject, "") Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idOK MsgBox($MB_SYSTEMMODAL, "", "test") EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) _AD_Close() EndFunc Is the _AD_GetObjectsInOU not separated with a pipe in this case? Yours sincerely Kenneth.
water Posted August 29, 2016 Posted August 29, 2016 It depends: When a single attribute contains multiple values then you get a single entry in the array where the values are separated by the pipe character When there are multiple attributes you get multiple entries in the returned array with the same attribute name 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