Java 使用log4jxml在spring中使用Ldap loggin
我在下一个Web.xml中有一个LDAP基本身份验证配置Java 使用log4jxml在spring中使用Ldap loggin,java,spring,ldap,log4j,Java,Spring,Ldap,Log4j,我在下一个Web.xml中有一个LDAP基本身份验证配置 <security-constraint> <web-resource-collection> <web-resource-name>Entire Application</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collect
<security-constraint>
<web-resource-collection>
<web-resource-name>Entire Application</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>mathematicians</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>ldap-realm</realm-name>
</login-config>
<security-role>
<description>Rol por defecto de la aplicacion mathematicians</description>
<role-name>mathematicians</role-name>
</security-role>
整个应用程序
/*
数学家
基本的
ldap领域
罗尔波·德拉阿普利卡翁数学家
数学家
是我拥有的唯一配置(和tomcat配置),工作正常,问题是当有身份验证问题时,我需要在日志文件中显示(使用log4jXML配置);ie:用户或密码错误,或者与ldap的连接失败。R您谈论的是使用
log4j
登录文件,还是在身份验证失败时,您希望在登录文件的jsp页面中显示错误?所提供的相关信息非常少且不清楚。改进您的问题并给出您想要的具体细节?对不起,我想在我的日志文件中显示身份验证错误。当您调用ldapContext.search(LDAP_组,“mail=“+emailId,constraints”)
要在LDAP中查找给定的emailId
或userName
,您需要以namingumeration-answer
的形式获取数据。由此,您可以使用answer.hasMore()
检查此枚举是否有数据。如果您获得了所需的数据,则登录成功,否则请调用LOGGER.fatal(“您的消息”)代码>让我们试一试&让我知道这对你有效吗?当我启动应用程序时,它会显示一个弹出窗口进行身份验证(基本身份验证),我的代码中没有任何检查,ldap会完成所有操作。使用