Source code of Windows XP (NT5)
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.

85 lines
2.4 KiB

  1. VERSION 5.00
  2. Begin VB.Form Form1
  3. Caption = "Form1"
  4. ClientHeight = 3192
  5. ClientLeft = 60
  6. ClientTop = 348
  7. ClientWidth = 4680
  8. LinkTopic = "Form1"
  9. ScaleHeight = 3192
  10. ScaleWidth = 4680
  11. StartUpPosition = 3 'Windows Default
  12. End
  13. Attribute VB_Name = "Form1"
  14. Attribute VB_GlobalNameSpace = False
  15. Attribute VB_Creatable = False
  16. Attribute VB_PredeclaredId = True
  17. Attribute VB_Exposed = False
  18. Private Sub Form_Load()
  19. Dim con As New Connection, rs As New Recordset
  20. Dim v
  21. Dim Com As New Command
  22. On Error GoTo bailout
  23. 'Open a Connection object
  24. con.Provider = "ADsDSOObject"
  25. Debug.Print con.Properties.Count
  26. For j = 0 To con.Properties.Count - 1
  27. Debug.Print con.Properties(j).Name
  28. Next j
  29. con.Open "Active Directory Provider"
  30. ' Create a command object on this connection
  31. Set Com.ActiveConnection = con
  32. ' set the query string
  33. Com.CommandText = "select name from 'LDAP://ntdsdc1/dc=COM/DC=MICROSOFT/DC=NTDEV' where objectClass='*'"
  34. 'Com.CommandText = "<LDAP://ntdsdc1/dc=COM/DC=MICROSOFT/DC=NTDEV>;(objectClass=*);name"
  35. For j = 0 To Com.Properties.Count - 1
  36. Debug.Print Com.Properties(j).Name
  37. Next j
  38. ' Set the preferences for Search
  39. 'Com.Properties("Page Size") = 1000
  40. 'Com.Properties("Timeout") = 30 'seconds
  41. Com.Properties("searchscope") = 1
  42. 'Execute the query
  43. Set rs = Com.Execute
  44. For i = 0 To rs.Fields.Count - 1
  45. Debug.Print rs.Fields(i).Name, rs.Fields(i).Type
  46. Next i
  47. rs.MoveLast
  48. Debug.Print "No. of rows = ", rs.RecordCount
  49. ' Navigate the record set
  50. rs.MoveFirst
  51. While Not rs.EOF
  52. For i = 0 To rs.Fields.Count - 1
  53. If rs.Fields(i).Type = adVariant And Not (IsNull(rs.Fields(i).Value)) Then
  54. Debug.Print rs.Fields(i).Name, " = "
  55. For j = LBound(rs.Fields(i).Value) To UBound(rs.Fields(i).Value)
  56. Debug.Print rs.Fields(i).Value(j), " # "
  57. Next j
  58. Else
  59. Debug.Print rs.Fields(i).Name, " = ", rs.Fields(i).Value
  60. End If
  61. Next i
  62. rs.MoveNext
  63. Wend
  64. rs.MoveLast
  65. Debug.Print "No. of rows = ", rs.RecordCount
  66. Exit Sub
  67. bailout: Debug.Print "Error", Hex(Err.Number), " :", Error(Err.Number)
  68. Exit Sub
  69. End Sub