Search in sources :

Example 1 with PDOMAIN_CONTROLLER_INFO

use of com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO in project jna by java-native-access.

the class Netapi32Util method getDC.

/**
     * Return the domain controller for a current computer.
     * @return
     *  Domain controller information.
     */
public static DomainController getDC() {
    PDOMAIN_CONTROLLER_INFO pdci = new PDOMAIN_CONTROLLER_INFO();
    int rc = Netapi32.INSTANCE.DsGetDcName(null, null, null, null, 0, pdci);
    if (W32Errors.ERROR_SUCCESS != rc) {
        throw new Win32Exception(rc);
    }
    DomainController dc = new DomainController();
    if (pdci.dci.DomainControllerAddress != null) {
        dc.address = pdci.dci.DomainControllerAddress.toString();
    }
    dc.addressType = pdci.dci.DomainControllerAddressType;
    if (pdci.dci.ClientSiteName != null) {
        dc.clientSiteName = pdci.dci.ClientSiteName.toString();
    }
    if (pdci.dci.DnsForestName != null) {
        dc.dnsForestName = pdci.dci.DnsForestName.toString();
    }
    dc.domainGuid = pdci.dci.DomainGuid;
    if (pdci.dci.DomainName != null) {
        dc.domainName = pdci.dci.DomainName.toString();
    }
    dc.flags = pdci.dci.Flags;
    if (pdci.dci.DomainControllerName != null) {
        dc.name = pdci.dci.DomainControllerName.toString();
    }
    rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.dci.getPointer());
    if (LMErr.NERR_Success != rc) {
        throw new Win32Exception(rc);
    }
    return dc;
}
Also used : PDOMAIN_CONTROLLER_INFO(com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO)

Aggregations

PDOMAIN_CONTROLLER_INFO (com.sun.jna.platform.win32.DsGetDC.PDOMAIN_CONTROLLER_INFO)1