repl_rootdse.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. * END COPYRIGHT BLOCK **/
  6. #include <string.h>
  7. #include "repl.h"
  8. #include "cl4.h"
  9. #include "slapi-plugin.h"
  10. /* Forward Declartions */
  11. static int repl_rootdse_search (Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg);
  12. int
  13. repl_rootdse_init()
  14. {
  15. /* The FE DSE *must* be initialised before we get here */
  16. int return_value= LDAP_SUCCESS;
  17. slapi_config_register_callback(SLAPI_OPERATION_SEARCH,DSE_FLAG_PREOP,"",LDAP_SCOPE_BASE,"(objectclass=*)",repl_rootdse_search,NULL);
  18. return return_value;
  19. }
  20. static int
  21. repl_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg)
  22. {
  23. #if 0
  24. struct berval val;
  25. struct berval *vals[2];
  26. vals[0] = &val;
  27. vals[1] = NULL;
  28. /* machine data suffix */
  29. val.bv_val = REPL_CONFIG_TOP;
  30. val.bv_len = strlen( val.bv_val );
  31. slapi_entry_attr_replace( e, ATTR_NETSCAPEMDSUFFIX, vals );
  32. /* Changelog information */
  33. /* ONREPL because we now support multiple 4.0 changelogs we no longer publish
  34. info in the rootdse */
  35. if ( get_repl_backend() != NULL )
  36. {
  37. char buf[BUFSIZ];
  38. changeNumber cnum;
  39. /* Changelog suffix */
  40. val.bv_val = changelog4_get_suffix ();
  41. if ( val.bv_val != NULL )
  42. {
  43. val.bv_len = strlen( val.bv_val );
  44. slapi_entry_attr_replace( e, "changelog", vals );
  45. }
  46. slapi_ch_free ((void **)&val.bv_val);
  47. /* First change number contained in log */
  48. cnum = ldapi_get_first_changenumber();
  49. sprintf( buf, "%lu", cnum );
  50. val.bv_val = buf;
  51. val.bv_len = strlen( val.bv_val );
  52. slapi_entry_attr_replace( e, "firstchangenumber", vals );
  53. /* Last change number contained in log */
  54. cnum = ldapi_get_last_changenumber();
  55. sprintf( buf, "%lu", cnum );
  56. val.bv_val = buf;
  57. val.bv_len = strlen( val.bv_val );
  58. slapi_entry_attr_replace( e, "lastchangenumber", vals );
  59. }
  60. #endif
  61. return SLAPI_DSE_CALLBACK_OK;
  62. }