protected String getUserDnForSearch(String userName) {
    if (userSearchAttributeName == null || userSearchAttributeName.isEmpty()) {
      // memberAttributeValuePrefix and memberAttributeValueSuffix
      // were computed from memberAttributeValueTemplate
      return memberDn(userName);
    } else {
      return getUserDn(userName);
    }
  }
@Test
  void getUserDnForSearch() {
    LdapRealm realm = new LdapRealm();

    realm.setUserSearchAttributeName("uid");
    assertEquals("foo", realm.getUserDnForSearch("foo"));

    // using a template
    realm.setUserSearchAttributeName(null);
    realm.setMemberAttributeValueTemplate("cn={0},ou=people,dc=hadoop,dc=apache");
    assertEquals("cn=foo,ou=people,dc=hadoop,dc=apache",
            realm.getUserDnForSearch("foo"));
  }