#include <stdio.h>
#include <ac/socket.h>
+#include <ac/string.h>
#include "slap.h"
SLAP_EXTOP_MAIN_FN *ext_main;
} *supp_ext_list = NULL;
+static SLAP_EXTOP_MAIN_FN whoami_extop;
+
/* this list of built-in extops is for extops that are not part
* of backends or in external modules. essentially, this is
* just a way to get built-in extops onto the extop list without
#ifdef HAVE_TLS
{ LDAP_EXOP_START_TLS, starttls_extop },
#endif
- { LDAP_EXOP_X_MODIFY_PASSWD, passwd_extop },
+ { LDAP_EXOP_MODIFY_PASSWD, passwd_extop },
+ { LDAP_EXOP_X_WHO_AM_I, whoami_extop },
{ NULL, NULL }
};
ber_len_t len;
struct extop_list *ext;
const char *text;
- BVarray refs;
+ BerVarray refs;
char *rspoid;
struct berval *rspdata;
LDAPControl **rspctrls;
send_ldap_extended( conn, op, rc, NULL, text, refs,
rspoid, rspdata, rspctrls );
- bvarray_free( refs );
+ ber_bvarray_free( refs );
}
if ( rspoid != NULL ) {
free( rspoid );
}
- if ( rspdata != NULL )
+ if ( rspdata != NULL ) {
ber_bvfree( rspdata );
+ }
done:
if ( reqdata != NULL ) {
}
return(NULL);
}
+
+
+int
+whoami_extop (
+ Connection *conn,
+ Operation *op,
+ const char * reqoid,
+ struct berval * reqdata,
+ char ** rspoid,
+ struct berval ** rspdata,
+ LDAPControl ***rspctrls,
+ const char ** text,
+ BerVarray * refs )
+{
+ struct berval *bv;
+
+ if ( reqdata != NULL ) {
+ /* no request data should be provided */
+ *text = "no request data expected";
+ return LDAP_PROTOCOL_ERROR;
+ }
+
+ bv = (struct berval *) ch_malloc( sizeof(struct berval) );
+ if( op->o_dn.bv_len ) {
+ bv->bv_len = op->o_dn.bv_len + sizeof("dn:")-1;
+ bv->bv_val = ch_malloc( bv->bv_len + 1 );
+ AC_MEMCPY( bv->bv_val, "dn:", sizeof("dn:")-1 );
+ AC_MEMCPY( &bv->bv_val[sizeof("dn:")-1], op->o_dn.bv_val,
+ op->o_dn.bv_len );
+ bv->bv_val[bv->bv_len] = '\0';
+
+ } else {
+ bv->bv_len = 0;
+ bv->bv_val = NULL;
+ }
+
+ *rspdata = bv;
+ return LDAP_SUCCESS;
+}
\ No newline at end of file