int rc = Netapi32.INSTANCE.DsGetDcName(null, null, null, null, 0, pdci); if (W32Errors.ERROR_SUCCESS != rc) { throw new Win32Exception(rc); dc.name = pdci.dci.DomainControllerName.toString(); rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.dci.getPointer()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
/** * Returns the name of the primary domain controller (PDC). * @param serverName * Specifies the DNS or NetBIOS name of the remote server on which the function is * to execute. * @param domainName * Specifies the name of the domain. * @return * Name of the primary domain controller. */ public static String getDCName(String serverName, String domainName) { PointerByReference bufptr = new PointerByReference(); try { int rc = Netapi32.INSTANCE.NetGetDCName(domainName, serverName, bufptr); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } return bufptr.getValue().getWideString(0); } finally { if (W32Errors.ERROR_SUCCESS != Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } } }
/** * Return the domain/workgroup join status for a computer. * @param computerName Computer name. * @return Join status. */ public static int getJoinStatus(String computerName) { PointerByReference lpNameBuffer = new PointerByReference(); IntByReference bufferType = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } return bufferType.getValue(); } finally { if (lpNameBuffer.getPointer() != null) { int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } } } }
int rc = -1; try { rc = Netapi32.INSTANCE.NetUserGetInfo(domainName, accountName, (short)23, bufptr); if (rc == LMErr.NERR_Success) { USER_INFO_23 info_23 = new USER_INFO_23(bufptr.getValue()); Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
IntByReference totalentries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetUserGetGroups( serverName, userName, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
IntByReference totalEntries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetUserEnum( serverName, 1, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
IntByReference totalEntries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetLocalGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null); if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) { throw new Win32Exception(rc); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
IntByReference totalentries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetUserGetLocalGroups( serverName, userName, 0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
IntByReference totalEntries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
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) { rc = Netapi32.INSTANCE.NetApiBufferFree(domainsPointerRef.getValue()); if(W32Errors.NO_ERROR != rc) { throw new Win32Exception(rc);
int rc = -1; try { rc = Netapi32.INSTANCE.NetUserGetInfo(domainName, accountName, (short)23, bufptr); if (rc == LMErr.NERR_Success) { USER_INFO_23 info_23 = new USER_INFO_23(bufptr.getValue()); Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
IntByReference totalentries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetUserGetGroups( serverName, userName, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
IntByReference totalEntries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetUserEnum( serverName, 1, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
IntByReference totalEntries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetLocalGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null); if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) { throw new Win32Exception(rc); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
IntByReference totalentries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetUserGetLocalGroups( serverName, userName, 0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
IntByReference totalEntries = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null); } finally { if (bufptr.getValue() != Pointer.NULL) { int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);
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) { rc = Netapi32.INSTANCE.NetApiBufferFree(domainsPointerRef.getValue()); if(W32Errors.NO_ERROR != rc) { throw new Win32Exception(rc);
/** * Return the domain/workgroup join status for a computer. * @param computerName Computer name. * @return Join status. */ public static int getJoinStatus(String computerName) { PointerByReference lpNameBuffer = new PointerByReference(); IntByReference bufferType = new IntByReference(); try { int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } return bufferType.getValue(); } finally { if (lpNameBuffer.getPointer() != null) { int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } } } }
/** * Returns the name of the primary domain controller (PDC). * @param serverName * Specifies the DNS or NetBIOS name of the remote server on which the function is * to execute. * @param domainName * Specifies the name of the domain. * @return * Name of the primary domain controller. */ public static String getDCName(String serverName, String domainName) { PointerByReference bufptr = new PointerByReference(); try { int rc = Netapi32.INSTANCE.NetGetDCName(domainName, serverName, bufptr); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); } return bufptr.getValue().getString(0, true); } finally { if (W32Errors.ERROR_SUCCESS != Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())) { throw new Win32Exception(Kernel32.INSTANCE.GetLastError()); } } }
int rc = Netapi32.INSTANCE.DsGetDcName(null, null, null, null, 0, pdci); if (W32Errors.ERROR_SUCCESS != rc) { throw new Win32Exception(rc); dc.name = pdci.dci.DomainControllerName.toString(); rc = Netapi32.INSTANCE.NetApiBufferFree(pdci.dci.getPointer()); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc);