Spring boot 如何使用spring boot在ldif文件(嵌入式LDAP)中创建新条目

Spring boot 如何使用spring boot在ldif文件(嵌入式LDAP)中创建新条目,spring-boot,ldap,spring-ldap,ldif,Spring Boot,Ldap,Spring Ldap,Ldif,我试图在我的LDIF文件中插入用户详细信息,该文件使用spring boot进行了完美配置,因为即使我能够使用LdapTemplate.bind()方法,我也能够获取数据 我尝试了各种代码,最后,我能够使用ldapTemplate.bind()方法,但它只将我的条目与LDAP树绑定,这意味着ldif文件中没有条目,当我重新启动LDAP服务器时,该条目丢失 错误: org.springframework.ldap.InvalidNameException: Invalid name: abcdte

我试图在我的LDIF文件中插入用户详细信息,该文件使用spring boot进行了完美配置,因为即使我能够使用LdapTemplate.bind()方法,我也能够获取数据

我尝试了各种代码,最后,我能够使用ldapTemplate.bind()方法,但它只将我的条目与LDAP树绑定,这意味着ldif文件中没有条目,当我重新启动LDAP服务器时,该条目丢失

错误:

org.springframework.ldap.InvalidNameException: Invalid name: abcdtestuser@gmail.com; nested exception is javax.naming.InvalidNameException: Invalid name: abcdtestuser@gmail.com
    at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:136)
    at org.springframework.ldap.support.LdapUtils.newLdapName(LdapUtils.java:416)
    at org.springframework.ldap.support.LdapNameBuilder.add(LdapNameBuilder.java:121)
    at in.indg.cdac.ldap.service.LdapService.saveInLdap(LdapService.java:71)
    at in.indg.cdac.ldap.service.LdapService.create(LdapService.java:57)
    at in.indg.cdac.ldap.controller.LdapController.saveUserDetail(LdapController.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
实体:

@Entry(base="ou=vikaspedia", objectClasses = {"inetOrgPerson", "person", "top"})
public class User {

    @Id
    private Name id;
    private @Attribute(name = "mail") String uid;
    private @Attribute(name = "cn") String firstName;
    private @Attribute(name = "sn") String lastName;
    private @Attribute(name = "userPassword") String password;
    private @Attribute(name = "description") String userrole;
创建方法:

    public String create(UserResponsePojo userResponsePojo) {
        try {
            Name dn = LdapNameBuilder
                      .newInstance()
                      .add("ou", "vikaspedia")
                      .add("mail", userResponsePojo.getUid())
//                    .add("cn", userResponsePojo.getUsername())
                      .build();
                    DirContextAdapter context = new DirContextAdapter(dn);

//                  Name id = LdapNameBuilder
//                          .newInstance()
//                          .add(userResponsePojo.getUid())
//                          .build();

                    context.setAttributeValues("objectclass", new String[]{"inetOrgPerson", "person", "top"});
                    context.setAttributeValue("cn", userResponsePojo.getUsername());
                    context.setAttributeValue("sn", userResponsePojo.getLastname());
                    context.setAttributeValue("description", userResponsePojo.getUserrole());
                    context.setAttributeValue("mail", userResponsePojo.getUid());
                    context.setAttributeValue("userPassword", digestSHA(userResponsePojo.getPassword()));

                    ldapTemplate.bind(context);
                    ldapTemplate.create(context);
也许,自动增加Id可以解决这个问题,但我不知道如何才能像使用JPA@GeneratedValue(strategy=GeneratedType.IDENTITY)那样实现这一点

任何帮助都将不胜感激。提前谢谢