Trust Relationship: Sample Case IV

Scenario
Given two domains - Domain1 and Domain2, you want to create a trust relationship between Domain1 and Domain2, that is, you want to add Domain2 as a trusted domain of Domain1.

Assumptions
Domain1
is either the domain where the sample script will run or is a trusted domain of the current domain.

Procedure
Use the AddTrustedDomain method of IDomainTrustManagement interface to add Domain2 as the trusted domain on Domain1.

Script

Dim Trust As IDomainTrustManagement
Dim Password As String
'Get the interface.
Set Trust = GetObject ("NTDS://Domain1")
Password = InputBox ("Enter the password used while adding trusted domain", "")
'Add domain2 as trusted domain of Domain1
Trust.AddTrustedDomain "Domain2", Password

 

 

See Also