212.7. サンプル

上記の Spring 設定に続いて、以下のコードサンプルは LDAP リクエストを送信して、メンバーのグループをフィルター検索します。次に、共通名がレスポンスから抽出されます。

ProducerTemplate<Exchange> template = exchange.getContext().createProducerTemplate();

List<?> results = (Collection<?>) template.sendBody("ldap:ldapConnection, "LDiff goes here");

if (results.size() > 0) {
  // Check for no errors

  for (String result : results) {
    if ("success".equalTo(result)) {
      // LDIF entry success
    } else {
      // LDIF entry failure
    }
  }
}