jnkbcs 0 Posted December 13, 2010 Morning all- I am trying to write a script using the AD UDF and was looking for some direction: The script i am trying to write needs to query the ldap servery and return the following items in the following format and export them to a test file so i can import it into an excel file: Qualifiers: User Name Pre win2000 login name Expiration Date - able to select a date range First Name Last Name Logon Name Manager name - needs to be the first and last and not the cn=XXX, I will write up the gui and post is here in a bit but any help with the syntax would be greatly appreciated. I would like to start another thread that has links for searching in AD. . Share this post Link to post Share on other sites
water 2,387 Posted December 13, 2010 (edited) To get all users with the above data I would use: $aResult = _AD_GetObjectsInOU("", "(objectcategory=user)", 2, "displayname,samaccountname,accountexpires,givenname,sn,samaccountname,managedby") accountexpires is an encoded property so you have to decode it. The method to use depends on the number of records to be returned. Some are faster, some are slower. Do you need to select users by any criteria? I would like to start another thread that has links for searching in AD. .The example script for _AD_GetObjectsInOU has lots of examples. Edited December 13, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
jnkbcs 0 Posted December 14, 2010 The search qualifier would be the date range for the expired accounts. we run a report near the end of year to see what accounts expire and then get an email to their managers Share this post Link to post Share on other sites
water 2,387 Posted December 14, 2010 Please have a look at the example script _AD_GetAccountsExpired.au3. Example 2 and 3 might just be want you want. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
jnkbcs 0 Posted December 14, 2010 Sounds good. Thanks water Share this post Link to post Share on other sites
jnkbcs 0 Posted December 14, 2010 ok i read it and i think ive got it. one question, i added the year from this year to next and it doesnt like it. do i need to flip them? #AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y #include ; Open Connection to the Active Directory _AD_Open() Global $aExpired[1] ; ***************************************************************************** ; Example 3 ; Get a list of user accounts that expire between january and october this year ; ***************************************************************************** ;$aExpired = _AD_GetAccountsExpired("user", @YEAR & "/10/31", @YEAR & "/01/01") $aExpired = _AD_GetAccountsExpired("user", @YEAR & "2010/12/01", @YEAR & "2011/01/31") If @error = 0 Then _ArrayDisplay($aExpired, "Active Directory Functions - Example 3 - Expired User Accounts (january to october this year)") ElseIf @error = 1 Then MsgBox(64, "Active Directory Functions - Example 3", "No expired user accounts could be found") Else MsgBox(64, "Active Directory Functions - Example 3", "Invalid parameters provided") EndIf Share this post Link to post Share on other sites
water 2,387 Posted December 14, 2010 (edited) Remove "@year & ". I mean: $aExpired = _AD_GetAccountsExpired("user", "2010/12/01", "2011/01/31") Edited December 15, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites