Pull in all the schema information during DRS schema fetch
authorAndrew Bartlett <abartlet@samba.org>
Wed, 4 Mar 2009 03:06:11 +0000 (14:06 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 4 Mar 2009 03:06:11 +0000 (14:06 +1100)
This includes things such as allowed attributes, which were not
populated into the schema structure before.

Andrew Bartlett

source4/dsdb/schema/schema_init.c

index fbd8946bb59f2a056dc217ab07edb9234182b2f4..a67aecd1e866289cf6e119eb8e74e3524ef9ab1e 100644 (file)
@@ -1202,6 +1202,34 @@ static struct drsuapi_DsReplicaAttribute *dsdb_find_object_attr_name(struct dsdb
        } \
 } while (0)
 
        } \
 } while (0)
 
+#define GET_STRING_LIST_DS(s, r, attr, mem_ctx, p, elem, strict) do { \
+       int get_string_list_counter;                                    \
+       struct drsuapi_DsReplicaAttribute *_a; \
+       _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
+       if (strict && !_a) { \
+               d_printf("%s: %s == NULL\n", __location__, attr); \
+               return WERR_INVALID_PARAM; \
+       } \
+       (p)->elem = _a ? talloc_array(mem_ctx, const char *, _a->value_ctr.num_values + 1) : NULL; \
+        for (get_string_list_counter=0;                                        \
+            _a && get_string_list_counter < _a->value_ctr.num_values;  \
+            get_string_list_counter++) {                               \
+               size_t _ret;                                            \
+               if (!convert_string_talloc_convenience(mem_ctx, s->iconv_convenience, CH_UTF16, CH_UNIX, \
+                                            _a->value_ctr.values[get_string_list_counter].blob->data, \
+                                            _a->value_ctr.values[get_string_list_counter].blob->length, \
+                                                      (void **)discard_const(&(p)->elem[get_string_list_counter]), &_ret, false)) { \
+                       DEBUG(0,("%s: invalid data!\n", attr)); \
+                       dump_data(0, \
+                                    _a->value_ctr.values[get_string_list_counter].blob->data, \
+                                    _a->value_ctr.values[get_string_list_counter].blob->length); \
+                       return WERR_FOOBAR; \
+               } \
+               (p)->elem[get_string_list_counter+1] = NULL;            \
+       }                                                               \
+       talloc_steal(mem_ctx, (p)->elem);                               \
+} while (0)
+
 #define GET_DN_DS(s, r, attr, mem_ctx, p, elem, strict) do { \
        struct drsuapi_DsReplicaAttribute *_a; \
        _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
 #define GET_DN_DS(s, r, attr, mem_ctx, p, elem, strict) do { \
        struct drsuapi_DsReplicaAttribute *_a; \
        _a = dsdb_find_object_attr_name(s, r, attr, NULL); \
@@ -1412,17 +1440,18 @@ WERROR dsdb_class_from_drsuapi(struct dsdb_schema *schema,
 
        GET_STRING_DS(schema, r, "subClassOf", mem_ctx, obj, subClassOf, true);
 
 
        GET_STRING_DS(schema, r, "subClassOf", mem_ctx, obj, subClassOf, true);
 
-       obj->systemAuxiliaryClass       = NULL;
-       obj->systemPossSuperiors        = NULL;
-       obj->systemMustContain          = NULL;
-       obj->systemMayContain           = NULL;
 
 
-       obj->auxiliaryClass             = NULL;
-       obj->possSuperiors              = NULL;
-       obj->mustContain                = NULL;
-       obj->mayContain                 = NULL;
+       GET_STRING_LIST_DS(schema, r, "systemAuxiliaryClass", mem_ctx, obj, systemAuxiliaryClass, false);
+       GET_STRING_LIST_DS(schema, r, "auxiliaryClass", mem_ctx, obj, auxiliaryClass, false);
+
+       GET_STRING_LIST_DS(schema, r, "systemMustContain", mem_ctx, obj, systemMustContain, false);
+       GET_STRING_LIST_DS(schema, r, "systemMayContain", mem_ctx, obj, systemMayContain, false);
+       GET_STRING_LIST_DS(schema, r, "mustContain", mem_ctx, obj, mustContain, false);
+       GET_STRING_LIST_DS(schema, r, "mayContain", mem_ctx, obj, mayContain, false);
 
 
-       obj->possibleInferiors          = NULL;
+       GET_STRING_LIST_DS(schema, r, "systemPossSuperiors", mem_ctx, obj, systemPossSuperiors, false);
+       GET_STRING_LIST_DS(schema, r, "possSuperiors", mem_ctx, obj, possSuperiors, false);
+       GET_STRING_LIST_DS(schema, r, "possibleInferiors", mem_ctx, obj, possibleInferiors, false);
 
        GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false);
 
 
        GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false);