1 /* txn.c - LDAP Transactions */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2006 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
22 #include <ac/socket.h>
23 #include <ac/string.h>
24 #include <ac/unistd.h>
32 const struct berval slap_EXOP_TXN_START = BER_BVC(LDAP_EXOP_X_TXN_START);
33 const struct berval slap_EXOP_TXN_END = BER_BVC(LDAP_EXOP_X_TXN_END);
36 Operation *op, SlapReply *rs )
40 if( op->ore_reqdata != NULL ) {
41 rs->sr_text = "no request data expected";
42 return LDAP_PROTOCOL_ERROR;
45 Statslog( LDAP_DEBUG_STATS, "%s TXN START\n",
46 op->o_log_prefix, 0, 0, 0, 0 );
48 op->o_bd = op->o_conn->c_authz_backend;
49 if( backend_check_restrictions( op, rs,
50 (struct berval *)&slap_EXOP_TXN_START ) != LDAP_SUCCESS )
55 bv = (struct berval *) ch_malloc( sizeof (struct berval) );
64 Operation *op, SlapReply *rs, LDAPControl *ctrl )
66 if ( !ctrl->ldctl_iscritical ) {
67 rs->sr_text = "txnSpec control must be marked critical";
68 return LDAP_PROTOCOL_ERROR;
71 rs->sr_text = "txnSpec control provided multiple times";
72 return LDAP_PROTOCOL_ERROR;
75 if ( ctrl->ldctl_value.bv_val == NULL ) {
76 rs->sr_text = "no transaction identifier provided";
77 return LDAP_PROTOCOL_ERROR;
79 if ( ctrl->ldctl_value.bv_len != 0 ) {
80 rs->sr_text = "invalid transaction identifier";
81 return LDAP_X_TXN_ID_INVALID;
84 op->o_txnSpec = SLAP_CONTROL_CRITICAL;
89 Operation *op, SlapReply *rs )
91 if( op->ore_reqdata == NULL ) {
92 rs->sr_text = "request data expected";
93 return LDAP_PROTOCOL_ERROR;
96 Statslog( LDAP_DEBUG_STATS, "%s TXN END\n",
97 op->o_log_prefix, 0, 0, 0, 0 );
99 op->o_bd = op->o_conn->c_authz_backend;
100 if( backend_check_restrictions( op, rs,
101 (struct berval *)&slap_EXOP_TXN_END ) != LDAP_SUCCESS )
106 rs->sr_text = "not yet implemented";
107 return LDAP_UNWILLING_TO_PERFORM;
110 #endif /* LDAP_X_TXN */