' Find75Users2.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 75 separate queries of Active Directory. 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, arrNames Sub QueryAD(ByVal intCount, ByVal arrNames) Dim objTrans, strNetBIOSDomain Dim objRootDSE, strDNSDomain, strNTName, strDN Dim 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) lngStart = Timer() For Each strNTName In arrNames ' Use the Set method to specify the NT format of the object name. On Error Resume Next objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strNTName If (Err.Number <> 0) Then On Error GoTo 0 strDN = "Unknown" Else On Error GoTo 0 ' Use the Get method to retrieve the RPC 1779 Distinguished Name. strDN = objTrans.Get(ADS_NAME_TYPE_1779) End If 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 ' Specify an array of NT names to be translated. arrNames = Array("r_mueller", "oregon$", "klmueller", "SBecker", _ "SRBecker", "RKWilliard", "FMadison", "TJefferson", "BFranklin", _ "JSmith", "JAdams", "PocketLunch", "School", "minnesota$", _ "JMonroe", "PLUser1", "PLUser2", "guest", "rlmueller", _ "FKaplan", "AReed", "fwilliamson", "JJSmith", "First_Last", _ "LFirst", "W.Smith", "Very Long Name 67890", "User 5", _ "VeryLongUserName4321", "RSmith", "WJohnson", "B#Test", "C_Test", _ "JPolk", "FirstMLast", "SallyCrawford", "JohnAdams", "AlGorney", _ "EZastera3", "EZastera2", "EZastera1", "EKent", "JKirk", _ "michelegeiger", "wrugby", "rrogers", "FJackson", "JackJones", _ "jmpolk", "PLTest", "JamesW", "A_Test", "Administrator", _ "Win2kXP", "TemplateUser", "F(M)Last", "GWashington", _ "VeryLongNameForTesti", "vcmgt0j6", "mo'brian", "PocketLunchSvc$Acct", _ "FMalloy", "fjones", "PL-User3", "Test22", "J Smith", "krbtgt", _ "`~^!@$%&-_", "Burke William", "Wisconsin$", "Washington$", _ "Wyoming$", "Nebraska$", "TsInternetUser", "IUSR_WISCONSIN") Randomize() For j = 1 To 9 Call QueryAD(j, arrNames) intPause = 1000 * CInt(300 + (600 * Rnd())) Wscript.Sleep intPause Next Call QueryAD(j, arrNames)