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 2 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, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "dsdb/samdb/samdb.h"
25 #include "librpc/gen_ndr/ndr_drsuapi.h"
26 #include "lib/ldb/include/ldb.h"
27 #include "system/time.h"
28 #include "lib/charset/charset.h"
29 #include "librpc/ndr/libndr.h"
31 static char *dsdb_subSchema_list_append(char *v, const char *list_name)
35 const char *attrs[] = {
46 v = talloc_asprintf_append(v, "%s ( ", list_name);
49 for (i=0; attrs[i]; i++) {
50 v = talloc_asprintf_append(v, "%s%s ",
57 v = talloc_asprintf_append(v, ") ");
63 WERROR dsdb_subSchema_attributeTypes(const struct dsdb_schema *schema,
66 struct ldb_message_element *e;
67 struct dsdb_attribute *a;
69 e = talloc_zero(mem_ctx, struct ldb_message_element);
70 W_ERROR_HAVE_NO_MEMORY(e);
72 for (a = schema->attributes; a; a = a->next) {
75 v = talloc_asprintf(e, "( %s NAME '%s' SYNTAX '%s' ",
76 a->attributeID_oid, a->lDAPDisplayName,
78 W_ERROR_HAVE_NO_MEMORY(v);
80 if (a->isSingleValued) {
81 v = talloc_asprintf_append(v, "SINGLE-VALUE ");
82 W_ERROR_HAVE_NO_MEMORY(v);
86 v = talloc_asprintf_append(v, "NO-USER-MODIFICATION ");
87 W_ERROR_HAVE_NO_MEMORY(v);
90 v = talloc_asprintf_append(v, ")");
91 W_ERROR_HAVE_NO_MEMORY(v);
99 WERROR dsdb_subSchema_objectClasses(const struct dsdb_schema *schema,
102 struct ldb_message_element *e;
103 struct dsdb_class *c;
105 e = talloc_zero(mem_ctx, struct ldb_message_element);
106 W_ERROR_HAVE_NO_MEMORY(e);
108 for (c = schema->classes; c; c = c->next) {
109 const char *class_type;
112 switch (c->objectClassCategory) {
115 * NOTE: this is an type 88 class
116 * e.g. 2.5.6.6 NAME 'person'
117 * but w2k3 gives STRUCTURAL here!
119 class_type = "STRUCTURAL";
122 class_type = "STRUCTURAL";
125 class_type = "ABSTRACT";
128 class_type = "AUXILIARY";
131 class_type = "UNKNOWN";
135 v = talloc_asprintf(e, "( %s NAME '%s' SUB %s %s ",
136 c->governsID_oid, c->lDAPDisplayName,
137 c->subClassOf, class_type);
138 W_ERROR_HAVE_NO_MEMORY(v);
140 v = dsdb_subSchema_list_append(v, "MUST");
141 W_ERROR_HAVE_NO_MEMORY(v);
143 v = dsdb_subSchema_list_append(v, "MAY");
144 W_ERROR_HAVE_NO_MEMORY(v);
146 v = talloc_asprintf_append(v, ")");
147 W_ERROR_HAVE_NO_MEMORY(v);
149 DEBUG(0,("%s\n", v));
155 WERROR dsdb_subSchema_dITContentRules(const struct dsdb_schema *schema,
158 struct ldb_message_element *e;
159 struct dsdb_class *c;
161 e = talloc_zero(mem_ctx, struct ldb_message_element);
162 W_ERROR_HAVE_NO_MEMORY(e);
164 for (c = schema->classes; c; c = c->next) {
168 * TODO: filter out classes without auxiliary classes
171 v = talloc_asprintf(e, "( %s NAME '%s' ",
172 c->governsID_oid, c->lDAPDisplayName);
173 W_ERROR_HAVE_NO_MEMORY(v);
175 v = dsdb_subSchema_list_append(v, "AUX");
176 W_ERROR_HAVE_NO_MEMORY(v);
178 v = dsdb_subSchema_list_append(v, "MUST");
179 W_ERROR_HAVE_NO_MEMORY(v);
181 v = dsdb_subSchema_list_append(v, "MAY");
182 W_ERROR_HAVE_NO_MEMORY(v);
184 v = talloc_asprintf_append(v, ")");
185 W_ERROR_HAVE_NO_MEMORY(v);
187 DEBUG(0,("%s\n", v));