repl_rootdse.c 2.2 KB

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