repl_compare.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. #include "slapi-plugin.h"
  13. #include "repl.h"
  14. int
  15. legacy_preop_compare( Slapi_PBlock *pb )
  16. {
  17. int is_replicated_operation = 0;
  18. struct berval **referral = NULL;
  19. int return_code = 0;
  20. Slapi_DN *basesdn = NULL;
  21. slapi_pblock_get(pb, SLAPI_IS_REPLICATED_OPERATION, &is_replicated_operation);
  22. slapi_pblock_get(pb, SLAPI_COMPARE_TARGET_SDN, &basesdn);
  23. if (NULL == basesdn) {
  24. slapi_send_ldap_result(pb, LDAP_OPERATIONS_ERROR, NULL,
  25. "Null target DN", 0, NULL );
  26. return_code = 1; /* return 1 to prevent further search processing */
  27. goto bail;
  28. }
  29. referral = get_data_source(pb, basesdn, 1, NULL);
  30. if (NULL != referral && !is_replicated_operation)
  31. {
  32. /*
  33. * There is a copyingFrom in this entry or an ancestor.
  34. * Return a referral to the supplier, and we're all done.
  35. */
  36. slapi_send_ldap_result(pb, LDAP_REFERRAL, NULL, NULL, 0, referral);
  37. return_code = 1; /* return 1 to prevent further search processing */
  38. }
  39. slapi_ch_free((void**)&referral);
  40. bail:
  41. return return_code;
  42. }