Announcement

Collapse
No announcement yet.

VBS in active directory

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • VBS in active directory

    Hi

    I have found an old VBSript that should ping all the computers under the correct OU
    and i get all the time Error , here is the example

    Set domainObject = GetObject("LDAP://OU=workstations,OU=computers,OU=HQ,DC=xxx,dc=xxx
    ")

    i get this error " line : 2
    char : 1
    Error: A referral was returned from the server
    code 8007202b

    Thanks

  • #2
    Re: VBS in active directory

    please post the complete script.
    Marcel
    Technical Consultant
    Netherlands
    http://www.phetios.com
    http://blog.nessus.nl

    MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
    "No matter how secure, there is always the human factor."

    "Enjoy life today, tomorrow may never come."
    "If you're going through hell, keep going. ~Winston Churchill"

    Comment


    • #3
      Re: VBS in active directory

      'on error resume next
      Set domainObject = GetObject("LDAP://CN=Computers,OU=Is,OU=E,OU=Re,DC=ccc,DC=com")
      Set fs = CreateObject("Scripting.FileSystemObject")
      Set CompFile = fs.CreateTextFile ("1.csv")
      ExportUsers(domainObject)
      Set oDomain = Nothing
      MsgBox "Finished...check the <1.csv> file"
      WScript.Quit


      Sub ExportUsers(oObject)
      on error resume next
      Dim Ocomputer
      For Each Ocomputer in oObject
      Select Case Ocomputer.Class
      Case "computer"
      CompFile.Write Ocomputer.name & ","
      nameLength = len(Ocomputer.name)
      compstr = Ocomputer.name
      computer = mid(compstr,4,nameLength)
      strComputer = computer
      Set objPing = GetObject("winmgmts:{impersonationLevel=impersonat e}")._
      ExecQuery("select * from Win32_PingStatus where address = '"_
      & strComputer & "'")
      For Each objStatus in objPing
      Select Case objStatus.StatusCode
      Case o
      CompFile.Write "Online"
      Case "11010"
      CompFile.Write "Request timed out"
      Case Else
      CompFile.Write "Not Resolved"
      End Select
      Next

      CompFile.WriteLine ""
      Case "organizationalUnit" , "container"
      If CompinOU(Ocomputer) then
      ExportUsers(Ocomputer)
      End if
      End select
      Next
      End Sub

      Function CompinOU(oObject)
      Dim Ocomputer
      CompinOU = False
      for Each Ocomputer in oObject
      Select Case Ocomputer.Class
      Case "organizationalUnit" , "container"
      CompinOU = CompinOU(Ocomputer)
      Case "computer"
      CompinOU = True

      End select
      Next
      End Function

      Comment

      Working...
      X