#include "ldb/include/ldb_private.h"
#include "libcli/ldap/ldap.h"
#include "libcli/ldap/ldap_client.h"
+#include "lib/cmdline/popt_common.h"
struct ildb_private {
const char *basedn;
int count, i;
struct ldap_message **ldapres, *msg;
+ if (scope == LDB_SCOPE_DEFAULT) {
+ scope = LDB_SCOPE_SUBTREE;
+ }
+
if (base == NULL) {
base = "";
}
ldb->modules->private_data = ildb;
ldb->modules->ops = &ildb_ops;
+ if (cmdline_credentials->username_obtained > CRED_GUESSED) {
+ status = ldap_bind_sasl(ildb->ldap, cmdline_credentials);
+ if (!NT_STATUS_IS_OK(status)) {
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "Failed to bind - %s\n",
+ ldap_errstr(ildb->ldap, status));
+ goto failed;
+ }
+ }
+
return 0;
failed:
#include "ldb/include/ldb.h"
#include "ldb/include/ldb_private.h"
#include "ldb/tools/cmdline.h"
+#ifdef _SAMBA_BUILD_
+#include "lib/cmdline/popt_common.h"
+#endif
/*
process command line options
{ "num-records", 0, POPT_ARG_INT, &options.num_records, 0, "number of test records", NULL },
{ "all", 'a', POPT_ARG_NONE, &options.all_records, 0, "dn=*", NULL },
{ "sorted", 'S', POPT_ARG_NONE, &options.sorted, 0, "sort attributes", NULL },
+ { "sasl-mechanism", 0, POPT_ARG_STRING, &options.sasl_mechanism, 0, "choose SASL mechanism", "MECHANISM" },
{ NULL, 'o', POPT_ARG_STRING, NULL, 'o', "ldb_connect option", "OPTION" },
+#ifdef _SAMBA_BUILD_
+ POPT_COMMON_SAMBA
+ POPT_COMMON_CREDENTIALS
+ POPT_COMMON_VERSION
+#endif
POPT_TABLEEND
};
+#ifdef _SAMBA_BUILD_
+ ldbsearch_init_subsystems;
+#endif
+
ret = talloc_zero(ldb, struct ldb_cmdline);
if (ret == NULL) {
ldb_oom(ldb);
options.editor = "vi";
}
+ options.scope = LDB_SCOPE_DEFAULT;
+
pc = poptGetContext(argv[0], argc, argv, popt_options,
POPT_CONTEXT_KEEP_FIRST);
goto failed;
}
+ if (ldb_connect(ldb, ret->url, 0, ret->options) != 0) {
+ fprintf(stderr, "Failed to connect to %s - %s\n",
+ ret->url, ldb_errstring(ldb));
+ goto failed;
+ }
+
return ret;
failed:
const char **argv;
int num_records;
int num_searches;
+ const char *sasl_mechanism;
};
struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, int argc, const char **argv,
int main(int argc, const char **argv)
{
struct ldb_context *ldb;
- int i, ret, count=0;
+ int i, count=0;
struct ldb_cmdline *options;
ldb = ldb_init(NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
- ret = ldb_connect(ldb, options->url, 0, options->options);
- if (ret != 0) {
- fprintf(stderr, "Failed to connect to %s - %s\n",
- options->url, ldb_errstring(ldb));
- talloc_free(ldb);
- exit(1);
- }
-
if (options->argc == 0) {
count += process_file(ldb, stdin);
} else {
exit(1);
}
- ret = ldb_connect(ldb, options->url, 0, options->options);
- if (ret != 0) {
- fprintf(stderr, "Failed to connect to %s - %s\n",
- options->url, ldb_errstring(ldb));
- talloc_free(ldb);
- exit(1);
- }
-
for (i=0;i<options->argc;i++) {
const char *dn = options->argv[i];
if (options->recursive) {
attrs = (const char * const *)options->argv;
}
- ret = ldb_connect(ldb, options->url, LDB_FLG_RDONLY, options->options);
- if (ret != 0) {
- fprintf(stderr, "Failed to connect to %s - %s\n",
- options->url, ldb_errstring(ldb));
- talloc_free(ldb);
- exit(1);
- }
-
ret = ldb_search(ldb, options->basedn, options->scope, expression, attrs, &msgs);
if (ret == -1) {
printf("search failed - %s\n", ldb_errstring(ldb));
options = ldb_cmdline_process(ldb, argc, argv, usage);
- ret = ldb_connect(ldb, options->url, 0, options->options);
- if (ret != 0) {
- fprintf(stderr, "Failed to connect to %s - %s\n",
- options->url, ldb_errstring(ldb));
- talloc_free(ldb);
- exit(1);
- }
-
if (options->argc == 0) {
usage();
exit(1);
options = ldb_cmdline_process(ldb, argc, argv, usage);
- ret = ldb_connect(ldb, options->url, 0, options->options);
- if (ret != 0) {
- fprintf(stderr, "Failed to connect to %s - %s\n",
- options->url, ldb_errstring(ldb));
- talloc_free(ldb);
- exit(1);
- }
-
if (options->argc < 2) {
usage();
}
struct ldb_context *ldb;
const char * const * attrs = NULL;
struct ldb_cmdline *options;
- int ret;
+ int ret = -1;
ldb = ldb_init(NULL);
attrs = (const char * const *)(options->argv+1);
}
- ret = ldb_connect(ldb, options->url, LDB_FLG_RDONLY, options->options);
- if (ret != 0) {
- fprintf(stderr, "Failed to connect to %s - %s\n",
- options->url, ldb_errstring(ldb));
- talloc_free(ldb);
- exit(1);
- }
-
if (options->interactive) {
char line[1024];
while (fgets(line, sizeof(line), stdin)) {
options->basedn = "ou=Ldb Test,ou=People,o=University of Michigan,c=US";
}
- ret = ldb_connect(ldb, options->url, 0, options->options);
- if (ret != 0) {
- fprintf(stderr, "Failed to connect to %s - %s\n",
- options->url, ldb_errstring(ldb));
- talloc_free(ldb);
- exit(1);
- }
-
srandom(1);
start_test(ldb, options->num_records, options->num_searches);