ldap/servers/slapd/tools/ldclt/ldapfct.c | 10 +++++++---
ldap/servers/slapd/tools/ldclt/ldclt.c | 18 ++++++++++++++----
ldap/servers/slapd/tools/ldclt/ldclt.h | 1 +
ldap/servers/slapd/tools/ldclt/ldcltU.c | 2 ++
man/man1/ldclt.1 | 3 +++
5 files changed, 27 insertions(+), 7 deletions(-)
New commits:
commit d13057ebf14b50c9b6701424da4c6c88427857f8
Author: William Brown <firstyear(a)redhat.com>
Date: Wed May 18 17:29:01 2016 +1000
Ticket 48754 - ldclt should support -H
Bug Description: Most ldap tools are using the ldap url format of
ldap://hostname:port rather than -h hostname -p port. We should support this.
Fix Description: Add support for -H to ldclt.
https://fedorahosted.org/389/ticket/48754
Author: wibrown
Review by: nhosoi (Thanks!)
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c
b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index 13e66b8..e13983d 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -489,9 +489,13 @@ connectToLDAP(thread_context *tttctx, const char *bufBindDN, const
char *bufPass
}
#if defined(USE_OPENLDAP)
- ldapurl = PR_smprintf("ldap%s://%s:%d/",
- (mode & SSL) ? "s" : "",
- mctx.hostname, mctx.port);
+ if (mctx.ldapurl != NULL) {
+ ldapurl = PL_strdup(mctx.ldapurl);
+ } else {
+ ldapurl = PR_smprintf("ldap%s://%s:%d/",
+ (mode & SSL) ? "s" : "",
+ mctx.hostname, mctx.port);
+ }
if (PR_SUCCESS != PR_CallOnce(&ol_init_callOnce, internal_ol_init_init)) {
printf("Could not perform internal ol_init init\n");
goto done;
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.c
b/ldap/servers/slapd/tools/ldclt/ldclt.c
index 7296439..67b34ff 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.c
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.c
@@ -2363,6 +2363,7 @@ main (
mctx.filter = NULL;
mctx.globStatsCnt = DEF_GLOBAL_NB; /*JLS 08-08-00*/
mctx.hostname = "localhost";
+ mctx.ldapurl = NULL; /* Default url to none. */
mctx.ignErrNb = 0;
mctx.images = NULL; /*JLS 17-11-00*/
mctx.imagesDir = DEF_IMAGES_PATH; /*JLS 16-11-00*/
@@ -2412,7 +2413,7 @@ main (
* Get options
*/
while ((opt_ret = getopt (argc, argv,
- "a:b:D:e:E:f:h:i:I:n:N:o:p:qQr:R:s:S:t:T:vVw:W:Z:H")) != EOF)
+ "a:b:D:e:E:f:h:H:i:I:n:N:o:p:qQr:R:s:S:t:T:vVw:W:Z:H")) != EOF)
switch (opt_ret)
{
case 'a':
@@ -2439,6 +2440,9 @@ main (
case 'h':
mctx.hostname = optarg;
break;
+ case 'H':
+ mctx.ldapurl = optarg;
+ break;
case 'i':
mctx.inactivMax = atoi (optarg);
break;
@@ -2517,10 +2521,12 @@ main (
mctx.mode |= SSL;
mctx.certfile = optarg;
break;
+ /*
case 'H':
usage ();
- ldcltExit (EXIT_OK); /*JLS 18-12-00*/
+ ldcltExit (EXIT_OK);
break;
+ */
case '?':
usage ();
ldcltExit (EXIT_PARAMS); /*JLS 13-11-00*/
@@ -2818,8 +2824,12 @@ main (
{
printf ("%s\n", argvList); /*JLS 07-12-00*/
printf ("Process ID = %d\n", mctx.pid);
- printf ("Host to connect = %s\n", mctx.hostname);
- printf ("Port number = %d\n", mctx.port);
+ if (mctx.ldapurl != NULL) {
+ printf ("Ldap url = %s\n", mctx.ldapurl);
+ } else {
+ printf ("Host to connect = %s\n", mctx.hostname);
+ printf ("Port number = %d\n", mctx.port);
+ }
if (mctx.bindDN == NULL)
printf ("Bind DN = NULL\n");
else
diff --git a/ldap/servers/slapd/tools/ldclt/ldclt.h
b/ldap/servers/slapd/tools/ldclt/ldclt.h
index 4f8f485..b5da93a 100644
--- a/ldap/servers/slapd/tools/ldclt/ldclt.h
+++ b/ldap/servers/slapd/tools/ldclt/ldclt.h
@@ -521,6 +521,7 @@ typedef struct main_context {
char *genldifName; /* Where to put ldif */ /*JLS 19-03-01*/
int genldifFile; /* Where to put ldif */ /*JLS 19-03-01*/
char *hostname; /* Host to connect */
+ char *ldapurl; /* Url to connect to */
int globStatsCnt; /* Global stats loop */ /*JLS 08-08-00*/
int ignErr[MAX_IGN_ERRORS]; /* Err ignor */
int ignErrNb; /* Nb err ignored */
diff --git a/ldap/servers/slapd/tools/ldclt/ldcltU.c
b/ldap/servers/slapd/tools/ldclt/ldcltU.c
index 4597a03..e1fb4f4 100644
--- a/ldap/servers/slapd/tools/ldclt/ldcltU.c
+++ b/ldap/servers/slapd/tools/ldclt/ldcltU.c
@@ -94,6 +94,7 @@
* withnewparent : rename with newparent specified as argument.
* -f Filter for searches.
* -h Host to connect. Default "localhost".
+ * -H Ldap URL to connect to. Overrides -h -p. Default "None".
* -i Number of times inactivity allowed. Default 3 (30 seconds)
* -I Ignore errors (cf. -E). Default none.
* -n Number of threads. Default 10.
@@ -200,6 +201,7 @@ void usage ()
(void) printf (" randomauthidhigh=value : high value for random SASL
Authid.\n");
(void) printf (" -f Filter for searches.\n");
(void) printf (" -h Host to connect. Default
\"localhost\".\n");
+ (void) printf (" -H Ldap URL to connect to. Overrides -h -p. Default
\"None\".\n");
(void) printf (" -i Number of times inactivity allowed. Default 3 (30
seconds)\n");
(void) printf (" -I Ignore errors (cf. -E). Default
none.\n");
(void) printf (" -n Number of threads. Default 10.\n");
diff --git a/man/man1/ldclt.1 b/man/man1/ldclt.1
index 87bc6b4..206bacf 100644
--- a/man/man1/ldclt.1
+++ b/man/man1/ldclt.1
@@ -55,6 +55,9 @@ Filter for searches.
.B \fB\-h\fR
Host to connect. Default "localhost".
.TP
+.B \fB\-H\fR
+Ldap URL to connect to. Example, ldap://localhost:389. This takes precedence over -h and
-p.
+.TP
.B \fB\-i\fR
Number of times inactivity allowed. Default 3 (30 seconds)
.TP