summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-01-18 00:49:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:43:43 -0500
commit301129f6defacfc924647e6aa7be45cf6d7f2f5b (patch)
treed99793af1085238fb00741afe686db78acea1c71 /source4
parent2c8a7cc33361a5fce453a77050742d0c7d7b5369 (diff)
downloadsamba-301129f6defacfc924647e6aa7be45cf6d7f2f5b.tar.gz
samba-301129f6defacfc924647e6aa7be45cf6d7f2f5b.tar.bz2
samba-301129f6defacfc924647e6aa7be45cf6d7f2f5b.zip
r20870: implement the constructed attributes dsSchemaAttrCount,
dsSchemaClassCount and dsSchemaPrefixCount on the rootdse having a loaded dsdb_schema make things so easy...:-) metze (This used to be commit 7862fcdbb5ce43e702512c1acdbb5843ef551293)
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/samdb/ldb_modules/rootdse.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index f9a9b52029..9a469c4563 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -26,6 +26,7 @@
#include "lib/ldb/include/ldb_errors.h"
#include "lib/ldb/include/ldb_private.h"
#include "system/time.h"
+#include "dsdb/samdb/samdb.h"
struct private_data {
int num_controls;
@@ -44,6 +45,11 @@ static int do_attribute(const char * const *attrs, const char *name)
ldb_attr_in_list(attrs, "*");
}
+static int do_attribute_explicit(const char * const *attrs, const char *name)
+{
+ return attrs != NULL && ldb_attr_in_list(attrs, name);
+}
+
/*
add dynamically generated attributes to rootDSE result
@@ -52,6 +58,9 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
{
struct private_data *priv = talloc_get_type(module->private_data, struct private_data);
char **server_sasl;
+ const struct dsdb_schema *schema;
+
+ schema = dsdb_get_schema(module->ldb);
msg->dn = ldb_dn_new(msg, module->ldb, NULL);
@@ -119,6 +128,41 @@ static int rootdse_add_dynamic(struct ldb_module *module, struct ldb_message *ms
}
}
+ if (schema && do_attribute_explicit(attrs, "dsSchemaAttrCount")) {
+ struct dsdb_attribute *cur;
+ uint32_t n = 0;
+
+ for (cur = schema->attributes; cur; cur = cur->next) {
+ n++;
+ }
+
+ if (ldb_msg_add_fmt(msg, "dsSchemaAttrCount",
+ "%u", n) != 0) {
+ goto failed;
+ }
+ }
+
+ if (schema && do_attribute_explicit(attrs, "dsSchemaClassCount")) {
+ struct dsdb_class *cur;
+ uint32_t n = 0;
+
+ for (cur = schema->classes; cur; cur = cur->next) {
+ n++;
+ }
+
+ if (ldb_msg_add_fmt(msg, "dsSchemaClassCount",
+ "%u", n) != 0) {
+ goto failed;
+ }
+ }
+
+ if (schema && do_attribute_explicit(attrs, "dsSchemaPrefixCount")) {
+ if (ldb_msg_add_fmt(msg, "dsSchemaPrefixCount",
+ "%u", schema->num_prefixes) != 0) {
+ goto failed;
+ }
+ }
+
/* TODO: lots more dynamic attributes should be added here */
return LDB_SUCCESS;