@Entry(baseDn = "ou=users,dc=example,dc=com", objectClasses = {"person"}) public class User { @Attribute(name = "cn") private String commonName; @Attribute(name = "sn") private String surName; @DnAttribute private String uid; } public class LdapOperations { public static void main(String[] args) { User user = new User("John Doe", "Doe", "jdoe"); LdapEntry entry = OxLdap.toEntry(user); ldapConnection.add(entry); LdapSearchCriteria<User> searchCriteria = OxLdap.createQuery(User.class) .where("sn").like("%Doe%") .orderBy("cn", OrderByDirection.ASCENDING) .limit(10) .build(); List<User> users = ldapConnection.search(searchCriteria); user.setCommonName("Jane Doe"); LdapEntry updatedEntry = OxLdap.toEntry(user); ldapConnection.update(updatedEntry); ldapConnection.delete(entry); } } LdapConnectionConfig connectionConfig = new LdapConnectionConfig(); connectionConfig.setLdapHost("ldap.example.com"); connectionConfig.setLdapPort(389); connectionConfig.setUseSsl(false); LdapConnection connection = new LdapNetworkConnection(connectionConfig); connection.connect();


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