Question

Given a username and plaintext password, our application currently verifies that a local user exists with those credentials using Jawin FuncPtr to access the LogonUser function of advapi32.dll. However, online I've seen that there is currently no 32-bit version of the Jawin dll, which is a problem because we want to port this application over to 64-bit systems and it is a requirement to use 64-bit Java on those systems (which, as far as I've seen, cannot access the 32-bit DLL, even if the DLL is placed in the WOW folder). I have been attempting to find a way to, instead of using Jawin, use the Jacob project, since we are already using it elsewhere, there is a 64-bit version, and I've noticed that it is possible to use the following to grab group information for a user (took out exception logic; username is a string passed in earlier):

ActiveXComponent network = new ActiveXComponent("WScript.Network");
String computerName = network.getPropertyAsString("ComputerName");
String path = "WinNT://" + computerName + "/" + username;
ActiveXComponent user = new ActiveXComponent(path);
Dispatch groupsCollection = Dispatch.call(user.getObject(), "Groups").toDispatch();

So if I can get a user's group information, I should be able to authenticate a user as well, hopefully by very similar means. I first attempted to construct a new ActiveXComponent with advapi32.dll since that is what Jawin was using, but found that advapi32.dll is not a valid COM object. I've attempted several combinations of synonyms for the title of this post, including searching specifically for COM objects/program IDs (for the ActiveXComponent) that will handle local authentication. So far all I've found is:

-How to grab current credentials. In many cases for our application, however, the current user credentials are different from the credentials used to log in to the application.

-How to authenticate via LDAP or similar protocols. The application is only to access local users groups and will not have Active Directory, etc., installed.

-How to load libraries (such as the advapi32.dll) via the System class/JNI, though could not find how to call up methods from advapi32.dll and I'm very certain it wasn't designed to be used this way.

I know I'm probably missing just the right word to google/the right idea, so any guidance would be helpful. Using Jacob is just a preference since we already have it in use; if there is something better that can be accessed on both 32-bit and 64-bit systems (we don't want to change too much between the those architectures), please let me know.

Also feel free to tell me if my posting could be improved somehow. I've read from this site a lot but this is my first posting.

Was it helpful?

Solution

Tested with WAFFLE JNA 1.5, and works like a beauty with a lot less coding hassle (though does have more dependencies we didn't already bring in). Hopefully this helps anyone else out there with the same problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top