TrustedDomainNameCollection

[This documentation is preliminary and is subject to change.]

The TrustedDomainNameCollection object contains a collection of the domain names that comprise a trusted user domain represented by a TrustedUserDomain object. Each element in the collection is a string. You can retrieve the collection by calling the DomainNames property on the TrustedUserDomain object.

Methods

The TrustedDomainNameCollection object defines the following methods.

Method Description
Add Adds an object to the collection (inherited from IList).
Clear Removes all objects from the collection (inherited from IList).
Contains Determines whether the collection contains a specific object (inherited from IList).
Copy Copies a rights template.
CopyTo Copies the collection elements to an array, starting at a specified index (inherited from ICollection).
IndexOf Retrieves the index of a specific object in the collection (inherited from IList).
Insert Inserts an object in the collection at the specified index (inherited from IList).
Remove Removes the first occurrence of the specified object from the collection (inherited from IList).
RemoveAt Removes the object at the specified index from the collection (inherited from IList).

Properties

The TrustedDomainNameCollection object has the following properties.

Property Description
Count Retrieves the number of objects contained in the collection (inherited from ICollection).
Item Specifies or retrieves the object at the specified index (inherited from IList).

Example Code [VBScript]

DIM config_manager
DIM admin_role

' *******************************************************************
' Create and initialize a ConfigurationManager object.

SUB InitObject()

  CALL WScript.Echo( "Create ConfigurationManager object...")
  SET config_manager = CreateObject _
    ("Microsoft.RightsManagementServices.Admin.ConfigurationManager")      
  CheckError()
    
  CALL WScript.Echo( "Initialize...")
  admin_role=config_manager.Initialize(false,"localhost",80,"","","")
  CheckError()

END SUB

' *******************************************************************
' Retrieve trusted user domain information.

SUB GetTudInfo()

  DIM trustPolicy
  DIM tudColl
  DIM Tud
  DIM domainNames
  DIM Index

  ' Retrieve the trust policy object.
  SET trustPolicy = config_manager.Enterprise.TrustPolicy
  CheckError()

  ' Retrieve the trusted user domain collection object.
  SET tudColl = trustPolicy.TrustedUserDomains
  CheckError()

  ' Import a server licensor certificate into the collection
  ' and retrieve a trusted user domain object
  SET Tud = tudColl.Import( "ServerLicensorCert", _
                            "c:\certFile.bin", _
                            False)
  CheckError()

  IF tudColl.Count < 1 OR IsNull(Tud.Id) THEN
    CALL RaiseError(-610, "Import failed.")
  END IF

  CALL WScript.Echo("Trusted user domain information: ")
  CALL WScript.Echo("Name = " & _
                    Tud.DisplayName)
  CALL WScript.Echo("Expiration = " & _
                    Tud.CertificateExpirationTime)
  CALL WScript.Echo("ID = " & _
                    Tud.Id)
  CALL WScript.Echo("ADFS trusted = " & _
                    Tud.IsADFederationSvcTrusted)
  CALL WScript.Echo("Imported = " & _
                    Tud.IsImported)
  CALL WScript.Echo("SIDs allowed = " & _
                    Tud.IsSecurityIdentifiersAllowed)
  CALL WScript.Echo("Trusted domain names:")

  SET domainNames = Tud.DomainNames
  For Index = 0 To domainNames.Count - 1
    CALL WScript.Echo("Domain Name = " & domainNames.Item(Index))
  Next

END SUB

' *******************************************************************
' Error checking function.

FUNCTION CheckError()
  CheckError = Err.number
  IF Err.number <> 0 THEN
    CALL WScript.Echo( vbTab & "*****Error Number: " _
                       & Err.number _
                       & " Desc:" _
                       & Err.Description _
                       & "*****")
    WScript.StdErr.Write(Err.Description)
    WScript.Quit( Err.number )
  END IF
END FUNCTION

' *******************************************************************
' Generate a runtime error.

SUB RaiseError(errId, desc)
  CALL Err.Raise( errId, "", desc )
  CheckError()
END SUB

Requirements

Product Requires Windows ServerĀ "Longhorn".
Library

Use Microsoft.RightsManagementServices.Admin.dll registered as a custom type library.

See Also

Active Directory Rights Management Services Scripting API