#include "portable.h"
#include <stdio.h>
#include <ac/socket.h>
#include <ac/string.h>
#include "slap.h"
#include "back-netinfo.h"
int
netinfo_back_referrals(
Backend *be,
Connection *conn,
Operation *op,
struct berval *dn,
struct berval *ndn,
const char **text )
{
struct dsinfo *di = (struct dsinfo *)be->be_private;
struct berval localDN;
#ifdef NO_NETINFO_REFERRALS
return LDAP_SUCCESS;
#endif
#ifdef NEW_LOGGING
LDAP_LOG(("backend", LDAP_LEVEL_ARGS, "netinfo_back_referrals DN %s\n", dn->bv_val));
#else
Debug(LDAP_DEBUG_TRACE, "==> netinfo_back_referrals dn=%s ndn=%s\n", dn->bv_val, ndn->bv_val, 0);
#endif
if (op->o_tag == LDAP_REQ_SEARCH)
{
#ifdef NEW_LOGGING
LDAP_LOG(("backend", LDAP_LEVEL_INFO, "netinfo_back_referrals: is search tag\n"));
#else
Debug(LDAP_DEBUG_TRACE, "<== netinfo_back_referrals\n", 0, 0, 0);
#endif
return LDAP_SUCCESS;
}
if (get_manageDSAit(op))
{
#ifdef NEW_LOGGING
LDAP_LOG(("backend", LDAP_LEVEL_INFO, "netinfo_back_referrals: manageDSAit control enabled\n"));
#else
Debug(LDAP_DEBUG_TRACE, "<== netinfo_back_referrals\n", 0, 0, 0);
#endif
return LDAP_SUCCESS;
}
if (netinfo_back_send_referrals(be, conn, op, ndn) == DSStatusOK)
{
#ifdef NEW_LOGGING
LDAP_LOG(("backend", LDAP_LEVEL_INFO, "netinfo_back_referrals: referred to children\n"));
#else
Debug(LDAP_DEBUG_TRACE, "<== netinfo_back_referrals (ref children)\n", 0, 0, 0);
#endif
return LDAP_SUCCESS;
}
if (dnMakeLocal(be, &localDN, ndn) == DSStatusPathNotLocal)
{
#ifdef NEW_LOGGING
LDAP_LOG(("backend", LDAP_LEVEL_INFO, "netinfo_back_referrals: referred to parent\n"));
#else
Debug(LDAP_DEBUG_TRACE, "<== netinfo_back_referrals (ref parent)\n", 0, 0, 0);
#endif
send_ldap_result(conn, op, LDAP_REFERRAL, NULL, NULL,
di->parent ? di->parent->refs : NULL, NULL);
}
else
{
if (localDN.bv_val != NULL)
ch_free(localDN.bv_val);
}
#ifdef NEW_LOGGING
LDAP_LOG(("backend", LDAP_LEVEL_INFO, "netinfo_back_referrals: done\n"));
#else
Debug(LDAP_DEBUG_TRACE, "<== netinfo_back_referrals (ref local)\n", 0, 0, 0);
#endif
return LDAP_SUCCESS;
}