Commit ac9395d8 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

updates from HEAD

parent 20a05ed4
......@@ -186,9 +186,14 @@ main( int argc, char **argv )
int referrals, timelimit, sizelimit, debug;
int authmethod, version, want_bindpw;
LDAP *ld = NULL;
int valuesReturnFilter;
BerElement *ber;
struct berval *bvalp;
char *vrFilter = NULL, *control = NULL, *s;
infile = NULL;
debug = verbose = not = vals2tmp = referrals =
debug = verbose = not = vals2tmp = referrals = valuesReturnFilter =
attrsonly = manageDSAit = ldif = want_bindpw = 0;
lutil_log_initialize(argc, argv);
......@@ -222,7 +227,7 @@ main( int argc, char **argv )
prog = (prog = strrchr(argv[0], *LDAP_DIRSEP)) == NULL ? argv[0] : prog + 1;
while (( i = getopt( argc, argv, "Aa:b:F:f:Ll:S:s:T:tuz:"
while (( i = getopt( argc, argv, "Aa:b:E:F:f:Ll:S:s:T:tuz:"
"Cd:D:h:H:IkKMnO:p:P:QR:U:vw:WxX:Y:Z")) != EOF )
switch( i ) {
......@@ -254,6 +259,47 @@ main( int argc, char **argv )
infile = strdup( optarg );
case 'E': /* controls */
if( version == LDAP_VERSION2 ) {
fprintf( stderr, "%s: -C incompatible with LDAPv%d\n",
prog, version );
/* should be extended to support comma separated list of
* key/value pairs: -E foo=123,bar=567
control = strdup( optarg );
if ( (s = strchr( control, '=' )) == NULL ) {
*s++ = '\0';
if ( strcasecmp( control, "mv" ) == 0 ) {
/* ValuesReturnFilter control */
if (valuesReturnFilter!=0) {
fprintf( stderr, "ValuesReturnFilter previously specified");
if ( *s == '!' ){
} else {
vrFilter = s;
version = LDAP_VERSION3;
} else {
fprintf( stderr, "Invalid control name: %s\n", control );
case 'F': /* uri prefix */
if( urlpre ) free( urlpre );
urlpre = strdup( optarg );
......@@ -829,24 +875,56 @@ main( int argc, char **argv )
if ( manageDSAit ) {
if ( manageDSAit || valuesReturnFilter ) {
int err;
LDAPControl c;
LDAPControl *ctrls[2];
ctrls[0] = &c;
ctrls[1] = NULL;
int i=0;
LDAPControl c1,c2;
LDAPControl *ctrls[3];
if ( manageDSAit ) {
ctrls[i] = NULL;
c1.ldctl_value.bv_val = NULL;
c1.ldctl_value.bv_len = 0;
c1.ldctl_iscritical = manageDSAit > 1;
c.ldctl_value.bv_val = NULL;
c.ldctl_value.bv_len = 0;
c.ldctl_iscritical = manageDSAit > 1;
if ( valuesReturnFilter ) {
struct berval *bvalp;
ctrls[i] = NULL;
c2.ldctl_iscritical = valuesReturnFilter > 1;
if (( ber = ber_alloc_t(LBER_USE_DER)) == NULL )
if ( err = put_vrFilter(ber, vrFilter)==-1 ) {
ber_free( ber, 1 );
fprintf( stderr, "Bad ValuesReturnFilter: %s\n", vrFilter );
if ( ber_flatten( ber, &bvalp ) == LBER_ERROR )
err = ldap_set_option( ld, LDAP_OPT_SERVER_CONTROLS, ctrls );
ber_free( ber, 1 );
if( err != LDAP_OPT_SUCCESS ) {
fprintf( stderr, "Could not set ManageDSAit %scontrol\n",
c.ldctl_iscritical ? "critical " : "" );
if( c.ldctl_iscritical ) {
fprintf( stderr, "Could not set %scontrols\n",
(c1.ldctl_iscritical || c2.ldctl_iscritical)
? "critical " : "" );
if( c1.ldctl_iscritical && c2.ldctl_iscritical ) {
Tools ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
ldapdelete *CDE *HI*K M*OPQR U*WXYZ cdef*h**k *n*p* vwx*
ldapmodify *CDEF*HI*K M*OPQR U*WXYZabcdef*h**k *n*p*r t vwx*
ldapmodrdn *CDE *HI*K M*OPQR U*WXYZ cdef*h**k *n*p*rs vwx*
ldappasswd A*CDE *HI* *O QRS U*WXYZa de *h** * * * s vwx*
ldapsearch A*CDE *HI*KLM*OPQRSTU*WXYZab*def*h**kl*n*p* stuvwx*z
Other Clients ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
fax500 * f h m
finger * c f i l p t x
go500 I * bcd f l p t x
go500gw I P * a cd f h l p t x
mail500 C * d f h lm v
rcpt500 U* abc f h l p st z
rp500 * ab d f x z
ud D * cd f l p s uv
* reserved
* General flags:
-C Chase Referrals
-D Bind DN
-E CommandSpecific Extensions (e.g., -E <[!]oid[=options]>*)
-e General Extensions (e.g., -e <[!]oid[=options]>*)
-P protocol version
-V version information
-W prompt for bind password
-d debug
-h host
-n no-op
-p port
-v verbose
-w Bind password
* LDAPv3 Only
-x simple bind (not recommended excepting for
anonymous access, w/ -ZZ, or with ldaps://.
-M ManageDSAIT
-Z StartTLS
-Y SASL Mechanism (defaults to "best")
-R SASL Realm (defaults to empty)
-O SASL Security Options (defaults to "noanonymous,noplain")
-U SASL Authentication Identity (defaults to USER)
-X SASL Authorization Identity (defaults to empty)
-I SASL interactive mode (default: automatic)
-Q SASL quiet mode (default: automatic)
-K LDAPv2 Kerberos Bind (Step 1 only)
-k LDAPv2 Kerberos Bind
.TH LDAPDELETE 1 "13 November 1995" "U-M LDAP LDVERSION"
.TH LDAPDELETE 1 "20 August 2001" "OpenLDAP LDVERSION"
.\" $OpenLDAP$
.\" Copyright 1998-2002 The OpenLDAP Foundation All Rights Reserved.
.\" Copying restrictions apply. See COPYRIGHT/LICENSE.
ldapdelete \- ldap delete entry tool
ldapdelete \- LDAP delete entry tool
.B ldapdelete
.B [\-n]
.B [\-v]
.B [\-k]
.B [\-K]
.B [\-c]
.B [\-d debuglevel]
.B [\-f file]
.B [\-D binddn]
.B [\-w passwd]
.B [\-h ldaphost]
.B [\-p ldapport]
.B [dn]...
.BR \-n ]
.BR \-v ]
.BR \-k ]
.BR \-K ]
.BR \-c ]
.BR \-C ]
.BR \-M[M] ]
.BI \-d \ debuglevel\fR]
.BI \-f \ file\fR]
.BI \-D \ binddn\fR]
.BR \-W ]
.BI \-w \ passwd\fR]
.BI \-H \ ldapuri\fR]
.BI \-h \ ldaphost\fR]
.BI \-P \ 2\fR\||\|\fI3\fR]
.BI \-p \ ldapport\fR]
.BR \-O \ security-properties ]
.BI \-U \ authcid\fR]
.BR \-x ]
.BR \-I ]
.BR \-Q ]
.BI \-X \ authzid\fR]
.BI \-Y \ mech\fR]
.BR \-Z[Z] ]
.IR dn ]...
.I ldapdelete
is a shell-accessible interface to the
......@@ -23,9 +64,10 @@ library call.
.B ldapdelete
opens a connection to an LDAP server, binds, and deletes one or more
entries. If one or more \fIdn\fP arguments are provided, entries with
those Distinguished Names are deleted. Each \fIdn\fP should be a
string-represented DN as defined in RFC 1779. If no \fIdn\fP arguments
entries. If one or more \fIDN\fP arguments are provided, entries with
those Distinguished Names are deleted. Each \fIDN\fP should be provided
using the LDAPv3 string representation as defined in RFC 2253.
If no \fIdn\fP arguments
are provided, a list of DNs is read from standard input (or from
\fIfile\fP if the -f flag is used).
......@@ -38,16 +80,19 @@ debugging in conjunction with -v.
Use verbose mode, with many diagnostics written to standard output.
.B \-k
Use Kerberos authentication instead of simple authentication. It is
Use Kerberos IV authentication instead of simple authentication. It is
assumed that you already have a valid ticket granting ticket. This option
only has effect if
. B ldapdelete
is compiled with KERBEROS defined.
is compiled with Kerberos support.
.B \-K
Same as \-k, but only does step 1 of the kerberos bind. This is useful
Same as \-k, but only does step 1 of the Kerberos IV bind. This is useful
when connecting to a slapd and there is no x500dsa.hostname principal
registered with your kerberos servers.
registered with your Kerberos Domain Controller(s).
.B \-C
Automatically chase referrals.
.B \-c
Continuous operation mode. Errors are reported, but
......@@ -55,55 +100,110 @@ Continuous operation mode. Errors are reported, but
will continue with deletions. The default is to exit after
reporting an error.
.B \-d debuglevel
.B \-M[M]
Enable manage DSA IT control.
.B \-MM
makes control critical.
.BI \-d \ debuglevel
Set the LDAP debugging level to \fIdebuglevel\fP.
.B ldapdelete
must be compiled with LDAP_DEBUG defined for this option to have any effect.
.B \-f file
Read a series of lines from \fIfile\fP, performing one LDAP search for
each line. In this case, the \fIfilter\fP given on the command line
is treated as a pattern where the first occurrence of \fB%s\fP is
replaced with a line from \fIfile\fP.
.BI \-f \ file
Read a series of DNs from \fIfile\fP, one per line, performing an
LDAP delete for each.
.B \-x
Use simple authentication instead of SASL.
.BI \-D \ binddn
Use the Distinguished Name \fIbinddn\fP to bind to the LDAP directory.
.B \-D binddn
Use \fIbinddn\fP to bind to the X.500 directory. \fIbinddn\fP should be
a string-represented DN as defined in RFC 1779.
.B \-W
Prompt for simple authentication.
This is used instead of specifying the password on the command line.
.B \-w passwd
.BI \-w \ passwd
Use \fIpasswd\fP as the password for simple authentication.
.B \-h ldaphost
.BI \-H \ ldapuri
Specify URI(s) referring to the ldap server(s).
.BI \-h \ ldaphost
Specify an alternate host on which the ldap server is running.
Deprecated in favor of -H.
.B \-p ldapport
.BI \-p \ ldapport
Specify an alternate TCP port where the ldap server is listening.
Deprecated in favor of -H.
.BI \-P \ 2\fR\||\|\fI3
Specify the LDAP protocol version to use.
.B \-r
Do a recursive delete. If the DN specified isn't a leaf, its
children, and all their children are deleted down the tree. No
verification is done, so if you add this switch, ldapdelete will
happily delete large portions of your tree. Use with care.
.BI \-O \ security-properties
Specify SASL security properties.
.B \-I
Enable SASL Interactive mode. Always prompt. Default is to prompt
only as needed.
.B \-Q
Enable SASL Quiet mode. Never prompt.
.BI \-U \ authcid
Specify the authentication ID for SASL bind. The form of the identity depends on the
actual SASL mechanism used.
.BI \-X \ authzid
Specify the requested authorization ID for SASL bind.
.I authzid
must be one of the following formats:
.B dn:\c
.I <distinguished name>
.B u:\c
.I <username>
.BI \-Y \ mech
Specify the SASL mechanism to be used for authentication. If it's not
specified, the program will choose the best mechanism the server knows.
.B \-Z[Z]
Issue StartTLS (Transport Layer Security) extended operation. If you use
.B \-ZZ\c
, the command will require the operation to be successful.
The following command:
ldapdelete "cn=Delete Me, o=University of Michigan, c=US"
ldapdelete "cn=Delete Me,dc=example,dc=com"
will attempt to delete the entry named with commonName "Delete Me"
directly below the University of Michigan organizational entry. Of
course it would probably be necessary to supply a \fIbinddn\fP and
\fIpasswd\fP for deletion to be allowed (see the -D and -w options).
will attempt to delete the entry named "cn=Delete Me,dc=example,dc=com".
Of course it would probably be necessary to supply authentication
Exit status is 0 if no errors occur. Errors result in a non-zero exit
status and a diagnostic message being written to standard error.
.BR ldap.conf (5),
.BR ldapadd (1),
.BR ldapmodify (1),
.BR ldapmodrdn (1),
.BR ldapsearch (1),
.BR ldap (3),
.BR ldap_delete (3)
Kille, S.,
.IR "A String Representation of Distinguished Names",
ISODE Consortium, March 1995.
There is no interactive mode, but there probably should be.
The OpenLDAP Project <>
is developed and maintained by The OpenLDAP Project (
is derived from University of Michigan LDAP 3.3 Release.
......@@ -193,8 +193,7 @@ An invalid filter was supplied to ldap_search() (e.g., unbalanced
An ldap routine was called with a bad parameter (e.g., a NULL ld
pointer, etc.).
An ldap routine was called with a bad parameter.
An memory allocation (e.g., malloc(3) or other dynamic memory
......@@ -15,10 +15,8 @@ make it easy to tie an existing database to the
.B "This backend's calling conventions have changed since OpenLDAP 2.0."
The operations receive a new "opid:" (operation ID) line, to be used
instead of "msgid:".
The "msgid:" line will be removed in a future version.
Also, abandon now gets a new "abandonid:" line.
The abandon operation now gets a new "pid:" line.
The "msgid:" lines will be removed in a future version.
.B slapd.conf
......@@ -36,17 +34,15 @@ Each option is followed by the input lines that the program receives:
.B abandon <pathname> <argument>...
opid: <operation ID>
msgid: <message ID of operation to abandon>
<repeat { "suffix:" <database suffix DN> }>
abandonid: <operation ID of operation to abandon>
pid: <process ID of operation to abandon>
.B add <pathname> <argument>...
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
<entry in LDIF format>
......@@ -54,8 +50,7 @@ msgid: <message ID>
.B bind <pathname> <argument>...
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
method: <method number>
......@@ -66,8 +61,7 @@ cred: <credentials>
.B compare <pathname> <argument>...
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
<attribute>: <value>
......@@ -76,8 +70,7 @@ dn: <DN>
.B delete <pathname> <argument>...
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
......@@ -85,8 +78,7 @@ dn: <DN>
.B modify <pathname> <argument>...
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
<repeat {
......@@ -99,8 +91,7 @@ dn: <DN>
.B modrdn <pathname> <argument>...
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <DN>
newrdn: <new RDN>
......@@ -111,8 +102,7 @@ deleteoldrdn: <0 or 1>
.B search <pathname> <argument>...
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
base: <base DN>
scope: <0-2, see ldap.h>
......@@ -127,16 +117,11 @@ attrs: <"all" or space-separated attribute list>
.B unbind <pathname> <argument>...
opid: <operation ID>
msgid: <message ID>
msgid: <message id>
<repeat { "suffix:" <database suffix DN> }>
dn: <bound DN>
.I operation ID
is a "connection ID/message ID" string identifying an operation.
Note that you need only supply configuration lines for those commands you
want the backend to handle.
Operations for which a command is not supplied will be refused with an
......@@ -204,6 +204,22 @@ disables Start TLS from forcing session to anonymous status (see also
disables StartTLS if authenticated (see also
.BR tls_2_anon ).
.B gentlehup { on | off }
A SIGHUP signal will only cause a 'gentle' shutdown-attempt:
.B Slapd
will stop listening for new connections, but will not close the
connections to the current clients. It terminates when all clients
have closed their connections (if they ever do), or \- as before \-
if it receives a SIGTERM signal. This can be useful if you wish to
terminate the server and start a new
.B slapd
.B with another database,
without disrupting the currently active clients.
The default is off. You may wish to use
.B idletimeout
along with this option.
.B idletimeout <integer>
Specify the number of seconds to wait before forcibly closing
an idle client connection. A idletimeout of 0 disables this
......@@ -413,9 +413,8 @@ ldap_create_control(
LDAPControl *ctrl;
struct berval *bvalp;
if ( requestOID == NULL || ctrlp == NULL ) {
assert( requestOID != NULL );
assert( ctrlp != NULL );
ctrl = (LDAPControl *) LDAP_MALLOC( sizeof(LDAPControl) );
if ( ctrl == NULL ) {
/* $OpenLDAP$ */
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* locate LDAP servers using DNS SRV records.
* Location code based on MIT Kerberos KDC location code.
#include "portable.h"
#include <stdio.h>
#include <ac/stdlib.h>
#include <ac/param.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/time.h>
#include "ldap-int.h"
#include <arpa/nameser.h>
#include <resolv.h>
/* Sometimes this is not defined. */
#ifndef T_SRV
#define T_SRV 33