Jump to content

Recommended Posts

Posted (edited)

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
Posted

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 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

 

Posted

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()

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
×
×
  • Create New...