cb_schema.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. void cb_eliminate_illegal_attributes(cb_backend_instance * inst, Slapi_Entry * e) {
  8. /* get rid of illegal attributes before sending op to the */
  9. /* farm server. (Add) */
  10. int rc,j;
  11. Slapi_Attr *attr=NULL;
  12. char *tobefreed=NULL;
  13. if (inst->illegal_attributes != NULL ) { /* Unlikely to happen */
  14. PR_RWLock_Wlock(inst->rwl_config_lock);
  15. for (j=0; inst->illegal_attributes[j]; j++) {
  16. char * aType=NULL;
  17. rc=slapi_entry_first_attr(e,&attr);
  18. while (rc==0) {
  19. if (tobefreed) {
  20. slapi_entry_attr_delete( e, tobefreed);
  21. tobefreed=NULL;
  22. }
  23. slapi_attr_get_type(attr,&aType);
  24. if (aType && slapi_attr_types_equivalent(inst->illegal_attributes[j],aType)) {
  25. tobefreed=aType;
  26. slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM,
  27. "attribute <%s> not forwarded.\n",aType);
  28. }
  29. rc = slapi_entry_next_attr(e, attr, &attr);
  30. }
  31. if (tobefreed) {
  32. slapi_entry_attr_delete( e, tobefreed);
  33. tobefreed=NULL;
  34. }
  35. }
  36. PR_RWLock_Unlock(inst->rwl_config_lock);
  37. }
  38. }