OpenLdap SpringldapTemplate 查询两种方式 随缘看

LdapQuery query = query().base("")
//        .attributes(key, val)   //返回的属性
        .where(key).is(val)
        .and("description").is("ou=xxx,ou=users");

        List result2 = ldapTemplate.search(query, new AbstractContextMapper() {
            @Override
            protected Object doMapFromContext(DirContextOperations ctx) {
                return ctx.getNameInNamespace();
            }
        });
        logger.info("result2: ",result2); 
  

 

EqualsFilter f = new EqualsFilter(key, val);
            List result = ldapTemplate.search("", andFilter.encode(), new AbstractContextMapper() {
                @Override
                protected Object doMapFromContext(DirContextOperations ctx) {
                    return ctx.getNameInNamespace();
                }
            }); 
  

 

你可能感兴趣的:(Rancher入门到精通,开发工具)