Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/310.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用log4jxml在spring中使用Ldap loggin_Java_Spring_Ldap_Log4j - Fatal编程技术网

Java 使用log4jxml在spring中使用Ldap loggin

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

我在下一个Web.xml中有一个LDAP基本身份验证配置

<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会完成所有操作。使用