2 Unix SMB/CIFS mplementation.
3 DSDB schema constructed attributes
4 attributeTypes, objectClasses, dITContentRules...
6 Copyright (C) Stefan Metzmacher 2006
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "dsdb/samdb/samdb.h"
24 #include "librpc/gen_ndr/ndr_drsuapi.h"
25 #include "lib/ldb/include/ldb.h"
26 #include "system/time.h"
27 #include "lib/charset/charset.h"
28 #include "librpc/ndr/libndr.h"
30 static char *dsdb_subSchema_list_append(char *v, const char *list_name)
34 const char *attrs[] = {
41 v = talloc_asprintf_append(v, "%s ( ", list_name);
44 for (i=0; attrs[i]; i++) {
45 v = talloc_asprintf_append(v, "%s%s ",
52 v = talloc_asprintf_append(v, ") ");
58 WERROR dsdb_subSchema_attributeTypes(const struct dsdb_schema *schema,
61 struct ldb_message_element *e;
62 struct dsdb_attribute *a;
64 e = talloc_zero(mem_ctx, struct ldb_message_element);
65 W_ERROR_HAVE_NO_MEMORY(e);
67 for (a = schema->attributes; a; a = a->next) {
70 v = talloc_asprintf(e, "( %s NAME '%s' SYNTAX '%s' ",
71 a->attributeID_oid, a->lDAPDisplayName,
73 W_ERROR_HAVE_NO_MEMORY(v);
75 if (a->isSingleValued) {
76 v = talloc_asprintf_append(v, "SINGLE-VALUE ");
77 W_ERROR_HAVE_NO_MEMORY(v);
81 v = talloc_asprintf_append(v, "NO-USER-MODIFICATION ");
82 W_ERROR_HAVE_NO_MEMORY(v);
85 v = talloc_asprintf_append(v, ")");
86 W_ERROR_HAVE_NO_MEMORY(v);
94 WERROR dsdb_subSchema_objectClasses(const struct dsdb_schema *schema,
97 struct ldb_message_element *e;
100 e = talloc_zero(mem_ctx, struct ldb_message_element);
101 W_ERROR_HAVE_NO_MEMORY(e);
103 for (c = schema->classes; c; c = c->next) {
104 const char *class_type;
107 switch (c->objectClassCategory) {
110 * NOTE: this is an type 88 class
111 * e.g. 2.5.6.6 NAME 'person'
112 * but w2k3 gives STRUCTURAL here!
114 class_type = "STRUCTURAL";
117 class_type = "STRUCTURAL";
120 class_type = "ABSTRACT";
123 class_type = "AUXILIARY";
126 class_type = "UNKNOWN";
130 v = talloc_asprintf(e, "( %s NAME '%s' SUB %s %s ",
131 c->governsID_oid, c->lDAPDisplayName,
132 c->subClassOf, class_type);
133 W_ERROR_HAVE_NO_MEMORY(v);
135 v = dsdb_subSchema_list_append(v, "MUST");
136 W_ERROR_HAVE_NO_MEMORY(v);
138 v = dsdb_subSchema_list_append(v, "MAY");
139 W_ERROR_HAVE_NO_MEMORY(v);
141 v = talloc_asprintf_append(v, ")");
142 W_ERROR_HAVE_NO_MEMORY(v);
144 DEBUG(0,("%s\n", v));
150 WERROR dsdb_subSchema_dITContentRules(const struct dsdb_schema *schema,
153 struct ldb_message_element *e;
154 struct dsdb_class *c;
156 e = talloc_zero(mem_ctx, struct ldb_message_element);
157 W_ERROR_HAVE_NO_MEMORY(e);
159 for (c = schema->classes; c; c = c->next) {
163 * TODO: filter out classes without auxiliary classes
166 v = talloc_asprintf(e, "( %s NAME '%s' ",
167 c->governsID_oid, c->lDAPDisplayName);
168 W_ERROR_HAVE_NO_MEMORY(v);
170 v = dsdb_subSchema_list_append(v, "AUX");
171 W_ERROR_HAVE_NO_MEMORY(v);
173 v = dsdb_subSchema_list_append(v, "MUST");
174 W_ERROR_HAVE_NO_MEMORY(v);
176 v = dsdb_subSchema_list_append(v, "MAY");
177 W_ERROR_HAVE_NO_MEMORY(v);
179 v = talloc_asprintf_append(v, ")");
180 W_ERROR_HAVE_NO_MEMORY(v);
182 DEBUG(0,("%s\n", v));