char ldctl_iscritical;
} LDAPControl;
-/* LDAP "Standard" Controls */
-
+/* LDAP Controls */
/* chase referrals controls */
#define LDAP_CONTROL_REFERRALS "1.2.840.113666.1.4.616"
#define LDAP_CHASE_SUBORDINATE_REFERRALS 0x0020
#define LDAP_CHASE_EXTERNAL_REFERRALS 0x0040
-/* LDAP "Extension" Controls */
+/* LDAP Unsolicited Notifications */
+#define LDAP_NOTICE_DISCONNECT "1.3.6.1.4.1.1466.20036"
-/* LDAP "Private/Experiemental" Controls */
+/* LDAP Extended Operations */
/*
* possible error codes we can return
*/
+#define LDAP_RANGE(n,x,y) (((x) >= (n)) && ((n) <= (y)))
+
#define LDAP_SUCCESS 0x00
#define LDAP_OPERATIONS_ERROR 0x01
#define LDAP_PROTOCOL_ERROR 0x02
#define LDAP_CONFIDENTIALITY_REQUIRED 0x0d /* LDAPv3 */
#define LDAP_SASL_BIND_IN_PROGRESS 0x0e /* LDAPv3 */
+#define LDAP_ATTR_ERROR(n) LDAP_RANGE((n),0x10,0x15) /* 16-21 */
+
#define LDAP_NO_SUCH_ATTRIBUTE 0x10
#define LDAP_UNDEFINED_TYPE 0x11
#define LDAP_INAPPROPRIATE_MATCHING 0x12
#define LDAP_TYPE_OR_VALUE_EXISTS 0x14
#define LDAP_INVALID_SYNTAX 0x15
+#define LDAP_NAME_ERROR(n) LDAP_RANGE((n),0x20,0x24) /* 32-34,36 */
+
#define LDAP_NO_SUCH_OBJECT 0x20
#define LDAP_ALIAS_PROBLEM 0x21
#define LDAP_INVALID_DN_SYNTAX 0x22
#define LDAP_IS_LEAF 0x23 /* not LDAPv3 */
#define LDAP_ALIAS_DEREF_PROBLEM 0x24
-#define LDAP_NAME_ERROR(n) (((int)(n) & 0x00f0) == 0x0020)
+#define LDAP_SECURITY_ERROR(n) LDAP_RANGE((n),0x30,0x32) /* 48-50 */
#define LDAP_INAPPROPRIATE_AUTH 0x30
#define LDAP_INVALID_CREDENTIALS 0x31
#define LDAP_INSUFFICIENT_ACCESS 0x32
+
+#define LDAP_SERVICE_ERROR(n) LDAP_RANGE((n),0x33,0x36) /* 51-54 */
+
#define LDAP_BUSY 0x33
#define LDAP_UNAVAILABLE 0x34
#define LDAP_UNWILLING_TO_PERFORM 0x35
#define LDAP_LOOP_DETECT 0x36
+#define LDAP_UPDATE_ERROR(n) LDAP_RANGE((n),0x40,0x47) /* 64-69,71 */
+
#define LDAP_NAMING_VIOLATION 0x40
#define LDAP_OBJECT_CLASS_VIOLATION 0x41
#define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42
#define LDAP_RESULTS_TOO_LARGE 0x46 /* CLDAP */
#define LDAP_AFFECTS_MULTIPLE_DSAS 0x47 /* LDAPv3 */
-#define LDAP_CLIENT_ERROR(n) ( (int)(n) >= 0x50 )
-
#define LDAP_OTHER 0x50
+
+#define LDAP_API_ERROR(n) LDAP_RANGE((n),0x51,0xff) /* 81+ */
+
#define LDAP_SERVER_DOWN 0x51
#define LDAP_LOCAL_ERROR 0x52
#define LDAP_ENCODING_ERROR 0x53
#include "slap.h"
-void
+int
do_abandon(
Connection *conn,
Operation *op
ber_int_t id;
Operation *o;
Operation **oo;
+ int rc;
Debug( LDAP_DEBUG_TRACE, "do_abandon\n", 0, 0, 0 );
if ( ber_scanf( op->o_ber, "i", &id ) == LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "do_abandon: ber_scanf failed\n", 0, 0 ,0 );
- return;
+ return LDAP_PROTOCOL_ERROR;
}
#ifdef GET_CTRLS
- if( get_ctrls( conn, op, 0 ) == -1 ) {
+ if( (rc = get_ctrls( conn, op, 0 )) != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "do_abandon: get_ctrls failed\n", 0, 0 ,0 );
- return;
+ return rc;
}
#endif
found_it:
ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+ return LDAP_SUCCESS;
}
static void add_created_attrs(Operation *op, Entry *e);
-void
+int
do_add( Connection *conn, Operation *op )
{
BerElement *ber = op->o_ber;
ber_tag_t tag;
Entry *e;
Backend *be;
+ int rc = LDAP_SUCCESS;
Debug( LDAP_DEBUG_TRACE, "do_add\n", 0, 0, 0 );
Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
"decoding error" );
- return;
+ return LDAP_PROTOCOL_ERROR;
}
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
NULL, "decoding error" );
entry_free( e );
- return;
+ return LDAP_PROTOCOL_ERROR;
}
if ( vals == NULL ) {
NULL );
free( type );
entry_free( e );
- return;
+ return LDAP_PROTOCOL_ERROR;
}
attr_merge( e, type, vals );
Debug( LDAP_DEBUG_ANY, "do_add: ber_scanf failed\n", 0, 0, 0 );
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
"decoding error" );
- return;
+ return LDAP_PROTOCOL_ERROR;
}
#ifdef GET_CTRLS
- if( get_ctrls( conn, op, 1 ) == -1 ) {
+ if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
entry_free( e );
Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
- return;
+ return rc;
}
#endif
entry_free( e );
send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
default_referral );
- return;
+ return rc;
}
/*
} else {
entry_free( e );
- send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS, NULL,
default_referral );
}
} else {
Debug( LDAP_DEBUG_ARGS, " do_add: HHH\n", 0, 0, 0 );
entry_free( e );
- send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
+ send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL,
"Function not implemented" );
}
+
+ return rc;
}
static void
#include "slap.h"
-void
+char *supportedSASLMechanisms[] = {
+ "X-CRAM-MD5",
+ "X-DIGEST-MD5",
+ NULL
+};
+
+int
do_bind(
Connection *conn,
Operation *op
ber_tag_t method;
char *mech;
char *cdn, *ndn;
- ber_tag_t rc;
+ ber_tag_t tag;
+ int rc;
struct berval cred;
Backend *be;
* }
*/
- rc = ber_scanf( ber, "{iat" /*}*/, &version, &cdn, &method );
+ tag = ber_scanf( ber, "{iat" /*}*/, &version, &cdn, &method );
- if ( rc == LBER_ERROR ) {
+ if ( tag == LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "bind: ber_scanf failed\n", 0, 0, 0 );
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL,
"decoding error" );
goto cleanup;
}
if( method != LDAP_AUTH_SASL ) {
- rc = ber_scanf( ber, /*{*/ "o}", &cred );
+ tag = ber_scanf( ber, /*{*/ "o}", &cred );
} else {
- rc = ber_scanf( ber, "{a" /*}*/, &mech );
+ tag = ber_scanf( ber, "{a" /*}*/, &mech );
- if ( rc != LBER_ERROR ) {
+ if ( tag != LBER_ERROR ) {
ber_len_t len;
- rc = ber_peek_tag( ber, &len );
+ tag = ber_peek_tag( ber, &len );
- if ( rc == LDAP_TAG_LDAPCRED ) {
- rc = ber_scanf( ber, "o", &cred );
+ if ( tag == LDAP_TAG_LDAPCRED ) {
+ tag = ber_scanf( ber, "o", &cred );
}
- if ( rc != LBER_ERROR ) {
- rc = ber_scanf( ber, /*{{*/ "}}" );
+ if ( tag != LBER_ERROR ) {
+ tag = ber_scanf( ber, /*{{*/ "}}" );
}
}
}
- if ( rc == LBER_ERROR ) {
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
+ if ( tag == LBER_ERROR ) {
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL,
"decoding error" );
goto cleanup;
}
#ifdef GET_CTRLS
- if( get_ctrls( conn, op, 1 ) == -1 ) {
+ if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "do_bind: get_ctrls failed\n", 0, 0, 0 );
goto cleanup;
}
if ( version < LDAP_VERSION_MIN || version > LDAP_VERSION_MAX ) {
Debug( LDAP_DEBUG_ANY, "unknown version %d\n", version, 0, 0 );
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL,
"version not supported" );
goto cleanup;
}
if ( version < LDAP_VERSION3 ) {
Debug( LDAP_DEBUG_ANY, "do_bind: sasl with LDAPv%d\n",
version, 0, 0 );
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL,
"sasl bind requires LDAPv3" );
goto cleanup;
}
Debug( LDAP_DEBUG_ANY,
"do_bind: no sasl mechanism provided\n",
version, 0, 0 );
- /* XXYYZ need to check this return code */
- send_ldap_result( conn, op, LDAP_AUTH_METHOD_NOT_SUPPORTED,
- NULL, "no sasl mechanism provided." );
+ send_ldap_result( conn, op, rc = LDAP_AUTH_METHOD_NOT_SUPPORTED,
+ NULL, "no sasl mechanism provided" );
goto cleanup;
}
- if( 1 ) {
+ if( !charray_inlist( supportedSASLMechanisms, mech ) ) {
Debug( LDAP_DEBUG_ANY,
"do_bind: sasl mechanism \"%s\" not supported.\n",
mech, 0, 0 );
- /* XXYYZ need to check this return code */
- send_ldap_result( conn, op, LDAP_AUTH_METHOD_NOT_SUPPORTED,
- NULL, "no sasl mechanism provided." );
+ send_ldap_result( conn, op, rc = LDAP_AUTH_METHOD_NOT_SUPPORTED,
+ NULL, "sasl mechanism not supported" );
goto cleanup;
}
}
send_ldap_result( conn, op, LDAP_SUCCESS,
NULL, NULL );
} else if ( default_referral && *default_referral ) {
- send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS,
+ send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS,
NULL, default_referral );
} else {
- send_ldap_result( conn, op, LDAP_INVALID_CREDENTIALS,
+ send_ldap_result( conn, op, rc = LDAP_INVALID_CREDENTIALS,
NULL, default_referral );
}
+
goto cleanup;
}
}
} else {
- send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
+ send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL,
"Function not implemented" );
}
if ( cred.bv_val != NULL ) {
free( cred.bv_val );
}
+
+ return rc;
}
#include "slap.h"
-void
+int
do_compare(
Connection *conn,
Operation *op
char *ndn;
Ava ava;
Backend *be;
+ int rc = LDAP_SUCCESS;
Debug( LDAP_DEBUG_TRACE, "do_compare\n", 0, 0, 0 );
if ( ber_scanf( op->o_ber, "{a{ao}}", &ndn, &ava.ava_type,
&ava.ava_value ) == LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
- return;
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL, "" );
+ return rc;
}
#ifdef GET_CTRLS
- if( get_ctrls( conn, op, 1 ) == -1 ) {
+ if( ( rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
free( ndn );
ava_free( &ava, 0 );
Debug( LDAP_DEBUG_ANY, "do_compare: get_ctrls failed\n", 0, 0, 0 );
- return;
+ return rc;
}
#endif
free( ndn );
ava_free( &ava, 0 );
- send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS, NULL,
default_referral );
- return;
+ return 1;
}
/* alias suffix if approp */
if ( be->be_compare ) {
(*be->be_compare)( be, conn, op, ndn, &ava );
} else {
- send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
+ send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL,
"Function not implemented" );
}
free( ndn );
ava_free( &ava, 0 );
+
+ return rc;
}
#include "slap.h"
-void
+int
do_delete(
Connection *conn,
Operation *op
{
char *ndn;
Backend *be;
+ int rc;
Debug( LDAP_DEBUG_TRACE, "do_delete\n", 0, 0, 0 );
if ( ber_scanf( op->o_ber, "a", &ndn ) == LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
- return;
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL, "" );
+ return rc;
}
#ifdef GET_CTRLS
- if( get_ctrls( conn, op, 1 ) == -1 ) {
+ if( ( rc = get_ctrls( conn, op, 1 ) ) != LDAP_SUCCESS ) {
free( ndn );
Debug( LDAP_DEBUG_ANY, "do_add: get_ctrls failed\n", 0, 0, 0 );
- return;
+ return rc;
}
#endif
*/
if ( (be = select_backend( ndn )) == NULL ) {
free( ndn );
- send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS, NULL,
default_referral );
- return;
+ return rc;
}
/* alias suffix if approp */
replog( be, LDAP_REQ_DELETE, ndn, NULL, 0 );
}
} else {
- send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS, NULL,
default_referral );
}
} else {
- send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
+ send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL,
"Function not implemented" );
}
free( ndn );
+ return rc;
}
static void modlist_free(LDAPModList *ml);
-void
+int
do_modify(
Connection *conn,
Operation *op
LDAPModList *tmp;
#endif
Backend *be;
+ int rc;
Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
if ( ber_scanf( op->o_ber, "{a" /*}*/, &ndn ) == LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
- return;
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL, "" );
+ return rc;
}
Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", ndn, 0, 0 );
&(*modtail)->ml_type, &(*modtail)->ml_bvalues )
== LBER_ERROR )
{
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL,
"decoding error" );
free( ndn );
free( *modtail );
*modtail = NULL;
modlist_free( modlist );
- return;
+ return rc;
}
(*modtail)->ml_op = mop;
(*modtail)->ml_op != LDAP_MOD_DELETE &&
(*modtail)->ml_op != LDAP_MOD_REPLACE )
{
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL,
"unrecognized modify operation" );
free( ndn );
modlist_free( modlist );
- return;
+ return rc;
}
if ( (*modtail)->ml_bvalues == NULL
&& (*modtail)->ml_op != LDAP_MOD_DELETE )
{
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL,
"no values given" );
free( ndn );
modlist_free( modlist );
- return;
+ return rc;
}
attr_normalize( (*modtail)->ml_type );
#endif
#ifdef GET_CTRLS
- if( get_ctrls( conn, op, 1 ) == -1 ) {
+ if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
free( ndn );
modlist_free( modlist );
Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
- return;
+ return rc;
}
#endif
if ( (be = select_backend( ndn )) == NULL ) {
free( ndn );
modlist_free( modlist );
- send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS, NULL,
default_referral );
- return;
+ return rc;
}
/* alias suffix if approp */
/* send a referral */
} else {
- send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS, NULL,
default_referral );
}
} else {
- send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
+ send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL,
"Function not implemented" );
}
free( ndn );
modlist_free( modlist );
+ return rc;
}
static void
#include "slap.h"
-void
+int
do_modrdn(
Connection *conn,
Operation *op
char *nnewSuperior = NULL;
Backend *newSuperior_be = NULL;
ber_len_t length;
+ int rc;
Debug( LDAP_DEBUG_TRACE, "do_modrdn\n", 0, 0, 0 );
if ( ber_scanf( op->o_ber, "{aab", &ndn, &newrdn, &deloldrdn )
== LBER_ERROR ) {
Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
- return;
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL, "" );
+ return rc;
}
/* Check for newSuperior parameter, if present scan it */
if ( ber_peek_tag( op->o_ber, &length ) == LDAP_TAG_NEWSUPERIOR ) {
- if ( op->o_protocol == 0 ) {
+ if ( op->o_protocol == 0 ) {
/*
* Promote to LDAPv3
*/
Debug( LDAP_DEBUG_ANY,
"modrdn(v2): invalid field newSuperior!\n",
0, 0, 0 );
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR,
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR,
NULL, "" );
- return;
+ return rc;
}
if ( ber_scanf( op->o_ber, "a", &newSuperior )
Debug( LDAP_DEBUG_ANY, "ber_scanf(\"a\"}) failed\n",
0, 0, 0 );
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL,
"" );
- return;
+ return rc;
}
free( newrdn );
free( newSuperior );
Debug( LDAP_DEBUG_ANY, "do_modrdn: ber_scanf failed\n", 0, 0, 0 );
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL,
"decoding error" );
- return;
+ return rc;
}
#ifdef GET_CTRLS
- if( get_ctrls( conn, op, 1 ) == -1 ) {
+ if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
free( ndn );
free( newrdn );
free( newSuperior );
Debug( LDAP_DEBUG_ANY, "do_modrdn: get_ctrls failed\n", 0, 0, 0 );
- return;
+ return rc;
}
#endif
free( nnewSuperior );
send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
default_referral );
- return;
+ return 0;
}
}
free( newrdn );
free( newSuperior );
free( nnewSuperior );
- send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS, NULL,
default_referral );
- return;
+ return rc;
}
/* Make sure that the entry being changed and the newSuperior are in
free( newSuperior );
free( nnewSuperior );
- send_ldap_result( conn, op, LDAP_AFFECTS_MULTIPLE_DSAS,
+ send_ldap_result( conn, op, rc = LDAP_AFFECTS_MULTIPLE_DSAS,
NULL, "" );
- return;
+ return rc;
}
{
if ( (*be->be_modrdn)( be, conn, op, ndn, newrdn,
deloldrdn, newSuperior ) == 0 ) {
- /* XXX: MAY NEEED TO ADD newSuperior HERE */
+ /* XXX: MAY NEED TO ADD newSuperior HERE */
replog( be, LDAP_REQ_MODRDN, ndn, newrdn,
deloldrdn );
}
} else {
- send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS, NULL,
default_referral );
}
} else {
- send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
+ send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL,
"Function not implemented" );
}
free( newrdn );
free( newSuperior );
free( nnewSuperior );
+ return rc;
}
#include "ldap_defaults.h"
#include "slap.h"
+char *supportedControls[] = {
+ NULL
+};
+
+char *supportedExtensions[] = {
+ NULL
+};
+
#if defined( SLAPD_MONITOR_DN )
void
/*
* monitor.c
*/
+extern char *supportedExtensions[];
+extern char *supportedControls[];
+extern char *supportedSASLMechanisms[];
void monitor_info LDAP_P(( Connection *conn, Operation *op ));
extern void config_info LDAP_P((Connection *conn, Operation *op));
extern void root_dse_info LDAP_P((Connection *conn, Operation *op, char **attrs, int attrsonly));
-extern void do_abandon LDAP_P((Connection *conn, Operation *op));
-extern void do_add LDAP_P((Connection *conn, Operation *op));
-extern void do_bind LDAP_P((Connection *conn, Operation *op));
-extern void do_compare LDAP_P((Connection *conn, Operation *op));
-extern void do_delete LDAP_P((Connection *conn, Operation *op));
-extern void do_modify LDAP_P((Connection *conn, Operation *op));
-extern void do_modrdn LDAP_P((Connection *conn, Operation *op));
-extern void do_search LDAP_P((Connection *conn, Operation *op));
-extern void do_unbind LDAP_P((Connection *conn, Operation *op));
+
+extern int do_abandon LDAP_P((Connection *conn, Operation *op));
+extern int do_add LDAP_P((Connection *conn, Operation *op));
+extern int do_bind LDAP_P((Connection *conn, Operation *op));
+extern int do_compare LDAP_P((Connection *conn, Operation *op));
+extern int do_delete LDAP_P((Connection *conn, Operation *op));
+extern int do_modify LDAP_P((Connection *conn, Operation *op));
+extern int do_modrdn LDAP_P((Connection *conn, Operation *op));
+extern int do_search LDAP_P((Connection *conn, Operation *op));
+extern int do_unbind LDAP_P((Connection *conn, Operation *op));
+extern int do_exop LDAP_P((Connection *conn, Operation *op));
extern int send_search_entry LDAP_P((Backend *be, Connection *conn, Operation *op, Entry *e, char **attrs, int attrsonly));
extern int str2result LDAP_P(( char *s, int *code, char **matched, char **info ));
ber_tag_t tag;
ber_len_t bytes;
+ assert( !LDAP_API_ERROR( err ) );
+
if ( err == LDAP_PARTIAL_RESULTS && (text == NULL || *text == '\0') )
err = LDAP_NO_SUCH_OBJECT;
char *text
)
{
+ assert( !LDAP_API_ERROR( err ) );
+
#ifdef LDAP_CONNECTIONLESS
if ( op->o_cldap ) {
ber_pvt_sb_udp_set_dst( &conn->c_sb, &op->o_clientaddr );
#endif
#if defined( SLAPD_SCHEMA_DN )
- val.bv_val = ch_strdup( SLAPD_SCHEMA_DN );
+ strcpy( buf, SLAPD_SCHEMA_DN );
+ val.bv_val = buf;
val.bv_len = strlen( val.bv_val );
attr_merge( e, "namingContexts", vals );
attr_merge( e, "subschemaSubentry", vals );
#endif
/* altServer unsupported */
- /* supportedExtension: no extensions supported */
- /* supportedControl: no controls supported */
- /* supportedSASLMechanism: not yet */
+ /* supportedControl */
+ for ( i=0; supportedControls[i] != NULL; i++ ) {
+ strcpy( buf, supportedControls[i] );
+ val.bv_val = buf;
+ val.bv_len = strlen( buf );
+ attr_merge( e, "supportedControl", vals );
+ }
+
+ /* supportedExtension */
+ for ( i=0; supportedExtensions[i] != NULL; i++ ) {
+ strcpy( buf, supportedExtensions[i] );
+ val.bv_val = buf;
+ val.bv_len = strlen( buf );
+ attr_merge( e, "supportedExtension", vals );
+ }
+
+ /* supportedLDAPVersion */
for ( i=LDAP_VERSION_MIN; i<=LDAP_VERSION_MAX; i++ ) {
sprintf(buf,"%d",i);
val.bv_val = buf;
val.bv_len = strlen( buf );
attr_merge( e, "supportedLDAPVersion", vals );
}
-
+
+ /* supportedSASLMechanism */
+ for ( i=0; supportedSASLMechanisms[i] != NULL; i++ ) {
+ strcpy( buf, supportedSASLMechanisms[i] );
+ val.bv_val = buf;
+ val.bv_len = strlen( buf );
+ attr_merge( e, "supportedSASLMechanism", vals );
+ }
+
+
send_search_entry( &backends[0], conn, op, e, attrs, attrsonly );
send_ldap_search_result( conn, op, LDAP_SUCCESS, NULL, NULL, 1 );
#include "slap.h"
-void
+int
do_search(
Connection *conn, /* where to send results */
Operation *op /* info about the op to which we're responding */
Filter *filter = NULL;
char **attrs = NULL;
Backend *be;
+ int rc;
Debug( LDAP_DEBUG_TRACE, "do_search\n", 0, 0, 0 );
*/
/* baseObject, scope, derefAliases, sizelimit, timelimit, attrsOnly */
- if ( ber_scanf( op->o_ber, "{aiiiib", &base, &scope, &deref, &sizelimit,
+ if ( ber_scanf( op->o_ber, "{aiiiib",
+ &base, &scope, &deref, &sizelimit,
&timelimit, &attrsonly ) == LBER_ERROR ) {
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL, "" );
goto return_results;
}
+
if ( scope != LDAP_SCOPE_BASE && scope != LDAP_SCOPE_ONELEVEL
&& scope != LDAP_SCOPE_SUBTREE ) {
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL,
"Unknown search scope" );
goto return_results;
}
/* attributes */
if ( ber_scanf( op->o_ber, /*{*/ "{v}}", &attrs ) == LBER_ERROR ) {
- send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL, "" );
+ send_ldap_result( conn, op, rc = LDAP_PROTOCOL_ERROR, NULL, "" );
goto return_results;
}
#ifdef GET_CTRLS
- if( get_ctrls( conn, op, 1 ) == -1 ) {
+ if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "do_search: get_ctrls failed\n", 0, 0, 0 );
goto return_results;
}
#endif
+ rc = 0;
+
Debug( LDAP_DEBUG_ARGS, " attrs:", 0, 0, 0 );
if ( attrs != NULL ) {
* if we don't hold it.
*/
if ( (be = select_backend( base )) == NULL ) {
- send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
+ send_ldap_result( conn, op, rc = LDAP_PARTIAL_RESULTS, NULL,
default_referral );
goto return_results;
(*be->be_search)( be, conn, op, base, scope, deref, sizelimit,
timelimit, filter, fstr, attrs, attrsonly );
} else {
- send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, NULL,
+ send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM, NULL,
"Function not implemented" );
}
if ( attrs != NULL ) {
charray_free( attrs );
}
+
+ return rc;
}
#include "slap.h"
-void
+int
do_unbind(
Connection *conn,
Operation *op
/* pass the unbind to all backends */
backend_unbind( conn, op );
+
+ return 0;
}