static int sasl_sc_sasl2dn( Operation *op, SlapReply *rs )
{
	struct berval *ndn = op->o_callback->sc_private;

	if ( rs->sr_type != REP_SEARCH ) return LDAP_SUCCESS;

	/* We only want to be called once */
	if ( !BER_BVISNULL( ndn ) ) {
		op->o_tmpfree( ndn->bv_val, op->o_tmpmemctx );
		BER_BVZERO( ndn );

		Debug( LDAP_DEBUG_TRACE,
			"%s: slap_sc_sasl2dn: search DN returned more than 1 entry\n",
			op->o_log_prefix, 0, 0 );
		return LDAP_UNAVAILABLE; /* short-circuit the search */
	}

	ber_dupbv_x( ndn, &rs->sr_entry->e_nname, op->o_tmpmemctx );
	return LDAP_SUCCESS;
}
static int sasl_sc_sasl2dn( Operation *op, SlapReply *rs )
{
	struct berval *ndn = op->o_callback->sc_private;

	if ( rs->sr_type != REP_SEARCH ) return LDAP_SUCCESS;

	 
	if ( !BER_BVISNULL( ndn ) ) {
		op->o_tmpfree( ndn->bv_val, op->o_tmpmemctx );
		BER_BVZERO( ndn );

		Debug( LDAP_DEBUG_TRACE,
			"%s: slap_sc_sasl2dn: search DN returned more than 1 entry\n",
			op->o_log_prefix, 0, 0 );
		return LDAP_UNAVAILABLE;  
	}

	ber_dupbv_x( ndn, &rs->sr_entry->e_nname, op->o_tmpmemctx );
	return LDAP_SUCCESS;
}