The DsEnumerateDomainTrusts function obtains domain trust data for a specified domain.
DSGETDCAPI DWORD DsEnumerateDomainTrustsA( LPSTR ServerName, ULONG Flags, PDS_DOMAIN_TRUSTSA *Domains, PULONG DomainCount );
Pointer to a null-terminated string that specifies the name of a computer in the domain to obtain the trust information for. If this parameter is NULL, the name of the local computer is used. The caller must be an authenticated user in this domain.
If this computer is a domain controller, this function returns the trust data immediately. If this computer is not a domain controller, this function obtains the trust data from cached data if the cached data is not expired. If the cached data is expired, this function obtains the trust data from a domain controller in the domain that this computer is a member of and updates the cache. The cached data automatically expires after five minutes.
Contains a set of flags that determines which domain trusts to enumerate. This can be zero or a combination of one or more of the following values.
Enumerate domains that directly trust the domain which has ServerName as a member.
Enumerate domains directly trusted by the domain which has ServerName as a member.
Enumerate domains that are a member of the same forest which has ServerName as a member.
Enumerate domains where the primary domain is running in Windows 2000 native mode.
Enumerate domains that are the primary domain of the domain which has ServerName as a member.
Enumerate domains that are at the root of the forest which has ServerName as a member.
Pointer to a PDS_DOMAIN_TRUSTS value that receives an array of DS_DOMAIN_TRUSTS structures. Each structure in this array contains trust data about a domain. The caller must free this memory when it is no longer required by calling NetApiBufferFree.
Pointer to a ULONG value that receives the number of elements returned in the Domains array.
Returns ERROR_SUCCESS if successful or a Win32 error code otherwise. Possible error codes include those listed in the following list.
|Minimum supported client||Windows Vista|
|Minimum supported server||Windows Server 2008|