Jump to content
Sign in to follow this  
HaeMHuK

Search in AD like in Outlook

Recommended Posts

HaeMHuK

Please, help me to create script which will search users in AD. It should be similar with user search in Outlook.

The user have to be found by name or surname or part of it.

Examples:

If I type John it will shows all the users with accounts that consist of word John.

If the user is chosen there are a Msgbox with it's information (dn,telephoneNumber).

Is it possible?

Edited by HaeMHuK

Share this post


Link to post
Share on other sites
Juvigy

Try the AD UDF:

Share this post


Link to post
Share on other sites
water

Please have a look at function _AD_GetObjectsInOU. If you would like to scan multiple name fiels please check for ANR (Ambigous Name Resolution) in the _AD_GetObjectsInOU.au3 example script.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
HaeMHuK

Thanks water. AD_GetObjectsInOU works for me.

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
; *****************************************************************************
; Example 1
; Deletes an AD object.
; *****************************************************************************
#include <AD.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

; Open Connection to the Active Directory
_AD_Open()


#region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Search AD", 180, 50)
GUICtrlCreateLabel("Search:", 8, 10, 50, 17)
Global $IObject = GUICtrlCreateInput("", 60, 8, 100, 21)
$Dum = GUICtrlCreateDummy()
Dim $accels[1][2] = [["{ENTER}", $Dum]]
GUISetAccelerators($accels)

GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
    Global $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
             Case $Dum
            Global $sObject = GUICtrlRead($IObject)

   
            If ControlGetFocus($Form1) Then 
            

$aObjects = _AD_GetObjectsInOU("", "(ANR=" & $sObject & ")", 2, "displayname,sAMAccountName,telephoneNumber,mobile,title,extensionAttribute11,employeeID,extensionAttribute15,employeeNumber,extensionAttribute1,extensionAttribute3", "displayname")
If @error > 0 Then
    MsgBox(64, "Active Directory search results", "No objects found")
Else
    _ArrayDisplay($aObjects, "Active Directory search results - '" & $sObject & "'", 0, 0, "", "|", "0|Display name|Account name|Telephone|Mobile|Title|Location|ID|Band|Grade|ICQ|Skype")
EndIf

; Close Connection to the Active Directory
EndIf
EndSwitch
WEnd

_AD_Close()

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.