HaeMHuK Posted May 16, 2011 Share Posted May 16, 2011 (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 May 16, 2011 by HaeMHuK Link to comment Share on other sites More sharing options...
Juvigy Posted May 16, 2011 Share Posted May 16, 2011 Try the AD UDF: Link to comment Share on other sites More sharing options...
water Posted May 16, 2011 Share Posted May 16, 2011 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
HaeMHuK Posted May 16, 2011 Author Share Posted May 16, 2011 Thanks water. AD_GetObjectsInOU works for me. expandcollapse popup#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() Link to comment Share on other sites More sharing options...
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