* Server name.
* @return
* An array of domain trusts.
*/
public static DomainTrust[] getDomainTrusts(String serverName) {
IntByReference domainTrustCount = new IntByReference();
PointerByReference domainsPointerRef = new PointerByReference();
int rc = Netapi32.INSTANCE.DsEnumerateDomainTrusts(serverName,
DsGetDC.DS_DOMAIN_VALID_FLAGS, domainsPointerRef, domainTrustCount);
if(W32Errors.NO_ERROR != rc) {
throw new Win32Exception(rc);
}
try {
DS_DOMAIN_TRUSTS domainTrustRefs = new DS_DOMAIN_TRUSTS(domainsPointerRef.getValue());
DS_DOMAIN_TRUSTS[] domainTrusts = (DS_DOMAIN_TRUSTS[]) domainTrustRefs.toArray(new DS_DOMAIN_TRUSTS[domainTrustCount.getValue()]);
ArrayList<DomainTrust> trusts = new ArrayList<DomainTrust>(domainTrustCount.getValue());
for(DS_DOMAIN_TRUSTS domainTrust : domainTrusts) {
DomainTrust t = new DomainTrust();
if (domainTrust.DnsDomainName != null) {
t.DnsDomainName = domainTrust.DnsDomainName.toString();
}