r20306: remove the static oid mapping table
[kai/samba.git] / source4 / dsdb / schema / schema_init.c
1 /* 
2    Unix SMB/CIFS mplementation.
3    DSDB schema header
4    
5    Copyright (C) Stefan Metzmacher 2006
6     
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20    
21 */
22
23 #include "includes.h"
24 #include "dsdb/samdb/samdb.h"
25 #include "lib/util/dlinklist.h"
26 #include "librpc/gen_ndr/drsuapi.h"
27
28 WERROR dsdb_load_oid_mappings(struct dsdb_schema *schema, const struct drsuapi_DsReplicaOIDMapping_Ctr *ctr)
29 {
30         uint32_t i,j;
31
32         schema->prefixes = talloc_array(schema, struct dsdb_schema_oid_prefix, ctr->num_mappings);
33         W_ERROR_HAVE_NO_MEMORY(schema->prefixes);
34
35         for (i=0, j=0; i < ctr->num_mappings; i++) {
36                 if (ctr->mappings[i].oid.oid == NULL) {
37                         return WERR_INVALID_PARAM;
38                 }
39
40                 if (strncasecmp(ctr->mappings[i].oid.oid, "ff", 2) == 0) {
41                         if (ctr->mappings[i].id_prefix != 0) {
42                                 return WERR_INVALID_PARAM;
43                         }
44
45                         /* the magic value should be in the last array member */
46                         if (i != (ctr->num_mappings - 1)) {
47                                 return WERR_INVALID_PARAM;
48                         }
49                                 
50                         schema->unknown_magic = talloc_strdup(schema, ctr->mappings[i].oid.oid);
51                         W_ERROR_HAVE_NO_MEMORY(schema->unknown_magic);
52                 } else {
53                         /* the last array member should contain the magic value not a oid */
54                         if (i == (ctr->num_mappings - 1)) {
55                                 return WERR_INVALID_PARAM;
56                         }
57
58                         schema->prefixes[j].id  = ctr->mappings[i].id_prefix<<16;
59                         schema->prefixes[j].oid = talloc_asprintf(schema->prefixes, "%s.",
60                                                                   ctr->mappings[i].oid.oid);
61                         W_ERROR_HAVE_NO_MEMORY(schema->prefixes[j].oid);
62                         schema->prefixes[j].oid_len = strlen(schema->prefixes[j].oid);
63                         j++;
64                 }
65         }
66
67         schema->num_prefixes = j;
68         return WERR_OK;
69 }
70
71 WERROR dsdb_map_oid2int(struct dsdb_schema *schema, const char *in, uint32_t *out)
72 {
73         uint32_t i;
74
75         for (i=0; i < schema->num_prefixes; i++) {
76                 const char *val_str;
77                 char *end_str;
78                 unsigned val;
79
80                 if (strncmp(schema->prefixes[i].oid, in, schema->prefixes[i].oid_len) != 0) {
81                         continue;
82                 }
83
84                 val_str = in + schema->prefixes[i].oid_len;
85                 end_str = NULL;
86                 errno = 0;
87
88                 if (val_str[0] == '\0') {
89                         return WERR_INVALID_PARAM;
90                 }
91
92                 /* two '.' chars are invalid */
93                 if (val_str[0] == '.') {
94                         return WERR_INVALID_PARAM;
95                 }
96
97                 val = strtoul(val_str, &end_str, 10);
98                 if (end_str[0] == '.' && end_str[1] != '\0') {
99                         /*
100                          * if it's a '.' and not the last char
101                          * then maybe an other mapping apply
102                          */
103                         continue;
104                 } else if (end_str[0] != '\0') {
105                         return WERR_INVALID_PARAM;
106                 } else if (val > 0xFFFF) {
107                         return WERR_INVALID_PARAM;
108                 }
109
110                 *out = schema->prefixes[i].id | val;
111                 return WERR_OK;
112         }
113
114         return WERR_DS_NO_MSDS_INTID;
115 }
116
117 WERROR dsdb_map_int2oid(struct dsdb_schema *schema, uint32_t in, TALLOC_CTX *mem_ctx, const char **out)
118 {
119         uint32_t i;
120
121         for (i=0; i < schema->num_prefixes; i++) {
122                 const char *val;
123                 if (schema->prefixes[i].id != (in & 0xFFFF0000)) {
124                         continue;
125                 }
126
127                 val = talloc_asprintf(mem_ctx, "%s%u",
128                                       schema->prefixes[i].oid,
129                                       in & 0xFFFF);
130                 W_ERROR_HAVE_NO_MEMORY(val);
131
132                 *out = val;
133                 return WERR_OK;
134         }
135
136         return WERR_DS_NO_MSDS_INTID;
137 }
138
139 #define GET_STRING_LDB(msg, attr, mem_ctx, p, elem, strict) do { \
140         (p)->elem = samdb_result_string(msg, attr, NULL);\
141         if (strict && (p)->elem == NULL) { \
142                 d_printf("%s: %s == NULL\n", __location__, attr); \
143                 return WERR_INVALID_PARAM; \
144         } \
145         talloc_steal(mem_ctx, (p)->elem); \
146 } while (0)
147
148 #define GET_BOOL_LDB(msg, attr, p, elem, strict) do { \
149         const char *str; \
150         str = samdb_result_string(msg, attr, NULL);\
151         if (str == NULL) { \
152                 if (strict) { \
153                         d_printf("%s: %s == NULL\n", __location__, attr); \
154                         return WERR_INVALID_PARAM; \
155                 } else { \
156                         (p)->elem = False; \
157                 } \
158         } else if (strcasecmp("TRUE", str) == 0) { \
159                 (p)->elem = True; \
160         } else if (strcasecmp("FALSE", str) == 0) { \
161                 (p)->elem = False; \
162         } else { \
163                 d_printf("%s: %s == %s\n", __location__, attr, str); \
164                 return WERR_INVALID_PARAM; \
165         } \
166 } while (0)
167
168 #define GET_UINT32_LDB(msg, attr, p, elem) do { \
169         (p)->elem = samdb_result_uint(msg, attr, 0);\
170 } while (0)
171
172 #define GET_GUID_LDB(msg, attr, p, elem) do { \
173         (p)->elem = samdb_result_guid(msg, attr);\
174 } while (0)
175
176 #define GET_BLOB_LDB(msg, attr, mem_ctx, p, elem) do { \
177         const struct ldb_val *_val;\
178         _val = ldb_msg_find_ldb_val(msg, attr);\
179         if (_val) {\
180                 (p)->elem = *_val;\
181                 talloc_steal(mem_ctx, (p)->elem.data);\
182         } else {\
183                 ZERO_STRUCT((p)->elem);\
184         }\
185 } while (0)
186
187 WERROR dsdb_attribute_from_ldb(struct ldb_message *msg, TALLOC_CTX *mem_ctx, struct dsdb_attribute *attr)
188 {
189         WERROR status;
190
191         GET_STRING_LDB(msg, "cn", mem_ctx, attr, cn, True);
192         GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, True);
193         GET_STRING_LDB(msg, "attributeID", mem_ctx, attr, attributeID_oid, True);
194         /* set an invalid value */
195         attr->attributeID_id = 0xFFFFFFFF;
196         GET_GUID_LDB(msg, "schemaIDGUID", attr, schemaIDGUID);
197         GET_UINT32_LDB(msg, "mAPIID", attr, mAPIID);
198
199         GET_GUID_LDB(msg, "attributeSecurityGUID", attr, attributeSecurityGUID);
200
201         GET_UINT32_LDB(msg, "searchFlags", attr, searchFlags);
202         GET_UINT32_LDB(msg, "systemFlags", attr, systemFlags);
203         GET_BOOL_LDB(msg, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, False);
204         GET_UINT32_LDB(msg, "linkID", attr, linkID);
205
206         GET_STRING_LDB(msg, "attributeSyntax", mem_ctx, attr, attributeSyntax_oid, True);
207         /* set an invalid value */
208         attr->attributeSyntax_id = 0xFFFFFFFF;
209         GET_UINT32_LDB(msg, "oMSyntax", attr, oMSyntax);
210         GET_BLOB_LDB(msg, "oMObjectClass", mem_ctx, attr, oMObjectClass);
211
212         GET_BOOL_LDB(msg, "isSingleValued", attr, isSingleValued, True);
213         GET_UINT32_LDB(msg, "rangeLower", attr, rangeLower);
214         GET_UINT32_LDB(msg, "rangeUpper", attr, rangeUpper);
215         GET_BOOL_LDB(msg, "extendedCharsAllowed", attr, extendedCharsAllowed, False);
216
217         GET_UINT32_LDB(msg, "schemaFlagsEx", attr, schemaFlagsEx);
218         GET_BLOB_LDB(msg, "msDs-Schema-Extensions", mem_ctx, attr, msDs_Schema_Extensions);
219
220         GET_BOOL_LDB(msg, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, False);
221         GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, attr, adminDisplayName, False);
222         GET_STRING_LDB(msg, "adminDescription", mem_ctx, attr, adminDescription, False);
223         GET_STRING_LDB(msg, "classDisplayName", mem_ctx, attr, classDisplayName, False);
224         GET_BOOL_LDB(msg, "isEphemeral", attr, isEphemeral, False);
225         GET_BOOL_LDB(msg, "isDefunct", attr, isDefunct, False);
226         GET_BOOL_LDB(msg, "systemOnly", attr, systemOnly, False);
227
228         return WERR_OK;
229 }
230
231 WERROR dsdb_class_from_ldb(struct ldb_message *msg, TALLOC_CTX *mem_ctx, struct dsdb_class *obj)
232 {
233         WERROR status;
234
235         GET_STRING_LDB(msg, "cn", mem_ctx, obj, cn, True);
236         GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, True);
237         GET_STRING_LDB(msg, "governsID", mem_ctx, obj, governsID_oid, True);
238         /* set an invalid value */
239         obj->governsID_id = 0xFFFFFFFF;
240         GET_GUID_LDB(msg, "schemaIDGUID", obj, schemaIDGUID);
241
242         GET_UINT32_LDB(msg, "objectClassCategory", obj, objectClassCategory);
243         GET_STRING_LDB(msg, "rDNAttID", mem_ctx, obj, rDNAttID, False);
244         GET_STRING_LDB(msg, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, True);
245  
246         GET_STRING_LDB(msg, "subClassOf", mem_ctx, obj, subClassOf, True);
247
248         GET_STRING_LDB(msg, "systemAuxiliaryClass", mem_ctx, obj, systemAuxiliaryClass, False);
249         obj->systemPossSuperiors= NULL;
250         obj->systemMustContain  = NULL;
251         obj->systemMayContain   = NULL;
252
253         GET_STRING_LDB(msg, "auxiliaryClass", mem_ctx, obj, auxiliaryClass, False);
254         obj->possSuperiors      = NULL;
255         obj->mustContain        = NULL;
256         obj->mayContain         = NULL;
257
258         GET_STRING_LDB(msg, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, False);
259
260         GET_UINT32_LDB(msg, "schemaFlagsEx", obj, schemaFlagsEx);
261         GET_BLOB_LDB(msg, "msDs-Schema-Extensions", mem_ctx, obj, msDs_Schema_Extensions);
262
263         GET_BOOL_LDB(msg, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, False);
264         GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, obj, adminDisplayName, False);
265         GET_STRING_LDB(msg, "adminDescription", mem_ctx, obj, adminDescription, False);
266         GET_STRING_LDB(msg, "classDisplayName", mem_ctx, obj, classDisplayName, False);
267         GET_BOOL_LDB(msg, "defaultHidingValue", obj, defaultHidingValue, False);
268         GET_BOOL_LDB(msg, "isDefunct", obj, isDefunct, False);
269         GET_BOOL_LDB(msg, "systemOnly", obj, systemOnly, False);
270
271         return WERR_OK;
272 }
273
274 static const struct {
275         const char *name;
276         const char *oid;
277 } name_mappings[] = {
278         { "cn",                                 "2.5.4.3" },
279         { "name",                               "1.2.840.113556.1.4.1" },
280         { "lDAPDisplayName",                    "1.2.840.113556.1.2.460" },
281         { "attributeID",                        "1.2.840.113556.1.2.30" },
282         { "schemaIDGUID",                       "1.2.840.113556.1.4.148" },
283         { "mAPIID",                             "1.2.840.113556.1.2.49" },
284         { "attributeSecurityGUID",              "1.2.840.113556.1.4.149" },
285         { "searchFlags",                        "1.2.840.113556.1.2.334" },
286         { "systemFlags",                        "1.2.840.113556.1.4.375" },
287         { "isMemberOfPartialAttributeSet",      "1.2.840.113556.1.4.639" },
288         { "linkID",                             "1.2.840.113556.1.2.50" },
289         { "attributeSyntax",                    "1.2.840.113556.1.2.30" },
290         { "oMSyntax",                           "1.2.840.113556.1.2.231" },
291         { "oMObjectClass",                      "1.2.840.113556.1.2.218" },
292         { "isSingleValued",                     "1.2.840.113556.1.2.33" },
293         { "rangeLower",                         "1.2.840.113556.1.2.34" },
294         { "rangeUpper",                         "1.2.840.113556.1.2.35" },
295         { "extendedCharsAllowed",               "1.2.840.113556.1.2.380" },
296         { "schemaFlagsEx",                      "1.2.840.113556.1.4.120" },
297         { "msDs-Schema-Extensions",             "1.2.840.113556.1.4.1440" },
298         { "showInAdvancedViewOnly",             "1.2.840.113556.1.2.169" },
299         { "adminDisplayName",                   "1.2.840.113556.1.2.194" },
300         { "adminDescription",                   "1.2.840.113556.1.2.226" },
301         { "classDisplayName",                   "1.2.840.113556.1.4.610" },
302         { "isEphemeral",                        "1.2.840.113556.1.4.1212" },
303         { "isDefunct",                          "1.2.840.113556.1.4.661" },
304         { "systemOnly",                         "1.2.840.113556.1.4.170" },
305         { "governsID",                          "1.2.840.113556.1.2.22" },
306         { "objectClassCategory",                "1.2.840.113556.1.2.370" },
307         { "rDNAttID",                           "1.2.840.113556.1.2.26" },
308         { "defaultObjectCategory",              "1.2.840.113556.1.4.783" },
309         { "subClassOf",                         "1.2.840.113556.1.2.21" },
310         { "systemAuxiliaryClass",               "1.2.840.113556.1.4.198" },
311         { "systemPossSuperiors",                "1.2.840.113556.1.4.195" },
312         { "systemMustContain",                  "1.2.840.113556.1.4.197" },
313         { "systemMayContain",                   "1.2.840.113556.1.4.196" },
314         { "auxiliaryClass",                     "1.2.840.113556.1.2.351" },
315         { "possSuperiors",                      "1.2.840.113556.1.2.8" },
316         { "mustContain",                        "1.2.840.113556.1.2.24" },
317         { "mayContain",                         "1.2.840.113556.1.2.25" },
318         { "defaultSecurityDescriptor",          "1.2.840.113556.1.4.224" },
319         { "defaultHidingValue",                 "1.2.840.113556.1.4.518" },
320 };
321
322 static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb_schema *schema,
323                                                                      struct drsuapi_DsReplicaObject *obj,
324                                                                      const char *name,
325                                                                      uint32_t *idx)
326 {
327         WERROR status;
328         uint32_t i, id;
329         const char *oid = NULL;
330
331         for(i=0; i < ARRAY_SIZE(name_mappings); i++) {
332                 if (strcmp(name_mappings[i].name, name) != 0) continue;
333
334                 oid = name_mappings[i].oid;
335                 break;
336         }
337
338         if (!oid) {
339                 return NULL;
340         }
341
342         status = dsdb_map_oid2int(schema, oid, &id);
343         if (!W_ERROR_IS_OK(status)) {
344                 return NULL;
345         }
346
347         for (i=0; i < obj->attribute_ctr.num_attributes; i++) {
348                 if (obj->attribute_ctr.attributes[i].attid != id) continue;
349
350                 if (idx) *idx = i;
351                 return &obj->attribute_ctr.attributes[i];
352         }
353
354         return NULL;
355 }
356
357 #define GET_STRING_DS(s, r, attr, mem_ctx, p, elem, strict) do { \
358         struct drsuapi_DsReplicaAttribute *_a; \
359         _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
360         if (strict && !_a) { \
361                 d_printf("%s: %s == NULL\n", __location__, attr); \
362                 return WERR_INVALID_PARAM; \
363         } \
364         if (strict && _a->value_ctr.unicode_string.num_values != 1) { \
365                 d_printf("%s: %s num_values == %u\n", __location__, attr, \
366                         _a->value_ctr.unicode_string.num_values); \
367                 return WERR_INVALID_PARAM; \
368         } \
369         if (_a && _a->value_ctr.unicode_string.num_values >= 1) { \
370                 (p)->elem = talloc_steal(mem_ctx, _a->value_ctr.unicode_string.values[0].string);\
371         } else { \
372                 (p)->elem = NULL; \
373         } \
374 } while (0)
375
376 #define GET_BOOL_DS(s, r, attr, p, elem, strict) do { \
377         struct drsuapi_DsReplicaAttribute *_a; \
378         _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
379         if (strict && !_a) { \
380                 d_printf("%s: %s == NULL\n", __location__, attr); \
381                 return WERR_INVALID_PARAM; \
382         } \
383         if (strict && _a->value_ctr.uint32.num_values != 1) { \
384                 d_printf("%s: %s num_values == %u\n", __location__, attr, \
385                         _a->value_ctr.uint32.num_values); \
386                 return WERR_INVALID_PARAM; \
387         } \
388         if (strict && !_a->value_ctr.uint32.values[0].value) { \
389                 d_printf("%s: %s value == NULL\n", __location__, attr); \
390                 return WERR_INVALID_PARAM; \
391         } \
392         if (_a && _a->value_ctr.uint32.num_values >= 1 \
393             && _a->value_ctr.uint32.values[0].value) { \
394                 (p)->elem = (*_a->value_ctr.uint32.values[0].value?True:False);\
395         } else { \
396                 (p)->elem = False; \
397         } \
398 } while (0)
399
400 #define GET_UINT32_DS(s, r, attr, p, elem) do { \
401         struct drsuapi_DsReplicaAttribute *_a; \
402         _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
403         if (_a && _a->value_ctr.uint32.num_values >= 1 \
404             && _a->value_ctr.uint32.values[0].value) { \
405                 (p)->elem = *_a->value_ctr.uint32.values[0].value;\
406         } else { \
407                 (p)->elem = 0; \
408         } \
409 } while (0)
410
411 #define GET_GUID_DS(s, r, attr, p, elem) do { \
412         struct drsuapi_DsReplicaAttribute *_a; \
413         _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
414         if (_a && _a->value_ctr.guid.num_values >= 1 \
415             && _a->value_ctr.guid.values[0].guid) { \
416                 (p)->elem = *_a->value_ctr.guid.values[0].guid;\
417         } else { \
418                 ZERO_STRUCT((p)->elem);\
419         } \
420 } while (0)
421
422 #define GET_BLOB_DS(s, r, attr, mem_ctx, p, elem) do { \
423         struct drsuapi_DsReplicaAttribute *_a; \
424         _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
425         if (_a && _a->value_ctr.data_blob.num_values >= 1 \
426             && _a->value_ctr.data_blob.values[0].data) { \
427                 (p)->elem = *_a->value_ctr.data_blob.values[0].data;\
428                 talloc_steal(mem_ctx, (p)->elem.data); \
429         } else { \
430                 ZERO_STRUCT((p)->elem);\
431         }\
432 } while (0)
433
434 WERROR dsdb_attribute_from_drsuapi(struct dsdb_schema *schema,
435                                    struct drsuapi_DsReplicaObject *r,
436                                    TALLOC_CTX *mem_ctx,
437                                    struct dsdb_attribute *attr)
438 {
439         WERROR status;
440
441         GET_STRING_DS(schema, r, "name", mem_ctx, attr, cn, True);
442         GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, True);
443         GET_UINT32_DS(schema, r, "attributeID", attr, attributeID_id);
444         status = dsdb_map_int2oid(schema, attr->attributeID_id, mem_ctx, &attr->attributeID_oid);
445         if (!W_ERROR_IS_OK(status)) {
446                 DEBUG(0,("%s: '%s': unable to map attributeID 0x%08X: %s\n",
447                         __location__, attr->lDAPDisplayName, attr->attributeID_id,
448                         win_errstr(status)));
449                 return status;
450         }
451         GET_GUID_DS(schema, r, "schemaIDGUID", attr, schemaIDGUID);
452         GET_UINT32_DS(schema, r, "mAPIID", attr, mAPIID);
453
454         GET_GUID_DS(schema, r, "attributeSecurityGUID", attr, attributeSecurityGUID);
455
456         GET_UINT32_DS(schema, r, "searchFlags", attr, searchFlags);
457         GET_UINT32_DS(schema, r, "systemFlags", attr, systemFlags);
458         GET_BOOL_DS(schema, r, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, False);
459         GET_UINT32_DS(schema, r, "linkID", attr, linkID);
460
461         GET_UINT32_DS(schema, r, "attributeSyntax", attr, attributeSyntax_id);
462         status = dsdb_map_int2oid(schema, attr->attributeSyntax_id, mem_ctx, &attr->attributeSyntax_oid);
463         if (!W_ERROR_IS_OK(status)) {
464                 DEBUG(0,("%s: '%s': unable to map attributeSyntax 0x%08X: %s\n",
465                         __location__, attr->lDAPDisplayName, attr->attributeSyntax_id,
466                         win_errstr(status)));
467                 return status;
468         }
469         GET_UINT32_DS(schema, r, "oMSyntax", attr, oMSyntax);
470         GET_BLOB_DS(schema, r, "oMObjectClass", mem_ctx, attr, oMObjectClass);
471
472         GET_BOOL_DS(schema, r, "isSingleValued", attr, isSingleValued, True);
473         GET_UINT32_DS(schema, r, "rangeLower", attr, rangeLower);
474         GET_UINT32_DS(schema, r, "rangeUpper", attr, rangeUpper);
475         GET_BOOL_DS(schema, r, "extendedCharsAllowed", attr, extendedCharsAllowed, False);
476
477         GET_UINT32_DS(schema, r, "schemaFlagsEx", attr, schemaFlagsEx);
478         GET_BLOB_DS(schema, r, "msDs-Schema-Extensions", mem_ctx, attr, msDs_Schema_Extensions);
479
480         GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, False);
481         GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, attr, adminDisplayName, False);
482         GET_STRING_DS(schema, r, "adminDescription", mem_ctx, attr, adminDescription, False);
483         GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, attr, classDisplayName, False);
484         GET_BOOL_DS(schema, r, "isEphemeral", attr, isEphemeral, False);
485         GET_BOOL_DS(schema, r, "isDefunct", attr, isDefunct, False);
486         GET_BOOL_DS(schema, r, "systemOnly", attr, systemOnly, False);
487
488         return WERR_OK;
489 }
490
491 WERROR dsdb_class_from_drsuapi(struct dsdb_schema *schema,
492                                struct drsuapi_DsReplicaObject *r,
493                                TALLOC_CTX *mem_ctx,
494                                struct dsdb_class *obj)
495 {
496         WERROR status;
497
498         GET_STRING_DS(schema, r, "name", mem_ctx, obj, cn, True);
499         GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, True);
500         GET_UINT32_DS(schema, r, "governsID", obj, governsID_id);
501         status = dsdb_map_int2oid(schema, obj->governsID_id, mem_ctx, &obj->governsID_oid);
502         if (!W_ERROR_IS_OK(status)) {
503                 DEBUG(0,("%s: '%s': unable to map governsID 0x%08X: %s\n",
504                         __location__, obj->lDAPDisplayName, obj->governsID_id,
505                         win_errstr(status)));
506                 return status;
507         }
508         GET_GUID_DS(schema, r, "schemaIDGUID", obj, schemaIDGUID);
509
510         GET_UINT32_DS(schema, r, "objectClassCategory", obj, objectClassCategory);
511         GET_STRING_DS(schema, r, "rDNAttID", mem_ctx, obj, rDNAttID, False);
512         GET_STRING_DS(schema, r, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, True);
513  
514         GET_STRING_DS(schema, r, "subClassOf", mem_ctx, obj, subClassOf, True);
515
516         GET_STRING_DS(schema, r, "systemAuxiliaryClass", mem_ctx, obj, systemAuxiliaryClass, False);
517         obj->systemPossSuperiors= NULL;
518         obj->systemMustContain  = NULL;
519         obj->systemMayContain   = NULL;
520
521         GET_STRING_DS(schema, r, "auxiliaryClass", mem_ctx, obj, auxiliaryClass, False);
522         obj->possSuperiors      = NULL;
523         obj->mustContain        = NULL;
524         obj->mayContain         = NULL;
525
526         GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, False);
527
528         GET_UINT32_DS(schema, r, "schemaFlagsEx", obj, schemaFlagsEx);
529         GET_BLOB_DS(schema, r, "msDs-Schema-Extensions", mem_ctx, obj, msDs_Schema_Extensions);
530
531         GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, False);
532         GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, obj, adminDisplayName, False);
533         GET_STRING_DS(schema, r, "adminDescription", mem_ctx, obj, adminDescription, False);
534         GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, obj, classDisplayName, False);
535         GET_BOOL_DS(schema, r, "defaultHidingValue", obj, defaultHidingValue, False);
536         GET_BOOL_DS(schema, r, "isDefunct", obj, isDefunct, False);
537         GET_BOOL_DS(schema, r, "systemOnly", obj, systemOnly, False);
538
539         return WERR_OK;
540 }