home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / Interopt / NDS / NDS.bas next >
Encoding:
BASIC Source File  |  1999-03-09  |  1.4 KB  |  61 lines

  1. Attribute VB_Name = "NDS"
  2. Sub Main()
  3. Dim dso
  4. Dim obj
  5. Dim usrName
  6. Dim password
  7. Dim serverName
  8.  
  9. serverName = "ntmarst2"
  10. userName = "supervisor.ntmarst2"
  11. password = "secretpwd"
  12.  
  13. '-- Connecting
  14. Set dso = GetObject("NDS:")
  15. Set cont = dso.OpenDSObject("NDS://" & serverName, userName, password, 0)
  16. '--- Enumeration
  17. For Each obj In cont
  18.   Debug.Print obj.Name & " (" & obj.Class & ")"
  19. Next
  20.  
  21. '--- Attribute Retrieval and Modification
  22. Path = "O=NTMARST2/CN=benny"
  23. ADsPath = "NDS://" & serverName & "/" & Path
  24. Set usr = dso.OpenDSObject(ADsPath, userName, password, 0)
  25. Debug.Print usr.Get("Surname")
  26. usr.Put "SurName", "Johnson"
  27. usr.SetInfo
  28.  
  29. '--- Object Creation
  30. Path = "O=NTMARST2"
  31. ADsPath = "NDS://" & serverName & "/" & Path
  32. Set cont = dso.OpenDSObject(ADsPath, userName, password, 0)
  33. Set usr = cont.Create("user", "alicew")
  34. usr.Put "cn", "alice"
  35. usr.Put "Surname", "Wonderland"
  36. usr.SetInfo
  37.  
  38. '---Searching-----
  39. ADsPath = "NDS://" & serverName
  40. Set con = CreateObject("ADODB.Connection")
  41. con.Provider = "ADsDSOObject"
  42. con.Properties("User ID") = userName
  43. con.Properties("Password") = password
  44. con.Open "ADSI"
  45.  
  46.  
  47. Set com = CreateObject("ADODB.Command")
  48. Set com.ActiveConnection = con
  49. com.CommandText = "SELECT ADsPath, 'Object Class' FROM '" & ADsPath & "' WHERE Surname='Wonderland'"
  50. Set rs = com.Execute
  51.  
  52.  
  53. While Not (rs.EOF)
  54.   Debug.Print rs.Fields("ADsPath")
  55.   rs.MoveNext
  56. Wend
  57.  
  58.  
  59.  
  60. End Sub
  61.