jnkbcs Posted December 13, 2010 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. .
water Posted December 13, 2010 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 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
jnkbcs Posted December 14, 2010 Author 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
water Posted December 14, 2010 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 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
jnkbcs Posted December 14, 2010 Author 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
water Posted December 14, 2010 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 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