Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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 LDAP与Spring_Java_Xml_Active Directory - Fatal编程技术网

Java LDAP与Spring

Java LDAP与Spring,java,xml,active-directory,Java,Xml,Active Directory,我想在我的应用程序中使用LDAP进行身份验证 我在以前的配置中使用了数据库进行身份验证 这是我以前的配置: <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:s

我想在我的应用程序中使用LDAP进行身份验证

我在以前的配置中使用了数据库进行身份验证

这是我以前的配置:

<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
                    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    http://www.springframework.org/schema/security 
                    http://www.springframework.org/schema/security/spring-security-3.1.xsd">

    <http auto-config="true" use-expressions="true">
        <intercept-url pattern="/test/**" access="hasRole('ADMIN')" />
        <intercept-url pattern="/test1/**" access="hasRole('USER')" />



         <form-login login-page="/index.htm" authentication-success-handler-ref="authenticationSuccessRedirecthandler"
          default-target-url = "/test/MainHealthCertificat.htm"
            authentication-failure-url="/index.htm?error=1"/>
        <logout logout-success-url="/index.htm" />


    </http>


    <beans:bean class="com..CustomAuthenticationHandler" id="authenticationSuccessRedirecthandler"></beans:bean>

    <authentication-manager>
        <authentication-provider>

                <jdbc-user-service data-source-ref="dataSource" 
                                        users-by-username-query="select username, password, enabled from users where username=?"  
                    authorities-by-username-query="select u.username, ur.authority from users u, user_roles ur where u.user_id = ur.user_id and u.username =?  " 
                />

        </authentication-provider>
    </authentication-manager>
</beans:beans>
老实说,我在设置ldap参数时迷失了方向:ou dc,cn

我需要帮助在security-app-context.xml中配置ldap的参数

这是ldap的正确参数,应在security-app-context.xml中使用

基本提供商URL

ldap://192.168.0.88:389

基本DN

DC=部长,DC=FR

负责人

<beans:beans xmlns="http://www.springframework.org/schema/security"
        xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
                        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                        http://www.springframework.org/schema/security 
                        http://www.springframework.org/schema/security/spring-security-3.1.xsd">

        <http auto-config="true" use-expressions="true">
            <intercept-url pattern="/test/**" access="hasRole('ADMIN')" />
            <intercept-url pattern="/test1/**" access="hasRole('USER')" />



             <form-login login-page="/index.htm" authentication-success-handler-ref="authenticationSuccessRedirecthandler"
              default-target-url = "/test/MainHealthCertificat.htm"
                authentication-failure-url="/index.htm?error=1"/>
            <logout logout-success-url="/index.htm" />


        </http>


        <beans:bean class="com..CustomAuthenticationHandler" id="authenticationSuccessRedirecthandler"></beans:bean>

         <security:authentication-manager>
         <security:ldap-authentication-provider 
           user-search-filter="(uid={0})"
           user-search-base="ou=users"
           group-search-filter="(uniqueMember={0})"
           group-search-base="ou=groups"
           group-role-attribute="cn"
           role-prefix="ROLE_">
         </security:ldap-authentication-provider>
 </security:authentication-manager>

 <security:ldap-server url="ldap://192.168.0.88:389" manager-dn="uid=admin,ou=system" manager-password="secret" />
    </beans:beans>
CN=LDAP请求者,OU=Users,OU=Technical Accounts,OU=P9 Accounts,DC=MINISTER,DC=FR

凭证

部长:9999美元

用户

身份验证搜索筛选器

(&(objectClass=person)(mail=@email_address@))

导入搜索过滤器

(objectClass=person)

用户映射

屏幕名称

sAMAccountName

密码

用户密码

电子邮件地址

邮寄

全名

cn

名字

吉文纳姆

中间名

中间名

姓氏

集团

成员

导入搜索过滤器

(&(objectClass=group)(cn=MinisterUsers)(cn=ministerAdministrators)(cn=ministerAdministrators)

组映射

组名

cn

说明

sAMAccountName

用户

成员

导出

用户DN DC=部长,DC=FR


组DN DC=MINISTER,DC=FR

错误代码数据52e表示提供的凭据无效

请尝试删除这些属性manager dn=“uid=admin,ou=system”manager password=“secret” 在下面

<security:ldap-server url="ldap://192.168.0.88:389" manager-dn="uid=admin,ou=system" manager-password="secret" />

然后再试一次。这些是LDAP管理凭据,用户身份验证不需要这些凭据。用户身份验证是使用您在登录期间提供的值完成的,spring默认情况下尝试使用提供的详细信息绑定到LDAP

还可以尝试通过在security-app-context.xml中包含标记来启用调试,并添加log4j.properties。这将为调试提供大量有用的信息

Caused by: org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db0
<security:ldap-server url="ldap://192.168.0.88:389" manager-dn="uid=admin,ou=system" manager-password="secret" />