tbaror Posted April 28, 2008 Share Posted April 28, 2008 Hi, I am looking for a script to display get list of all pc's in active drictory/domain using either ADSI NT or LDAP thanks Link to comment Share on other sites More sharing options...
herewasplato Posted April 28, 2008 Share Posted April 28, 2008 Have you read thru http://www.autoitscript.com/forum/index.ph...showtopic=37378Or use the forum advanced search and look for +active +directorySearch titles only and there are a few more threads in the Examples forum. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
spudw2k Posted April 28, 2008 Share Posted April 28, 2008 (edited) This should look up the Default DSE and populate a listview with hosts. Any checked hosts are returned in an array. expandcollapse popup#include <Array.au3> #Include <GuiTreeView.au3> BrowseHosts(True) Func BrowseHosts($debug = False) $domain = GetRootDSE() If $domain = "Failed" Then msgbox(0,"No Domain to Query","Not a member of a domain.") Return EndIf $arrComputers = GetComputers($domain) $arrSelectedHosts = DispComputers($arrComputers) If $debug <> False Then _ArrayDisplay($arrSelectedHosts) Return $arrSelectedHosts EndFunc Func DispComputers($arrComputers) Dim $tTreeArr[1] $tGui = GUICreate("Browse for Hosts",250,326,-1,-1,"","") $tTree = GUICtrlCreateTreeView(5,5,235,258,BitOr(256,55)) $tSelectAll = GUICtrlCreateButton("Select All",85,270,75,20) $tDeSelectAll = GUICtrlCreateButton("Deselect All",165,270,75,20) $tOKBtn = GUICtrlCreateButton("OK",5,270,75,20) GUICtrlSetState(-1,$GUI_FOCUS) For $i = 0 to UBound($arrComputers) - 1 $tTreeArr[$i] = GUICtrlCreateTreeViewItem($arrComputers[$i],$tTree) ReDim $tTreeArr[$i + 2] Next $tVarTreeCount = _GUICtrlTreeView_GetCount(GUICtrlGetHandle($tTree)) GUISetState(@SW_SHOW,$tGui) While 1 $msg = GUIGetMsg() If $msg = $tSelectAll Then For $i = 0 to $tVarTreeCount - 1 GUICtrlSetState($tTreeArr[$i],$GUI_CHECKED) Next EndIf If $msg = $tDeSelectAll Then For $i = 0 to $tVarTreeCount - 1 GUICtrlSetState($tTreeArr[$i],$GUI_UNCHECKED) Next EndIf If $msg = $tOKBtn Then Local $tStrSelectedHosts For $i = 0 to $tVarTreeCount - 1 If BitAnd(GUICtrlRead($tTreeArr[$i]),$GUI_CHECKED) Then $tStrSelectedHosts = $tStrSelectedHosts & GUICtrlRead($tTreeArr[$i],1) & "," EndIf Next GUIDelete($tGui) $tArrSelectedHosts = StringSplit($tStrSelectedHosts,",") _ArrayDelete($tArrSelectedHosts,0) _ArrayDelete($tArrSelectedHosts,UBound($tArrSelectedHosts)-1) Return $tArrSelectedHosts EndIf WEnd EndFunc Func GetComputers($domainname) $objComputers = ObjGet("LDAP://CN=Computers," & $domainname) local $strComputers For $obj In $objComputers $strComputers = $strComputers & $obj.Name & "," Next $obj = "" $objComputers = "" $strComputers = StringLeft($strComputers,StringLen($strComputers)-1) $strComputers = StringReplace($strComputers,"CN=","") $arrComputers = StringSplit($strComputers,",") _ArrayDelete($arrComputers,0) _ArraySort($arrComputers) Return $arrComputers EndFunc Func GetRootDSE() $RootDSE = ObjGet("LDAP://RootDSE") If IsObj($RootDSE) Then Return $RootDSE.get( "DefaultNamingContext" ) Else Return "Failed" EndIf EndFunc Edited April 28, 2008 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
schilbiz Posted April 28, 2008 Share Posted April 28, 2008 (edited) I usually do a search for ADFunctions for AD stuff.http://www.autoitscript.com/forum/index.ph...=%2BAdfunctionsSpecifically look at John's ADFunctions.http://www.autoitscript.com/forum/index.ph...;hl=AdfunctionsEdit: Spelling Edited April 28, 2008 by schilbiz Link to comment Share on other sites More sharing options...
cherdeg Posted June 12, 2008 Share Posted June 12, 2008 This should look up the Default DSE and populate a listview with hosts. Any checked hosts are returned in an array.Hi, if anyone is interested in using spudw2k's very useful (at least for me, ADfunctions.au3 seems to be quite crappy) script, please be informed that in the code above an include for "GUIConstantsEx.au3" is missing. Please add the line: #include <GUIConstantsEx.au3> ...to the top of the code. Regards, Chris 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