Jump to content
Sign in to follow this  
jnkbcs

Creating Search in AD with following qualifiers

Recommended Posts

jnkbcs

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. :x.

Share this post


Link to post
Share on other sites
water

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. :x.

The example script for _AD_GetObjectsInOU has lots of examples. Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jnkbcs

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

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
jnkbcs

Sounds good. Thanks water

Share this post


Link to post
Share on other sites
jnkbcs

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

Remove "@year & ". I mean:

$aExpired = _AD_GetAccountsExpired("user", "2010/12/01", "2011/01/31")
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×