cb_acl.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright 2001 Sun Microsystems, Inc.
  3. * Portions copyright 1999, 2001-2003 Netscape Communications Corporation.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. #include "cb.h"
  7. /*
  8. ** generic function to send back results
  9. ** Turn off acl eval on front-end when needed
  10. */
  11. void cb_set_acl_policy(Slapi_PBlock *pb) {
  12. Slapi_Backend *be;
  13. cb_backend_instance *cb;
  14. int noacl;
  15. slapi_pblock_get( pb, SLAPI_BACKEND, &be );
  16. cb = cb_get_instance(be);
  17. /* disable acl checking if the local_acl flag is not set
  18. or if the associated backend is disabled */
  19. noacl=!(cb->local_acl) || cb->associated_be_is_disabled;
  20. if (noacl) {
  21. slapi_pblock_set(pb, SLAPI_PLUGIN_DB_NO_ACL, &noacl);
  22. } else {
  23. /* Be very conservative about acl evaluation */
  24. slapi_pblock_set(pb, SLAPI_PLUGIN_DB_NO_ACL, &noacl);
  25. }
  26. }
  27. int cb_access_allowed(
  28. Slapi_PBlock *pb,
  29. Slapi_Entry *e, /* The Slapi_Entry */
  30. char *attr, /* Attribute of the entry */
  31. struct berval *val, /* value of attr. NOT USED */
  32. int access, /* access rights */
  33. char **errbuf
  34. )
  35. {
  36. switch (access) {
  37. case SLAPI_ACL_ADD:
  38. case SLAPI_ACL_DELETE:
  39. case SLAPI_ACL_COMPARE:
  40. case SLAPI_ACL_WRITE:
  41. case SLAPI_ACL_PROXY:
  42. /* Keep in mind some entries are NOT */
  43. /* available for acl evaluation */
  44. return slapi_access_allowed(pb,e,attr,val,access);
  45. default:
  46. return LDAP_INSUFFICIENT_ACCESS;
  47. }
  48. }