From 0fa924bb8f446e35a0fd543cda20b23c81e7dc9e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 13 Oct 2005 05:04:16 +0000 Subject: r10954: added support for canonicalName in the operational module, using the dn->canonicalName function abartlet just committed (This used to be commit 197e8a27f0557869eacd17b74e1b14e0665883b1) --- source4/lib/ldb/modules/operational.c | 112 ++++++++++++++++++++++++---------- 1 file changed, 80 insertions(+), 32 deletions(-) (limited to 'source4/lib/ldb/modules/operational.c') diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c index c40936df07..8a06e20c29 100644 --- a/source4/lib/ldb/modules/operational.c +++ b/source4/lib/ldb/modules/operational.c @@ -79,6 +79,19 @@ #include "ldb/include/ldb_private.h" #include +/* + construct a canonical name from a message +*/ +static int construct_canonical_name(struct ldb_module *module, struct ldb_message *msg) +{ + char *canonicalName; + canonicalName = ldb_dn_canonical_string(msg, msg->dn); + if (canonicalName == NULL) { + return -1; + } + return ldb_msg_add_string(msg, "canonicalName", canonicalName); +} + /* a list of attribute names that should be substituted in the parse tree before the search is done @@ -91,6 +104,7 @@ static const struct { { "modifyTimestamp", "whenChanged" } }; + /* a list of attribute names that are hidden, but can be searched for using another (non-hidden) name to produce the correct result @@ -98,12 +112,65 @@ static const struct { static const struct { const char *attr; const char *replace; + int (*constructor)(struct ldb_module *, struct ldb_message *); } search_sub[] = { - { "createTimestamp", "whenCreated" }, - { "modifyTimestamp", "whenChanged" }, - { "structuralObjectClass", "objectClass" } + { "createTimestamp", "whenCreated", NULL }, + { "modifyTimestamp", "whenChanged", NULL }, + { "structuralObjectClass", "objectClass", NULL }, + { "canonicalName", "distinguishedName", construct_canonical_name } }; +/* + post process a search result record. For any search_sub[] attributes that were + asked for, we need to call the appropriate copy routine to copy the result + into the message, then remove any attributes that we added to the search but were + not asked for by the user +*/ +static int operational_search_post_process(struct ldb_module *module, + struct ldb_message *msg, + const char * const *attrs) +{ + int i, a=0; + + for (a=0;attrs && attrs[a];a++) { + for (i=0;ildb, LDB_DEBUG_WARNING, + "operational_search_post_process failed for attribute '%s'\n", + attrs[a]); + return -1; +} + /* hook search operations */ @@ -131,13 +198,14 @@ static int operational_search_bytree(struct ldb_module *module, /* in the list of attributes we are looking for, rename any attributes to the alias for any hidden attributes that can be fetched directly using non-hidden names */ - for (i=0;ildb); -- cgit