Platform SDK: Active Directory, ADSI, and Directory Services

DsEnumerateDomainTrusts

The DsEnumerateDomainTrusts function returns information about domain trusts for the domain which has ServerName as a member.

DWORD DsEnumerateDomainTrusts(
  LPWSTR ServerName,
  ULONG Flags,
  PDS_DOMAIN_TRUSTS *Domains,
  PULONG DomainCount
);

Parameters

ServerName
[in, optional] Pointer to a null-terminated string that specifies the name of the remote server to process this function. If this parameter is NULL, the local computer is used. ServerName must be a Windows NT workstation or a Windows NT non-DC server. This name should be prefixed by "\\".
Flags
[in] Specifies attributes of trusts to be returned. This parameter can be a combination of the following values, coupled by using the OR operation.
Value Meaning
DS_DOMAIN_DIRECT_INBOUND The domain is directly trusting the domain which has ServerName as a member.
DS_DOMAIN_DIRECT_OUTBOUND The domain is directly trusted.
DS_DOMAIN_IN_FOREST The domain is a member of the same forest which has ServerName as a member.
DS_DOMAIN_NATIVE_MODE The primary domain is running in the Windows 2000® native mode.
DS_DOMAIN_PRIMARY The domain is the primary domain of the queried server.
DS_DOMAIN_TREE_ROOT The domain is the root of a tree and member of the same forest which has ServerName as a member.
DS_DOMAIN_VALID_FLAGS All of the above values.

*Domains
[out] Returns an array of domain trust structures. The buffer must be freed using NetApiBufferFree().
DomainCount
[out] Returns a count of the number of elements in the Domains array.

Return Values

Value Meaning
ERROR_INVALID_FLAGS The Flags parameter has invalid bit set.
ERROR_NO_LOGON_SERVERS No DC could be found and no cached information is available
ERROR_NO_TRUST_LSA_SECRET The client side of the trust relationship is broken and no cached information is available.
ERROR_NO_TRUST_SAM_ACCOUNT The server side of the trust relationship is broken or the password is broken and no cached information is available.
ERROR_NOT_SUPPORTED ServerName does not support this call. In particular, this error is returned if ServerName is an Windows NT® 3.51 machine or if ServerName is an Windows NT 4.0 machine and DS_DOMAIN_DIRECT_INBOUND is specified.
NO_ERROR Success

Requirements

  Windows NT/2000: Requires Windows 2000.
  Header: Declared in Dsgetdc.h.
  Library: Included as a resource in Ntdsapi.dll.
  Unicode: Implemented as Unicode and ANSI versions on Windows 2000.

See Also

Directory Service Functions