svn commit: samba r20870 - in branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules: .

metze at samba.org metze at samba.org
Thu Jan 18 00:49:53 GMT 2007


Author: metze
Date: 2007-01-18 00:49:52 +0000 (Thu, 18 Jan 2007)
New Revision: 20870

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20870

Log:
implement the constructed attributes dsSchemaAttrCount,
dsSchemaClassCount and dsSchemaPrefixCount on the rootdse

having a loaded dsdb_schema make things so easy...:-)

metze
Modified:
   branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/rootdse.c


Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/rootdse.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/rootdse.c	2007-01-18 00:26:07 UTC (rev 20869)
+++ branches/SAMBA_4_0/source/dsdb/samdb/ldb_modules/rootdse.c	2007-01-18 00:49:52 UTC (rev 20870)
@@ -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,7 +45,12 @@
 		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,7 +58,10 @@
 {
 	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);
 
 	/* don't return the distinduishedName, cn and name attributes */
@@ -119,6 +128,41 @@
 		}
 	}
 
+	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;



More information about the samba-cvs mailing list