Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

  1. '
  2. ' Copyright (c) 1997-1999 Microsoft Corporation
  3. '
  4. '
  5. ' This Script list the users in this domain
  6. '
  7. '
  8. ' This is a general routine to enumerate instances of a given class
  9. ' In this script, it is called for the class "ds_user"
  10. '
  11. Sub EnumerateInstances ( objService , objClass )
  12. On Error Resume Next
  13. Dim objInstance
  14. Dim objEnumerator
  15. Set objEnumerator = objService.InstancesOf ( objClass )
  16. If Err = 0 Then
  17. For Each objInstance In objEnumerator
  18. Dim propertyEnumerator
  19. Set propertyEnumerator = objInstance.Properties_
  20. WScript.Echo propertyEnumerator.Item("DS_sAMAccountName")
  21. Next
  22. Else
  23. WScript.Echo "Err = " + Err.Number
  24. End If
  25. End Sub
  26. ' Start of script
  27. ' Create a locator and connect to the namespace where the DS Provider operates
  28. Dim objLocator
  29. Set objLocator = CreateObject("WbemScripting.SWbemLocator")
  30. Dim objService
  31. Set objService = objLocator.ConnectServer(".", "root\directory\LDAP")
  32. ' Set the impersonation level
  33. objService.Security_.ImpersonationLevel = 3
  34. ' Enumerate the instances of the class "ds_user"
  35. EnumerateInstances objService , "ds_user"