@LdapEntity(name = "user", schema = "ou=users,dc=example,dc=com") public class User { @LdapAttribute(name = "cn") private String fullName; @LdapAttribute(name = "uid") private String username; @LdapAttribute(name = "userPassword") private String password; // Getters and setters } public class Main { public static void main(String[] args) { LdapTemplate ldapTemplate = new LdapTemplate(); // Configuration LdapConfiguration configuration = new LdapConfiguration(); configuration.setUri("ldap://localhost:389"); configuration.setBaseDn("dc=example,dc=com"); configuration.setUseConnectionPooling(true); configuration.setEnableSsl(false); configuration.setEnableLogging(true); // Set configuration to the ldap template ldapTemplate.setConfiguration(configuration); // Connecting to the Ldap server ldapTemplate.connect(); // Create a new user entry User user = new User(); user.setFullName("John Doe"); user.setUsername("johndoe"); user.setPassword("password"); // Save the user entry to the Ldap server ldapTemplate.save(user); } }


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