import org.oxldap.annotation.*; @LdapEntity(entryObjectClasses = {"inetOrgPerson"}) public class LdapPerson { @LdapAttribute(name = "cn") private String fullname; @LdapAttribute(name = "sn") private String lastname; @LdapAttribute(name = "givenName") private String firstname; // Getters and setters } properties ldap.url=ldap://localhost:389 ldap.username=admin ldap.password=secret LdapTemplate ldapTemplate = new LdapTemplate(); ldapTemplate.init(); LdapPerson person = ldapTemplate.findByDn("uid=johndoe,ou=users,dc=example,dc=com", LdapPerson.class); System.out.println(person.getFullname()); person.setLastname("Doe"); ldapTemplate.update(person); LdapPerson newPerson = new LdapPerson(); newPerson.setFullname("Alice Smith"); newPerson.setLastname("Smith"); newPerson.setFirstname("Alice"); ldapTemplate.create(newPerson); ldapTemplate.destroy();


上一篇:
下一篇:
切换中文