home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / ADSDK.ZIP / Samples / WinNT / Binding / vb / Binding.bas next >
Encoding:
BASIC Source File  |  1999-03-16  |  1.9 KB  |  65 lines

  1. Attribute VB_Name = "Binding"
  2. Sub Main()
  3.  
  4. '----------------------------------------------------------------------------
  5. '
  6. '  Microsoft Active Directory 2.5 Sample Code
  7. '
  8. '  Copyright (C) Microsoft Corporation, 1996 - 1999
  9. '
  10. '  File:       bind.bas
  11. '
  12. '  Contents:   Show how to bind to an ADSI object
  13. '
  14. '----------------------------------------------------------------------------
  15.  
  16. Dim dso As IADsOpenDSObject
  17.  
  18. userName = "Administrator"
  19. password = "waldoishere"
  20.  
  21. '-----------------------------------------------------
  22. '--- BINDING TO A DOMAIN -----------------------------
  23. '------------------------------------------------------
  24. domainName = "INDEPENDENCE"
  25.  
  26. '--- Binding to a domain as currently logged on user
  27. Set dom = GetObject("WinNT://" & domainName)
  28.  
  29.  
  30. '--- Binding to a domain with supplied credential
  31. Set dso = GetObject("WinNT:")
  32. Set dom = dso.OpenDSObject("WinNT://" & domainName, userName, password, 0)
  33.  
  34.  
  35. '-----------------------------------------------------
  36. '--- BINDING TO A REMOTE MACHINE  --------------------
  37. '------------------------------------------------------
  38. computerName = "adsi"
  39.  
  40. '--- Binding to a computer as currently logged on user
  41. Set comp = GetObject("WinNT://" & computerName & ",computer")
  42.  
  43.  
  44. '--- Binding to a computer with supplied credential
  45. Set dso = GetObject("WinNT:")
  46. Set comp = dso.OpenDSObject("WinNT://" & computerName & ",computer", userName, password, 0)
  47.  
  48. '-- and you can find out which domain this computer is joined to
  49. Debug.Print "Domain Name for this computer is " & comp.Parent
  50.  
  51.  
  52.  
  53. '-----------------------------------------------------
  54. '--- BINDING TO A USER IN A DOMAIN  --------------------
  55. '------------------------------------------------------
  56. ADsPath = "WinNT://" & domainName & "/" & userName
  57. '-- adsPath == WinNT://INDEPENDENCE/Administrator
  58.  
  59. Set dom = GetObject(ADsPath)
  60.  
  61.  
  62.  
  63.  
  64. End Sub
  65.