Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.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
在密码更改openldap spring中获取BadCredentialsException_Spring_Ldap_Passwords_Credentials_Openldap - Fatal编程技术网

在密码更改openldap spring中获取BadCredentialsException

在密码更改openldap spring中获取BadCredentialsException,spring,ldap,passwords,credentials,openldap,Spring,Ldap,Passwords,Credentials,Openldap,我在本地主机上运行openldap,我试图从我的spring应用程序更改用户帐户密码,但我遇到以下异常 请帮忙 org.springframework.security.authentication.BadCredentialsException: Authentication for password change failed. at org.springframework.security.ldap.userdetails.LdapUserDetailsManager$3.exec

我在本地主机上运行openldap,我试图从我的spring应用程序更改用户帐户密码,但我遇到以下异常

请帮忙

org.springframework.security.authentication.BadCredentialsException: Authentication for password change failed.
    at org.springframework.security.ldap.userdetails.LdapUserDetailsManager$3.executeWithContext(LdapUserDetailsManager.java:204) ~[spring-security-ldap-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.ldap.core.LdapTemplate.executeWithContext(LdapTemplate.java:817) ~[spring-ldap-core-2.3.1.RELEASE.jar:2.3.1.RELEASE]
    at org.springframework.ldap.core.LdapTemplate.executeReadWrite(LdapTemplate.java:812) ~[spring-ldap-core-2.3.1.RELEASE.jar:2.3.1.RELEASE]
    at org.springframework.security.ldap.userdetails.LdapUserDetailsManager.changePassword(LdapUserDetailsManager.java:191) ~[spring-security-ldap-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at com.atulsia.controller.UserController.getTemplate(UserController.java:417) ~[classes/:na]
    at com.atulsia.controller.UserController.getAllUsers(UserController.java:437) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_171]
代码:

    LdapContextSource contextSource = new LdapContextSource();
    contextSource.setUrl("ldap://localhost:389");
    contextSource.setUserDn("cn=Anil Pawar,cn=mts,ou=mm,dc=example,dc=com");
    contextSource.setPassword("123456");
    try {
        contextSource.afterPropertiesSet();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    LdapTemplate template = new LdapTemplate();
    template.setContextSource(contextSource);

    LdapUserDetailsManager ldapUserDetailsManager  = new LdapUserDetailsManager(template.getContextSource());
    ldapUserDetailsManager.changePassword("123456", "111111");