-static int
-slapi_int_pblock_get_connection( Slapi_PBlock *pb, Operation *op )
-{
- char *connDn = NULL;
- Connection *conn = op->o_conn;
-
- slapi_pblock_get( pb, SLAPI_X_CONN_SSF, (void **)&conn->c_ssf );
- slapi_pblock_get( pb, SLAPI_X_CONN_SASL_CONTEXT, (void **)&conn->c_sasl_authctx );
-
- if ( slapi_pblock_get( pb, SLAPI_CONN_DN, (void **)&connDn ) != 0 ||
- connDn == NULL ) {
- /* default to operation DN */
- conn->c_ndn = op->o_ndn;
- conn->c_dn = op->o_ndn;
- } else {
- /* NB: conn DN must be normalized */
- conn->c_ndn.bv_val = connDn;
- conn->c_ndn.bv_len = strlen( connDn );
-
- conn->c_dn = conn->c_ndn;
- }
-
- return LDAP_SUCCESS;
-}
-
-static int
-slapi_int_pblock_get_operation( Slapi_PBlock *pb, Operation *op, SlapReply *rs )
-{
- int isRoot = 0;
- int isUpdateDn = 0;
- char *requestorDn = NULL;
- struct berval targetDn = BER_BVNULL;
- LDAPControl **controls;
- int rc;
-
- /* All internal operations must specify a target DN */
- if ( slapi_pblock_get( pb, SLAPI_TARGET_DN, (void **)&targetDn.bv_val ) != 0 ||
- targetDn.bv_val == NULL ) {
- return LDAP_PARAM_ERROR;
- }
-
- targetDn.bv_len = strlen( targetDn.bv_val );
-
- rc = dnPrettyNormal( NULL, &targetDn, &op->o_req_dn, &op->o_req_ndn, NULL );
- if ( rc != LDAP_SUCCESS ) {
- return rc;
- }
-
- rc = slapi_int_pblock_get_backend( pb, op );
- if ( rc != LDAP_SUCCESS ) {
- return rc;
- }
-
- slapi_pblock_get( pb, SLAPI_REQUESTOR_ISROOT, (void **)&isRoot );
- slapi_pblock_get( pb, SLAPI_REQUESTOR_ISUPDATEDN, (void **)&isUpdateDn );
- /* NB: requestor DN must be normalized */
- slapi_pblock_get( pb, SLAPI_REQUESTOR_DN, (void **)&requestorDn );
-
- /* Default authorization identity for internal operations is root DN */
- if ( isRoot || requestorDn == NULL ) {
- op->o_dn = op->o_bd->be_rootdn;
- op->o_ndn = op->o_bd->be_rootndn;
- isRoot = 1;
- } else {
- op->o_ndn.bv_val = requestorDn;
- op->o_ndn.bv_len = strlen( requestorDn );
- op->o_dn = op->o_ndn;
- }
-
- if ( isRoot )
- slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot );
-
- rc = slapi_int_pblock_get_connection( pb, op );
- if ( rc != LDAP_SUCCESS ) {
- return rc;
- }
-
- slapi_pblock_get( pb, SLAPI_REQCONTROLS, (void **)&controls );
- rc = slapi_int_get_ctrls( op, rs, controls );
- if ( rc != LDAP_SUCCESS ) {
- return rs->sr_err;
- }
-
- return LDAP_SUCCESS;
-}
-
-int
-slapi_int_init_connection( Slapi_PBlock *pb,
- SlapReply *rs,
- int OpType,
- Connection **pConn )