title: LDAP: error code 65 - object class 'inetOrgPerson' requires attribute 'sn'
body: <p>I am using LdapTemplate in my Spring application.While adding records it giving error <code>LDAP: error code 65 - object class 'inetOrgPerson' requires attribute 'sn'</code></p>
  
  <p>My repository code is</p>
  
  <pre><code>@Autowired
      private LdapTemplate ldapTemplate;
  
      @Autowired
      private PasswordEncoder passwordEncoder;
  
      public void setLdapTemplate(LdapTemplate ldapTemplate) {
          this.ldapTemplate = ldapTemplate;
      }
  
      public void create(User user) {
          Name dn = buildDn(user);
          DirContextAdapter context = new DirContextAdapter(dn);
          mapToContext(user, context);
          ldapTemplate.bind(dn, context, null);
      }
  
      private LdapName buildDn(User user) {
          return LdapNameBuilder
                  .newInstance()
                  .add("cn", user.getName())
                  .add("sn", user.getLname())
                  .add("uid", user.getUid())
                  .add("userPassword", passwordEncoder.encode(user.getPassword()))
                  .build();
  
      }
  
      private void mapToContext(User user, DirContextAdapter context) {
          context.setAttributeValues("objectclass", new String[] { "top", "inetOrgPerson" });
          context.setAttributeValue("uid", user.getName());
          context.setAttributeValue("userPassword",
                  passwordEncoder.encode(user.getPassword()));
  
      }
  }
  </code></pre>
  
  <p>I also change inetOrgPerson to person,organizationalPerson but it won't work.</p>
  
  <p>Where as I can add ldif file from my terminal</p>
  
  <pre><code>dn: ou=roles,dc=cofinding,dc=com
  objectclass: top
  objectclass: organizationalUnit
  ou: roles
  
  dn: ou=people,dc=cofinding,dc=com
  objectclass: top
  objectclass: organizationalUnit
  ou: people
  
  
  # Users
  
  dn: uid=admin1,ou=people,dc=cofinding,dc=com
  objectclass: top
  objectclass: person
  objectclass: organizationalPerson
  objectclass: inetOrgPerson
  cn: Prashant
  sn:Thorat
  uid: admin1
  userPassword: admin1Pass
  
  dn: uid=admin2,ou=people,dc=cofinding,dc=com
  objectclass: top
  objectclass: person
  objectclass: organizationalPerson
  objectclass: inetOrgPerson
  cn: Aniket
  sn:Patil
  uid: admin2
  userPassword: admin2Pass
  
  dn: uid=user1,ou=people,dc=cofinding,dc=com
  objectclass: top
  objectclass: person
  objectclass: organizationalPerson
  objectclass: inetOrgPerson
  cn: Gautam
  sn:Kanawade
  uid: user1
  userPassword: user1Pass
  
  
  # Roles
  
  dn: cn=USER,ou=roles,dc=cofinding,dc=com
  objectclass: top
  objectclass: groupOfNames
  cn: USER
  member: uid=admin1,ou=people,dc=cofinding,dc=com
  member: uid=admin2,ou=people,dc=cofinding,dc=com
  member: uid=user2,ou=people,dc=cofinding,dc=com
  
  dn: cn=ADMIN,ou=roles,dc=cofinding,dc=com
  objectclass: top
  objectclass: groupOfNames
  cn: ADMIN
  member: uid=admin1,ou=people,dc=cofinding,dc=com
  member: uid=admin2,ou=people,dc=cofinding,dc=com
  </code></pre>