Listing08_List_Trusts (VBScript)

This code can be found in Chapter 7 of Managing Enterprise Active Directory Services

Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.

Find out how to download all of the VBScript code from this site.

'# From the book "Managing Enterprise Active Directory Services"
'# ISBN: 0-672-32125-4

Dim user, passwd, server, system_cont, ldapObj, trustsObj, trustObj
Dim count, trustTypes, trustDirections

server = "dc1"
user   = "administrator@xyz.com"
passwd = "password"
system_cont = "cn=system,dc=xyz,dc=com"

trustTypes = Array("Unknown","Downlevel","Uplevel","Kerberos","DCE")
trustDirections = Array("Disabled","Trusting","Trusted","Trusting and Trusted")

Set ldapObj = GetObject("LDAP:")
Set trustsObj = ldapObj.OpenDsObject("LDAP://" & server & "/" & system_cont, _
                                       user, passwd, 1)
trustsObj.Filter = Array("trustedDomain")

Wscript.Echo "Trusts for " & server & ":"
count = 0
On Error Resume Next
For Each trustObj in trustsObj
   count = count + 1
   Wscript.Echo count & ". " & trustObj.trustPartner _
                      & " - " & trustTypes(trustObj.trusttype) _
                      & " " & trustDirections(trustObj.trustdirection)
Next

This code has been viewed 817 times.

New from the creators of TechTasks.com: StatSheet.com