2

I want to authenticate user with OS. I am getting username, password as input from user & I simply want to check with os whether that username, password is right or wrong.

I don't want to do LDAP authenticating. Only os authentication where my program is running. Second thing program should run on windows from xp on-wards, linux & if possible unix flavors.

Is there any way I can achieve that?

While googling I found : https://github.com/twall/jna

But still trying to figure out whether this library is right for my requirement or not

2
  • I suspect you need to use JNA. The only alternative I know is to read the shadow file (requiring you to access to it) Commented Mar 29, 2012 at 7:35
  • for linux its alternative way. Its unaccepted for my mgr to read from file. And for windows how can I do that? Commented Mar 29, 2012 at 9:01

2 Answers 2

1

Try WAFFLE windows Authentication framework

Steps for Windows Authentication using WAFFLE framework

Step1. Download following jars a.jna.jar b.waffle-jna.jar

Step 2 :Place these jars in your class folders

Step 3: Using waffle in your Java code below is the code snippet

public boolean isValidUser(String username , String password){
  WindowsAuthProviderImpl authenticationProvider = new WindowsAuthProviderImpl();
  IWindowsIdentity loggedOnUser = authenticationProvider.logonUser(username, password);
  if(!loggedOnUser.isGuest()){
        return true;
  }
   return false;
 }

Hope this helps !!

Sign up to request clarification or add additional context in comments.

2 Comments

do u have any idea about how to do authentication with os, if os is linux
one more thing, it not working on 64bit windows 7. I put wrong username, password combination still It list all group names & doesn't throw any error/exception
0

Use GSS-API with Kerberos if your are in an Active Directory environment.

1 Comment

not looking for AD authentication anyway thanks for suggestion. Will keep in mind if doing auth with ad

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.