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();
}
}