From 9539e2b508b3340b49575e5022c365ec382b2097 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 2 Apr 2009 16:42:21 +1100 Subject: major upgrade to the ldb attribute handling This is all working towards supporting the full WSPP schema without a major performance penalty. We now use binary searches when looking up classes and attributes. We also avoid the loop loading the attributes into ldb, by adding a hook to override the ldb attribute search function in a module. The attributes can thus be loaded once, and then saved as part of the global schema. Also added support for a few more key attribute syntaxes, as needed for the full schema. --- source4/lib/ldb/common/ldb_attributes.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source4/lib/ldb/common/ldb_attributes.c') diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c index 9fa0fb2ccd..cf45e8ef28 100644 --- a/source4/lib/ldb/common/ldb_attributes.c +++ b/source4/lib/ldb/common/ldb_attributes.c @@ -124,6 +124,16 @@ const struct ldb_schema_attribute *ldb_schema_attribute_by_name(struct ldb_conte int i, e, b = 0, r; const struct ldb_schema_attribute *def = &ldb_attribute_default; + if (ldb->schema.attribute_handler_override) { + const struct ldb_schema_attribute *ret = + ldb->schema.attribute_handler_override(ldb, + ldb->schema.attribute_handler_override_private, + name); + if (ret) { + return ret; + } + } + /* as handlers are sorted, '*' must be the first if present */ if (strcmp(ldb->schema.attributes[0].name, "*") == 0) { def = &ldb->schema.attributes[0]; @@ -273,3 +283,14 @@ const struct ldb_dn_extended_syntax *ldb_dn_extended_syntax_by_name(struct ldb_c return NULL; } +/* + set an attribute handler override function - used to delegate schema handling + to external code + */ +void ldb_schema_attribute_set_override_handler(struct ldb_context *ldb, + ldb_attribute_handler_override_fn_t override, + void *private_data) +{ + ldb->schema.attribute_handler_override_private = private_data; + ldb->schema.attribute_handler_override = override; +} -- cgit From 9181637170a994ef93bfb8c0fa69ab7b89837f0d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 7 Apr 2009 16:33:54 +1000 Subject: fixed internal handling of attribute deletion --- source4/lib/ldb/common/ldb_attributes.c | 36 +++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'source4/lib/ldb/common/ldb_attributes.c') diff --git a/source4/lib/ldb/common/ldb_attributes.c b/source4/lib/ldb/common/ldb_attributes.c index cf45e8ef28..79c5dd69de 100644 --- a/source4/lib/ldb/common/ldb_attributes.c +++ b/source4/lib/ldb/common/ldb_attributes.c @@ -118,22 +118,13 @@ static const struct ldb_schema_attribute ldb_attribute_default = { /* return the attribute handlers for a given attribute */ -const struct ldb_schema_attribute *ldb_schema_attribute_by_name(struct ldb_context *ldb, - const char *name) +static const struct ldb_schema_attribute *ldb_schema_attribute_by_name_internal( + struct ldb_context *ldb, + const char *name) { int i, e, b = 0, r; const struct ldb_schema_attribute *def = &ldb_attribute_default; - if (ldb->schema.attribute_handler_override) { - const struct ldb_schema_attribute *ret = - ldb->schema.attribute_handler_override(ldb, - ldb->schema.attribute_handler_override_private, - name); - if (ret) { - return ret; - } - } - /* as handlers are sorted, '*' must be the first if present */ if (strcmp(ldb->schema.attributes[0].name, "*") == 0) { def = &ldb->schema.attributes[0]; @@ -162,6 +153,25 @@ const struct ldb_schema_attribute *ldb_schema_attribute_by_name(struct ldb_conte return def; } +/* + return the attribute handlers for a given attribute +*/ +const struct ldb_schema_attribute *ldb_schema_attribute_by_name(struct ldb_context *ldb, + const char *name) +{ + if (ldb->schema.attribute_handler_override) { + const struct ldb_schema_attribute *ret = + ldb->schema.attribute_handler_override(ldb, + ldb->schema.attribute_handler_override_private, + name); + if (ret) { + return ret; + } + } + + return ldb_schema_attribute_by_name_internal(ldb, name); +} + /* add to the list of ldif handlers for this ldb context @@ -171,7 +181,7 @@ void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name) const struct ldb_schema_attribute *a; int i; - a = ldb_schema_attribute_by_name(ldb, name); + a = ldb_schema_attribute_by_name_internal(ldb, name); if (a == NULL || a->name == NULL) { return; } -- cgit