JamesDover Posted August 2, 2011 Posted August 2, 2011 I found the adfunctions.au3 but was unable to find information on how to pull certin things from active directory. Could someone link or help me find some more information on this? Cheers
water Posted August 2, 2011 Posted August 2, 2011 You could use my Active Directory UDF (ad.au3) which is the successor of adfunctions.au3 (for download please see my signature). Which function to use depends on what you want to do. A good place to start is function _AD_GetObjectsInOU. Please have a look at the example script file _AD_GetObjectsInOU.au3. The phone number is just a property of an user object. Do you want just a single user or a (filtered) list of users? 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
JamesDover Posted August 5, 2011 Author Posted August 5, 2011 (edited) Excellent just what I was looking for.DankeYou could use my Active Directory UDF (ad.au3) which is the successor of adfunctions.au3 (for download please see my signature).Which function to use depends on what you want to do.A good place to start is function _AD_GetObjectsInOU. Please have a look at the example script file _AD_GetObjectsInOU.au3.The phone number is just a property of an user object. Do you want just a single user or a (filtered) list of users? Edited August 5, 2011 by JamesDover
water Posted August 5, 2011 Posted August 5, 2011 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
JamesDover Posted August 8, 2011 Author Posted August 8, 2011 (edited) One more quick question with the _AD_GetObjectsInOU if i decide to make the output ($output to display on a form) instead of _ArrayDisplay would this be possible? Also I can't seem to get the lastLogon (date) to show up in the array i must be doing something wrong. #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y #include <AD.au3> _AD_Open() Global $sOU = "OU=LUsers,OU=Users,OU=test,DC=test1,DC=edu" ; Global $aObjects[1][1] $aObjects = _AD_GetObjectsInOU($sOU, "(sAMAccountName=Sam.Turner)", 2, "Telephone number,lastLogon") If @error > 0 Then MsgBox(64, "Active Directory Functions", "No OUs could be found") Else _ArrayDisplay($aObjects, "Missing E-Mail and Phone Numbers '" & $sOU & "'") EndIf _AD_Close() Cheers Edited August 8, 2011 by JamesDover
water Posted August 8, 2011 Posted August 8, 2011 (edited) One more quick question with the _AD_GetObjectsInOU if i decide to make the output ($output to display on a form) instead of _ArrayDisplay would this be possible?How you display the data returned by a functions is up to you. _AD_GetObjectsInOU simply returns an array.Also I can't seem to get the lastLogon (date) to show up in the array i must be doing something wrong.Active Directory stores different types of data (strings, arrays, data that needs some sort of "interpretation", data that needs to be accessed in a special way).Function _AD_GetObjectsInOU returns the data "as is" - so it's only useful for string and array type of data.To get "interpreted" data you could use _AD_GetObjectProperties. This function translates all kind of data into readable form.To get the LastLogon data you need to use function _AD_GetLastLoginDate. The data is stored on the domain controller where the user logged on and isn't replicated to other domain controllers. This is why function _AD_GetLastLoginDate queries all DC to return the correct data._AD_GetObjectsInOU is best to be used when a lot of recordes will be returned e.g. give me all users with department = xy_AD_GetObjectProperties is best to be used when you need to query all/some properties of a single object (user, computer, group) and need the data in readable form. Edited August 8, 2011 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
JamesDover Posted August 8, 2011 Author Posted August 8, 2011 Ad.au3 has a lot of good uses I wish I found it long ago. Hopefully they will add it to the auto-it include folder in future releases. Your information is very helpful as always.CheersHow you display the data returned by a functions is up to you. _AD_GetObjectsInOU simply returns an array.Active Directory stores different types of data (strings, arrays, data that needs some sort of "interpretation", data that needs to be accessed in a special way).Function _AD_GetObjectsInOU returns the data "as is" - so it's only useful for string and array type of data.To get "interpreted" data you could use _AD_GetObjectProperties. This function translates all kind of data into readable form.To get the LastLogon data you need to use function _AD_GetLastLoginDate. The data is stored on the domain controller where the user logged on and isn't replicated to other domain controllers. This is why function _AD_GetLastLoginDate queries all DC to return the correct data._AD_GetObjectsInOU is best to be used when a lot of recordes will be returned e.g. give me all users with department = xy_AD_GetObjectProperties is best to be used when you need to query all/some properties of a single object (user, computer, group) and need the data in readable form.
water Posted August 9, 2011 Posted August 9, 2011 Glad you like the UDF. If you want to show other users how useful the UDF is you can go to the download page and click on one of the stars at "Rate topic:" 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
JamesDover Posted August 9, 2011 Author Posted August 9, 2011 I guess it would work like this after creating a forum? Thanks #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y #include <AD.au3> ; Open Connection to the Active Directory _AD_Open() Global $aProperties[1][2];<----------- How do these numbers work? $aProperties = _AD_GetObjectProperties("John.Jones", "Telephone number") ;_ArrayDisplay($aProperties, "Telephone Number") GUICtrlSetData($PhoneNumberInput, $aProperties);<--------------------------- Is this possible? _AD_Close()
hannes08 Posted August 9, 2011 Posted August 9, 2011 Global $aProperties[1][2];<----------- How do these numbers work? This declares a new array with 2 dimensions. First dimension has 1 Element and second dimension 2 elements. Effectively you can use $aProperties[0][0] and $aProperties[0][1] GUICtrlSetData($PhoneNumberInput, $aProperties);<--------------------------- Is this possible? No, see description above. Try: GUICtrlSetData($PhoneNumberInput, $aProperties[0][1]) $aProperties[0][1] is just a guess. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
water Posted August 9, 2011 Posted August 9, 2011 Do you need something like this #include <ad.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $sUserName #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 332, 146, 192, 124) GUICtrlCreateLabel("Please enter User Name:", 16, 18, 122, 17) GUICtrlCreateLabel("Telephone number:", 16, 52, 96, 17) $IUserName = GUICtrlCreateInput("", 153, 16, 159, 21) $IPhoneNumber = GUICtrlCreateInput("", 152, 50, 159, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) $BtnExit = GUICtrlCreateButton("Exit", 248, 96, 65, 33, $WS_GROUP) $BtnGo = GUICtrlCreateButton("Go", 16, 96, 65, 33, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _AD_Open() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $BtnExit _AD_Close() Exit Case $BtnGo $sUser = GUICtrlRead($IUserName) If $sUser <> "" Then $sPhoneNumber = _AD_GetObjectAttribute($sUser, "telephonenumber") GUICtrlSetData($IPhoneNumber, $sPhoneNumber) Endif EndSwitch WEnd 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
JamesDover Posted August 10, 2011 Author Posted August 10, 2011 (edited) Cheers, I was stuck on the purpose of the numbers. Water, yes that is what i was looking for This declares a new array with 2 dimensions. First dimension has 1 Element and second dimension 2 elements. Effectively you can use $aProperties[0][0] and $aProperties[0][1] No, see description above. Try: GUICtrlSetData($PhoneNumberInput, $aProperties[0][1]) $aProperties[0][1] is just a guess. Edited August 10, 2011 by JamesDover
JamesDover Posted October 3, 2011 Author Posted October 3, 2011 I am using _AD_GetObjectsInOU to retrive the name,operatingsystem and service pack. The problem is the server is windows 2000. Has any one had any luck with windows 2000 I can't seem to make it work. It could be my $sOU is wrong. Cheers #include <AD.au3> _AD_Open() Global $sOU = "OU=Computers,DC=MyZone,DC=local" Global $aObjects[1][1] $aObjects = _AD_GetObjectsInOU($sOU, "(name=*)", 2, "sAMAccountName,operatingSystem,operatingSystemServicePack") ;Workstations If @error > 0 Then MsgBox(64, "Active Directory", "No OUs could be found") Else _ArrayDisplay($aObjects, "Os And ServicePak" & $sOU & "'") EndIf _AD_Close()
water Posted October 3, 2011 Posted October 3, 2011 (edited) Could you please try this modified code? This LDAP query only returns computer objects. #include <AD.au3> _AD_Open() Global $sOU = "OU=Computers,DC=MyZone,DC=local" Global $aObjects[1][1] $aObjects = _AD_GetObjectsInOU($sOU, "(objectClass=computer)", 2, "sAMAccountName,operatingSystem,operatingSystemServicePack") ;Workstations If @error > 0 Then MsgBox(64, "Active Directory", "No OUs could be found") Else _ArrayDisplay($aObjects, "Os And ServicePak" & $sOU & "'") EndIf _AD_Close() Edited October 4, 2011 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
water Posted October 4, 2011 Posted October 4, 2011 The image can not be displayed. Can you post the error as text? 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