From 0d76df995332b468b26dbb5807ad0317e55ad288 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Dec 2009 23:44:44 +1100 Subject: s4-ldb: added a function to filter extended components of a ldb_dn We need to be able to filter out components that should not be exposed to users --- source4/lib/ldb/common/ldb_dn.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4/lib/ldb/common') diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c index bd42bd5f18..f11ccf35d7 100644 --- a/source4/lib/ldb/common/ldb_dn.c +++ b/source4/lib/ldb/common/ldb_dn.c @@ -873,6 +873,22 @@ char *ldb_dn_get_extended_linearized(void *mem_ctx, struct ldb_dn *dn, int mode) return p; } +/* + filter out all but an acceptable list of extended DN components + */ +void ldb_dn_extended_filter(struct ldb_dn *dn, const char * const *accept) +{ + int i; + for (i=0; iext_comp_num; i++) { + if (!ldb_attr_in_list(accept, dn->ext_components[i].name)) { + memmove(&dn->ext_components[i], + &dn->ext_components[i+1], + (dn->ext_comp_num-(i+1))*sizeof(dn->ext_components[0])); + dn->ext_comp_num--; + i--; + } + } +} char *ldb_dn_alloc_linearized(void *mem_ctx, struct ldb_dn *dn) -- cgit