' Find75Users4.vbs ' VBScript program retrieve the Distinguished Names of 75 objects ' in Active Directory from the sAMAccountName values. ' ' ---------------------------------------------------------------------- ' Copyright (c) 2011 Richard L. Mueller ' Hilltop Lab web site - http://www.rlmueller.net ' Version 1.0 - January 17, 2011 ' ' This program uses the NameTranslate object to query Active Directory ' for 75 objects with given values of the sAMAccountName attribute. This ' program makes one query of Active Directory for all 75 values at once. ' The program tracks how long this process takes. The program repeats ' the 75 queries 10 times at random intervals between 10 and 15 minutes ' apart. ' ' You have a royalty-free right to use, modify, reproduce, and ' distribute this script file in any way you find useful, provided that ' you agree that the copyright owner above has no warranty, obligations, ' or liability for such use. Option Explicit Dim intPause, j Sub QueryAD(ByVal intCount) Dim objTrans, strNetBIOSDomain Dim objRootDSE, strDNSDomain, arrDNs, k Dim arrNames(74), lngStart, lngEnd, lngSetup ' Constants for the NameTranslate object. Const ADS_NAME_INITTYPE_GC = 3 Const ADS_NAME_TYPE_NT4 = 3 Const ADS_NAME_TYPE_1779 = 1 lngSetup = Timer() ' Determine DNS name of domain from RootDSE. Set objRootDSE = GetObject("LDAP://RootDSE") strDNSDomain = objRootDSE.Get("defaultNamingContext") ' Use the NameTranslate object to find the NetBIOS domain name ' from the DNS domain name. Set objTrans = CreateObject("NameTranslate") objTrans.Init ADS_NAME_INITTYPE_GC, "" objTrans.Set ADS_NAME_TYPE_1779, strDNSDomain strNetBIOSDomain = objTrans.Get(ADS_NAME_TYPE_NT4) ' Remove trailing backslash. strNetBIOSDomain = Left(strNetBIOSDomain, Len(strNetBIOSDomain) - 1) ' Specify an array of NT names to be translated. arrNames(0) = strNetBIOSDomain & "\r_mueller" arrNames(1) = strNetBIOSDomain & "\oregon$" arrNames(2) = strNetBIOSDomain & "\klmueller" arrNames(3) = strNetBIOSDomain & "\SBecker" arrNames(4) = strNetBIOSDomain & "\SRBecker" arrNames(5) = strNetBIOSDomain & "\RKWilliard" arrNames(6) = strNetBIOSDomain & "\FMadison" arrNames(7) = strNetBIOSDomain & "\TJefferson" arrNames(8) = strNetBIOSDomain & "\BFranklin" arrNames(9) = strNetBIOSDomain & "\JSmith" arrNames(10) = strNetBIOSDomain & "\JAdams" arrNames(11) = strNetBIOSDomain & "\PocketLunch" arrNames(12) = strNetBIOSDomain & "\School" arrNames(13) = strNetBIOSDomain & "\minnesota$" arrNames(14) = strNetBIOSDomain & "\JMonroe" arrNames(15) = strNetBIOSDomain & "\PLUser1" arrNames(16) = strNetBIOSDomain & "\PLUser2" arrNames(17) = strNetBIOSDomain & "\guest" arrNames(18) = strNetBIOSDomain & "\rlmueller" arrNames(19) = strNetBIOSDomain & "\FKaplan" arrNames(20) = strNetBIOSDomain & "\AReed" arrNames(21) = strNetBIOSDomain & "\fwilliamson" arrNames(22) = strNetBIOSDomain & "\JJSmith" arrNames(23) = strNetBIOSDomain & "\First_Last" arrNames(24) = strNetBIOSDomain & "\LFirst" arrNames(25) = strNetBIOSDomain & "\W.Smith" arrNames(26) = strNetBIOSDomain & "\Very Long Name 67890" arrNames(27) = strNetBIOSDomain & "\User 5" arrNames(28) = strNetBIOSDomain & "\VeryLongUserName4321" arrNames(29) = strNetBIOSDomain & "\RSmith" arrNames(30) = strNetBIOSDomain & "\WJohnson" arrNames(31) = strNetBIOSDomain & "\B#Test" arrNames(32) = strNetBIOSDomain & "\C_Test" arrNames(33) = strNetBIOSDomain & "\JPolk" arrNames(34) = strNetBIOSDomain & "\FirstMLast" arrNames(35) = strNetBIOSDomain & "\SallyCrawford" arrNames(36) = strNetBIOSDomain & "\JohnAdams" arrNames(37) = strNetBIOSDomain & "\AlGorney" arrNames(38) = strNetBIOSDomain & "\EZastera3" arrNames(39) = strNetBIOSDomain & "\EZastera2" arrNames(40) = strNetBIOSDomain & "\EZastera1" arrNames(41) = strNetBIOSDomain & "\EKent" arrNames(42) = strNetBIOSDomain & "\JKirk" arrNames(43) = strNetBIOSDomain & "\michelegeiger" arrNames(44) = strNetBIOSDomain & "\wrugby" arrNames(45) = strNetBIOSDomain & "\rrogers" arrNames(46) = strNetBIOSDomain & "\FJackson" arrNames(47) = strNetBIOSDomain & "\JackJones" arrNames(48) = strNetBIOSDomain & "\jmpolk" arrNames(49) = strNetBIOSDomain & "\PLTest" arrNames(50) = strNetBIOSDomain & "\JamesW" arrNames(51) = strNetBIOSDomain & "\A_Test" arrNames(52) = strNetBIOSDomain & "\Administrator" arrNames(53) = strNetBIOSDomain & "\Win2kXP" arrNames(54) = strNetBIOSDomain & "\TemplateUser" arrNames(55) = strNetBIOSDomain & "\F(M)Last" arrNames(56) = strNetBIOSDomain & "\GWashington" arrNames(57) = strNetBIOSDomain & "\VeryLongNameForTesti" arrNames(58) = strNetBIOSDomain & "\vcmgt0j6" arrNames(59) = strNetBIOSDomain & "\mo'brian" arrNames(60) = strNetBIOSDomain & "\PocketLunchSvc$Acct" arrNames(61) = strNetBIOSDomain & "\FMalloy" arrNames(62) = strNetBIOSDomain & "\fjones" arrNames(63) = strNetBIOSDomain & "\PL-User3" arrNames(64) = strNetBIOSDomain & "\Test22" arrNames(65) = strNetBIOSDomain & "\J Smith" arrNames(66) = strNetBIOSDomain & "\krbtgt" arrNames(67) = strNetBIOSDomain & "\`~^!@$%&-_" arrNames(68) = strNetBIOSDomain & "\Burke William" arrNames(69) = strNetBIOSDomain & "\Wisconsin$" arrNames(70) = strNetBIOSDomain & "\Washington$" arrNames(71) = strNetBIOSDomain & "\Wyoming$" arrNames(72) = strNetBIOSDomain & "\Nebraska$" arrNames(73) = strNetBIOSDomain & "\TsInternetUser" arrNames(74) = strNetBIOSDomain & "\IUSR_WISCONSIN" lngStart = Timer() ' Use the SetEx method to specify the NT format of the object names. objTrans.SetEx ADS_NAME_TYPE_NT4, arrNames ' Use the GetEx method to retrieve the RPC 1779 Distinguished Names. arrDNs = objTrans.GetEx(ADS_NAME_TYPE_1779) For k = 0 To 74 ' Wscript.Echo arrNames(k) & " : " & arrDNs(k) Next lngEnd = Timer() Wscript.Echo "-- " & CStr(intCount) & " --" Wscript.Echo FormatNumber((lngStart - lngSetup), 7) Wscript.Echo FormatNumber((lngEnd - lngStart), 7) Wscript.Echo FormatNumber((lngEnd - lngSetup), 7) End Sub Randomize() For j = 1 To 9 Call QueryAD(j) intPause = 1000 * CInt(300 + (600 * Rnd())) Wscript.Sleep intPause Next Call QueryAD(j)