s4-ldb: added a function to filter extended components of a ldb_dn
authorAndrew Tridgell <tridge@samba.org>
Thu, 10 Dec 2009 12:44:44 +0000 (23:44 +1100)
committerAndrew Tridgell <tridge@samba.org>
Mon, 14 Dec 2009 11:29:57 +0000 (22:29 +1100)
We need to be able to filter out components that should not be exposed
to users

source4/lib/ldb/common/ldb_dn.c

index bd42bd5f1828e8571815a1ccf7599603afc55920..f11ccf35d752b4287573f604798c9acc3e1f9d97 100644 (file)
@@ -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; i<dn->ext_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)