DispTrus Sample: Enumerates the Trusted Domains

Click to open or copy the files for the DispTrus sample.

Click to open or copy the Include files (required).

The DispTrus sample enumerates the trusted domains on the target machine, and displays them on stdout. This list matches (minus sorting) the list of domains presented by the WinNT DACL editor. For practical applications, replace the AddTrustToList function with linked-list management code and then use the resultant list later on in the application.

The optional target machine is specified as argv[1], eg, lsatrust \\winbase

Relevant Trusted Domains

For a WinNT workstation that is not a member of a domain, the only relevant trusted domain is the account domain of the machine. This sample detects a nonmember workstation by checking if the primary domain Sid is NULL.

For a WinNT workstation that is a member of a domain, the relevant trusted domain is the account domain, the primary domain, and the trusted domain(s) of the primary domain.

For a WinNT Domain controller, the relevant trusted domain is the account domain and the trusted domains.

Building SDK Samples

This sample uses the following keywords:

addtrusttolist; buildtrustlist; displaywinerror; enumtrusteddomains; formatmessagea; fprintf; freelibrary; getlasterror; getprocessheap; getstdhandle; heapalloc; heapfree; initlsastring; isdomaincontroller; loadlibraryex; localfree; lsaclose; lsaenumeratetrusteddomains; lsafreememory; lsantstatustowinerror; lsaopenpolicy; lsaqueryinformationpolicy; lstrcpynw; lstrlenw; makelangid; netapibufferfree; netgetdcname; netservergetinfo; openpolicy; printf; setlasterror; text; wmain; writefile; zeromemory