cb_schema.c 1.4 KB

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