0

I am working on one java application. I am using Apache tomcat for this. I have one login page and i want user to login with OS NTNET username and password. I have details of our Active Directory. Now i want to authenticate the username password provided in my jsp page with the details we have in the active directory. I am not sure how LDAP will work here. Should we use JNDI Realm or something else is needed. What i tried till now is i updated the server.xml and web.xml files of tomcat with AD details. and updated my validate.jsp with below code:

`import java.security.Principal;
……
Principal principal = request.getUserPrincipal();
String userName = principal.getName();
.…`

But it didn't help. If some one can help here it would be great.

shilpa
  • 9
  • 1
  • 5
  • SSO ? or will he/she key in domain credentials again ? – Ramachandran.A.G Aug 10 '16 at 10:13
  • user need to login in my login page Login.jsp and once they click on login button it should authenticate the details with Active Directory. – shilpa Aug 10 '16 at 10:16
  • Have you read [Windows Authentication How-To](https://tomcat.apache.org/tomcat-8.0-doc/windows-auth-howto.html) from Tomcat's documentation? Is there something you don't need to help with? – Jozef Chocholacek Aug 10 '16 at 11:35
  • Why not just use a `JNDIRealm` with your application? It should be pretty straightforward. – Christopher Schultz Aug 10 '16 at 12:17
  • yes i did same I added JNDIRealm in my server.xml also updated the web.xml file. But how my jsp page will authenticate that username password that i am not sure. – shilpa Aug 10 '16 at 12:38

1 Answers1

0

You would have a login page , a Text Input , a password field and then a submit button with a controller wired on POST.

In the controller you will get data from the UI form. Then you can call a method from the controller for authentication like in this thread (Authenticating against Active Directory with Java on Linux) and based on the value returned by the authentication you can choose to redirect the user to the next page

Ramachandran.A.G
  • 4,788
  • 1
  • 12
  • 24
  • So no matter whether we will update server.xml and web.xml of tomcat or not. just we need to update the validation code in .java file which will authenticate the user. No role of tomcat here?? – shilpa Aug 10 '16 at 10:29