[英]How to authenticate JSP login page with LDAP Active Directory
I am working on one java application. 我正在开发一个Java应用程序。 I am using Apache tomcat for this.
我为此使用Apache tomcat。 I have one login page and i want user to login with OS NTNET username and password.
我有一个登录页面,我希望用户使用OS NTNET用户名和密码登录。 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.
现在,我要使用活动目录中的详细信息来验证我的jsp页面中提供的用户名密码。 I am not sure how LDAP will work here.
我不确定LDAP在这里如何工作。 Should we use JNDI Realm or something else is needed.
我们应该使用JNDI Realm还是需要其他东西。 What i tried till now is i updated the server.xml and web.xml files of tomcat with AD details.
到目前为止,我尝试用AD详细信息更新了tomcat的server.xml和web.xml文件。 and updated my validate.jsp with below code:
并使用以下代码更新了我的validate.jsp:
`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.
如果有人可以在这里提供帮助,那就太好了。
You would have a login page , a Text Input , a password field and then a submit button with a controller wired on POST. 您将拥有一个登录页面,一个文本输入,一个密码字段,然后有一个带有POST上连接的控制器的提交按钮。
In the controller you will get data from the UI form. 在控制器中,您将从UI表单获取数据。 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
然后,您可以从控制器中调用一种方法进行身份验证,如该线程中所示( 在Linux上使用Java对Active Directory进行身份验证 ),然后根据身份验证返回的值,您可以选择将用户重定向到下一页
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.