From 12e81808d4160bc5ef9d56b885ea1bd00dd4d697 Mon Sep 17 00:00:00 2001
From: ugaston <ugaston@localhost>
Date: Fri, 09 Jan 2009 17:40:19 +0000
Subject: [PATCH] Add set of SSF testcases to SASL test suite
---
opendj-sdk/opends/tests/staf-tests/shared/java/ldap/saslSearchClient.java | 32 +++++++++++++++++++++++++++++---
1 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/opendj-sdk/opends/tests/staf-tests/shared/java/ldap/saslSearchClient.java b/opendj-sdk/opends/tests/staf-tests/shared/java/ldap/saslSearchClient.java
index fb54766..2846360 100644
--- a/opendj-sdk/opends/tests/staf-tests/shared/java/ldap/saslSearchClient.java
+++ b/opendj-sdk/opends/tests/staf-tests/shared/java/ldap/saslSearchClient.java
@@ -37,6 +37,9 @@
import javax.naming.CommunicationException;
import javax.naming.directory.InvalidSearchFilterException;
import javax.security.sasl.AuthenticationException;
+import javax.naming.NamingEnumeration;
+import javax.naming.directory.SearchResult;
+import javax.naming.directory.SearchControls;
import java.util.HashSet;
import java.util.Iterator;
@@ -57,9 +60,9 @@
// Ldapsearch parameters
String hostname = null;
String ldapPort = null;
- String scope = null;
String basedn = null;
String filter = null;
+ int scope;
// SASL options
@@ -80,6 +83,8 @@
Hashtable envLdap = new Hashtable();
LdapContext ctx = null;
+ SearchControls searchControls = null;
+ NamingEnumeration results = null;
@@ -95,7 +100,16 @@
ldapPort = val1;
}
if (opt1.equals("-s")) {
- scope = val1;
+ if (val1.equals("base")) {
+ scope = SearchControls.OBJECT_SCOPE;
+ } else if (opt1.equals("one")) {
+ scope = SearchControls.ONELEVEL_SCOPE;
+ } else {
+ // default scope: "sub"
+ scope = SearchControls.SUBTREE_SCOPE;
+ }
+ searchControls = new SearchControls();
+ searchControls.setSearchScope(scope);
}
if (opt1.equals("-b")) {
basedn = val1;
@@ -178,7 +192,7 @@
ctx = new InitialLdapContext(envLdap, null);
// issue ldapsearch
- ctx.search(basedn, filter, null);
+ results = ctx.search(basedn, filter, searchControls);
ctx.close();
} catch (CommunicationException e1) {
@@ -229,6 +243,18 @@
}
}
+ try {
+ if ((errorCode.equals("0")) && (results != null)) {
+ while (results.hasMore()) {
+ SearchResult searchResult = (SearchResult) results.next();
+ System.out.println(searchResult.toString());
+ }
+ results.close();
+ }
+ } catch (NamingException ne) {
+ ne.printStackTrace();
+ }
+
int RC = Integer.parseInt(errorCode);
System.exit(RC);
}
--
Gitblit v1.10.0