This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
+ version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
/*
* Author: Andrew Tridgell
*/
-#include "includes.h"
-#include "ldb/include/includes.h"
-#include "ldb/tools/cmdline.h"
+#include "ldb_includes.h"
+#include "tools/cmdline.h"
static void usage(void)
{
struct ldb_message **el2,
void *opaque)
{
- struct ldb_context *ldb = talloc_get_type(opaque, struct ldb_context);
- return ldb_dn_compare(ldb, (*el1)->dn, (*el2)->dn);
+ return ldb_dn_compare((*el1)->dn, (*el2)->dn);
}
struct search_context {
return -1;
}
- sctx->store[sctx->num_stored] = talloc_move(sctx->store, msg);
+ sctx->store[sctx->num_stored] = talloc_move(sctx->store, &msg);
sctx->num_stored++;
sctx->store[sctx->num_stored] = NULL;
return -1;
}
- sctx->refs_store[sctx->refs] = talloc_move(sctx->refs_store, referral);
+ sctx->refs_store[sctx->refs] = talloc_move(sctx->refs_store, &referral);
sctx->refs++;
sctx->refs_store[sctx->refs] = NULL;
}
static int do_search(struct ldb_context *ldb,
- const struct ldb_dn *basedn,
+ struct ldb_dn *basedn,
struct ldb_cmdline *options,
const char *expression,
const char * const *attrs)
sctx->sort = options->sorted;
sctx->num_stored = 0;
sctx->store = NULL;
- sctx->req_ctrls = parse_controls(ldb, options->controls);
- if (options->controls != NULL && sctx->req_ctrls== NULL) return -1;
+ sctx->req_ctrls = ldb_parse_control_strings(ldb, sctx, (const char **)options->controls);
+ if (options->controls != NULL && sctx->req_ctrls== NULL) {
+ printf("parsing controls failed: %s\n", ldb_errstring(ldb));
+ return -1;
+ }
sctx->entries = 0;
sctx->refs = 0;
req->operation = LDB_SEARCH;
req->op.search.base = basedn;
req->op.search.scope = options->scope;
- req->op.search.tree = ldb_parse_tree(ldb, expression);
+ req->op.search.tree = ldb_parse_tree(req, expression);
if (req->op.search.tree == NULL) return -1;
req->op.search.attrs = attrs;
req->controls = sctx->req_ctrls;
if (sctx->pending)
goto again;
- if (sctx->sort && sctx->num_stored != 0) {
+ if (sctx->sort && (sctx->num_stored != 0 || sctx->refs != 0)) {
int i;
- ldb_qsort(sctx->store, ret, sizeof(struct ldb_message *),
+ ldb_qsort(sctx->store, sctx->num_stored, sizeof(struct ldb_message *),
ldb, (ldb_qsort_cmp_fn_t)do_compare_msg);
if (ret != 0) {
}
if (options->basedn != NULL) {
- basedn = ldb_dn_explode(ldb, options->basedn);
- if (basedn == NULL) {
+ basedn = ldb_dn_new(ldb, ldb, options->basedn);
+ if ( ! ldb_dn_validate(basedn)) {
fprintf(stderr, "Invalid Base DN format\n");
exit(1);
}