How to access LogonUser from advapi32.dll – using JNA

Re: [jna-users] How to access logonuser from advapi32.dll – Nikolas Lotz – net.java.dev.jna.users – MarkMail
import com.sun.jna.Library;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.Native;
import com.sun.jna.Platform;

public interface CLibrary extends Library {

CLibrary INSTANCE = (CLibrary) Native.loadLibrary((Platform.isWindows() ? “advapi32″ : “c"), CLibrary.class);

public boolean LogonUserA(String userName, String domain, String password, int dwLogonType, int dwLogonProvider, IntByReference lToken);
}

public static void main(String[] args) {

try {
IntByReference lToken = new IntByReference(0);

System.out.println(CLibrary.INSTANCE.LogonUserA(“username", “.", “password", 3, 0, lToken));
System.out.println(lToken);
} catch (Exception e) {
e.printStackTrace();
}

}

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *

What is 4 + 10 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)