で失敗私は、読ん更新およびLDAPでユーザーデータを作成するために、春データとLdapRepository APIを使用しようとしています。私は読むことと、正常に更新することができましたが、私は新しいレコードを挿入しようとするたびに私はこのエラーを取得する:春データLdapRepositoryで新しいユーザーを作成するLDAPエラーコード32
2017-07-25 17:31:01.966 ERROR 14404 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed;
nested exception is org.springframework.ldap.NameNotFoundException:
[LDAP: error code 32 - The search base entry '[email protected],ou=people,ou=myou,dc=bar,dc=foo' does not exist];
nested exception is javax.naming.NameNotFoundException:
[LDAP: error code 32 - The search base entry '[email protected],ou=people,ou=myou,dc=bar,dc=foo' does not exist]; remaining name '[email protected]']
with root cause
javax.naming.NameNotFoundException: [LDAP: error code 32 - The search base entry '[email protected],ou=people,ou=myou,dc=bar,dc=foo' does not exist]
私application.propertiesは次のとおりです。
user-api.ldap.contextSource.url=ldap://server.address.com:1389
user-api.ldap.contextSource.userDn=cn=manager role
user-api.ldap.contextSource.password=apasswordwashere
user-api.ldap.contextSource.base=ou=people,ou=myou,dc=bar,dc=foo
私のレポインタフェース、LdapUserRepository .javaファイル:
public interface LdapUserRepository extends LdapRepository<LdapUser>{
LdapUser findByCn(String cn);
LdapUser findBySn(String sn);
LdapUser save(LdapUser ldapUser);
}
私は明示的に保存方法を公開するか否か同じ応答を取得します。
私の設定がLdapConfiguration.javaで行われます。
@Configuration
@EnableLdapRepositories(basePackages = "foo.bar.userapi.dao.ldap", ldapTemplateRef="userLdapTemplate")
public class LdapConfiguration {
@Autowired
Environment env;
@Bean
public LdapContextSource contextSource() {
LdapContextSource contextSource= new LdapContextSource();
contextSource.setUrl(env.getRequiredProperty("user-api.ldap.contextSource.url"));
contextSource.setBase(env.getRequiredProperty("user-api.ldap.contextSource.base"));
contextSource.setUserDn(env.getRequiredProperty("user-api.ldap.contextSource.userDn"));
contextSource.setPassword(env.getRequiredProperty("user-api.ldap.contextSource.password"));
return contextSource;
}
@Bean(name="userLdapTemplate")
public LdapTemplate ldapTemplate() {
return new LdapTemplate(contextSource());
}
}
そして、私のテストルーチン:
public void test() {
LdapUser ldapUser = new LdapUser();
ldapUser.setCn("198777777");
ldapUser.setCountry("United States");
ldapUser.setGivenName("Hepsibah");
ldapUser.setIsActive("true");
ldapUser.setSn("Testerson91");
ldapUser.setStatus("active");
ldapUser.setUid(LdapUtils.newLdapName("[email protected]"));
ldapUser.setUserModifyTimestamp("20160222145439Z");
ldapUser.setUserPassword("Password-12345");
ldapUser = ldapUserRepository.save(ldapUser);
}
ストレスに私はこのような何かを行うとするので、コンフィギュレーションは、挿入以外のすべてのために働きます、それは動作します:
public void test2() {
LdapUser ldapUser = ldapUserRepository.findBySn("Testerson");
if (ldapUser != null) {
System.out.println(ldapUser.getUid().toString());
System.out.println("result: " + ldapUser.toString());
ldapUser.setSn("Testerson2");
ldapUser.setUserPassword("Password-12345!");
ldapUser = ldapUserRepository.save(ldapUser);
ldapUser = ldapUserRepository.findBySn("Testerson2");
if (ldapUser != null) {
System.out.println("result: " + ldapUser.toString());
}
}
}
私は答えがLdap error code 32 while adding user to ldapしかし、私は明示的に保存操作中にdnを追加していません。更新操作はうまく動作します。
レコードを取得するときに、uid値を変更して保存すると、同じエラーが発生します。レコードを取得してuidを検査すると、 "uid = [email protected]"の部分だけが表示され、 "ou = people、ou = myou、dc = bar、dc = foo"の部分は表示されません。 SimpleLdapRepositoryが、それは「保存」または「更新すべきかどうかを判断しようとすると、問題が発生している - デフォルトの実装が使用されている(リポジトリインタフェースを自身で実装していない場合は、これを取得しますSimpleLdapRepository)を想定すると
完璧だったアウトhttps://stackoverflow.com/questions/33288011/ldaprepository-update-spring-ldap P. – Philip