Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/source4/dsdb/schema
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source4/dsdb/schema/schema.h

    r740 r988  
    2424
    2525#include "prefixmap.h"
     26
     27enum dsdb_dn_format {
     28        DSDB_NORMAL_DN,
     29        DSDB_BINARY_DN,
     30        DSDB_STRING_DN,
     31        DSDB_INVALID_DN
     32};
     33
    2634
    2735struct dsdb_attribute;
     
    6674                               const struct dsdb_attribute *attr,
    6775                               const struct ldb_message_element *in);
     76        bool auto_normalise;
     77        bool userParameters; /* Indicates the syntax userParameters should be forced to */
    6878};
    6979
     
    108118        bool systemOnly;
    109119
     120        bool one_way_link;
     121        enum dsdb_dn_format dn_format;
     122
    110123        /* internal stuff */
    111124        const struct dsdb_syntax *syntax;
     
    144157
    145158        uint32_t schemaFlagsEx;
     159        uint32_t systemFlags;
    146160        struct ldb_val msDs_Schema_Extensions;
    147161
     
    154168        bool systemOnly;
    155169
    156         const char **supclasses;
    157         const char **subclasses;
    158         const char **subclasses_direct;
    159         const char **posssuperiors;
    160170        uint32_t subClassOf_id;
    161171        uint32_t *systemAuxiliaryClass_ids;
     
    174184         * 3 */
    175185        uint32_t subClass_order;
     186
     187        struct {
     188                const char **supclasses;
     189                const char **subclasses;
     190                const char **subclasses_direct;
     191                const char **posssuperiors;
     192        } tmp;
    176193};
    177194
     
    186203
    187204struct dsdb_schema {
    188         struct ldb_dn *base_dn;
    189 
    190205        struct dsdb_schema_prefixmap *prefixmap;
    191206
     
    206221        struct dsdb_class *classes;
    207222
     223        struct dsdb_attribute **attributes_to_remove;
     224        uint32_t attributes_to_remove_size;
     225        struct dsdb_class **classes_to_remove;
     226        uint32_t classes_to_remove_size;
     227
    208228        /* lists of classes sorted by various attributes, for faster
    209229           access */
     
    225245        struct {
    226246                bool we_are_master;
     247                bool update_allowed;
    227248                struct ldb_dn *master_dn;
    228249        } fsmo;
    229250
    230251        /* Was this schema loaded from ldb (if so, then we will reload it when we detect a change in ldb) */
    231         struct ldb_module *loaded_from_module;
    232         struct dsdb_schema *(*refresh_fn)(struct ldb_module *module, struct dsdb_schema *schema, bool is_global_schema);
    233252        bool refresh_in_progress;
    234         /* an 'opaque' sequence number that the reload function may also wish to use */
    235         uint64_t reload_seq_number;
     253        time_t ts_last_change;
     254        time_t last_refresh;
     255        time_t refresh_interval;
     256        /* This 'opaque' is stored in the metadata and is used to check if the currently
     257         * loaded schema needs a reload because another process has signaled that it has been
     258         * requested to reload the schema (either due through DRS or via the schemaUpdateNow).
     259         */
     260        uint64_t metadata_usn;
    236261
    237262        /* Should the syntax handlers in this case handle all incoming OIDs automatically, assigning them as an OID if no text name is known? */
     
    255280};
    256281
     282struct ldb_module;
     283
     284typedef struct dsdb_schema *(*dsdb_schema_refresh_fn)(struct ldb_module *module,
     285                                                      struct tevent_context *ev,
     286                                                      struct dsdb_schema *schema, bool is_global_schema);
    257287#include "dsdb/schema/proto.h"
    258288
  • vendor/current/source4/dsdb/schema/schema_convert_to_ol.c

    r740 r988  
    135135                                                        NULL);
    136136                if (schema_entry == NULL) {
     137                        talloc_free(mem_ctx);
    137138                        DEBUG(0, ("failed to generate schema description for %s\n", name));
    138139                        return NULL;
     
    146147                        out = talloc_asprintf_append(out, "objectClasses: %s\n", schema_entry);
    147148                        break;
     149                default:
     150                        talloc_free(mem_ctx);
     151                        DEBUG(0,(__location__ " Wrong type of target %u!", (unsigned)target));
     152                        return NULL;
    148153                }
    149154                talloc_free(mem_ctx);
     
    200205                target = TARGET_FEDORA_DS;
    201206        } else {
     207                talloc_free(mem_ctx);
    202208                DEBUG(0, ("Invalid target type for schema conversion %s\n", target_str));
    203209                return NULL;
    204210        }
    205211
    206         /* The mappings are line-seperated, and specify details such as OIDs to skip etc */
     212        /* The mappings are line-separated, and specify details such as OIDs to skip etc */
    207213        while (1) {
    208214                line = next_line;
     
    264270        schema = dsdb_get_schema(ldb, mem_ctx);
    265271        if (!schema) {
     272                talloc_free(mem_ctx);
    266273                DEBUG(0, ("No schema on ldb to convert!\n"));
    267274                return NULL;
     
    275282                out = talloc_strdup(mem_ctx, "dn: cn=schema\n");
    276283                break;
     284        default:
     285                talloc_free(mem_ctx);
     286                DEBUG(0,(__location__ " Wrong type of target %u!", (unsigned)target));
     287                return NULL;
    277288        }
    278289
     
    340351
    341352                if (schema_entry == NULL) {
     353                        talloc_free(mem_ctx);
    342354                        DEBUG(0, ("failed to generate attribute description for %s\n", name));
    343355                        return NULL;
     
    351363                        out = talloc_asprintf_append(out, "attributeTypes: %s\n", schema_entry);
    352364                        break;
     365                default:
     366                        talloc_free(mem_ctx);
     367                        DEBUG(0,(__location__ " Wrong type of target %u!", (unsigned)target));
     368                        return NULL;
    353369                }
    354370        }
    355371
    356372        out = print_schema_recursive(out, schema, "top", target, attrs_skip, attr_map, oid_map);
     373
     374        talloc_steal(ldb, out);
     375        talloc_free(mem_ctx);
    357376
    358377        return out;
  • vendor/current/source4/dsdb/schema/schema_inferiors.c

    r740 r988  
    4040        const char **list;
    4141
    42         if (schema_class->supclasses) {
    43                 return schema_class->supclasses;
     42        if (schema_class->tmp.supclasses) {
     43                return schema_class->tmp.supclasses;
    4444        }
    4545
     
    5353        if (schema_class->subClassOf &&
    5454            strcmp(schema_class->lDAPDisplayName, schema_class->subClassOf) == 0) {
    55                 schema_class->supclasses = list;
     55                schema_class->tmp.supclasses = list;
    5656                return list;
    5757        }
     
    6666        }
    6767
    68         schema_class->supclasses = str_list_unique(list);
    69 
    70         return schema_class->supclasses;
     68        schema_class->tmp.supclasses = str_list_unique(list);
     69
     70        return schema_class->tmp.supclasses;
    7171}
    7272
     
    8888                        continue;
    8989                }
    90                 list = str_list_append_const(list, schema_class->subclasses);
     90                list = str_list_append_const(list, schema_class->tmp.subclasses);
    9191        }
    9292        return list;
     
    100100                                         struct dsdb_class *schema_class)
    101101{
    102         if (schema_class->posssuperiors == NULL) {
     102        if (schema_class->tmp.posssuperiors == NULL) {
    103103                const char **list2 = const_str_list(str_list_make_empty(schema_class));
    104104                const char **list3;
     
    119119                list2 = str_list_append_const(list2, schema_subclasses(schema, list2, list2));
    120120
    121                 schema_class->posssuperiors = str_list_unique(list2);
    122         }
    123 
    124         return schema_class->posssuperiors;
     121                schema_class->tmp.posssuperiors = str_list_unique(list2);
     122        }
     123
     124        return schema_class->tmp.posssuperiors;
    125125}
    126126
     
    128128                                              struct dsdb_class *schema_class)
    129129{
    130         const char **list = str_list_copy_const(schema_class, schema_class->subclasses_direct);
     130        const char **list = str_list_copy_const(schema_class, schema_class->tmp.subclasses_direct);
    131131        unsigned int i;
    132132        for (i=0;list && list[i]; i++) {
     
    142142/* Walk down the subClass tree, setting a higher index as we go down
    143143 * each level.  top is 1, subclasses of top are 2, etc */
    144 void schema_subclasses_order_recurse(const struct dsdb_schema *schema,
    145                                      struct dsdb_class *schema_class,
    146                                      const int order)
    147 {
    148         const char **list = schema_class->subclasses_direct;
     144static void schema_subclasses_order_recurse(const struct dsdb_schema *schema,
     145                                            struct dsdb_class *schema_class,
     146                                            const int order)
     147{
     148        const char **list = schema_class->tmp.subclasses_direct;
    149149        unsigned int i;
    150150        schema_class->subClass_order = order;
     
    170170                }
    171171                if (schema_class2 && schema_class != schema_class2) {
    172                         if (schema_class2->subclasses_direct == NULL) {
    173                                 schema_class2->subclasses_direct = const_str_list(str_list_make_empty(schema_class2));
    174                                 if (!schema_class2->subclasses_direct) {
     172                        if (schema_class2->tmp.subclasses_direct == NULL) {
     173                                schema_class2->tmp.subclasses_direct = const_str_list(str_list_make_empty(schema_class2));
     174                                if (!schema_class2->tmp.subclasses_direct) {
    175175                                        return LDB_ERR_OPERATIONS_ERROR;
    176176                                }
    177177                        }
    178                         schema_class2->subclasses_direct = str_list_add_const(schema_class2->subclasses_direct,
     178                        schema_class2->tmp.subclasses_direct = str_list_add_const(schema_class2->tmp.subclasses_direct,
    179179                                                schema_class->lDAPDisplayName);
    180180                }
     
    182182
    183183        for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {
    184                 schema_class->subclasses = str_list_unique(schema_subclasses_recurse(schema, schema_class));
     184                schema_class->tmp.subclasses = str_list_unique(schema_subclasses_recurse(schema, schema_class));
    185185
    186186                /* Initialize the subClass order, to ensure we can't have uninitialized sort on the subClass hierarchy */
     
    202202{
    203203        struct dsdb_class *c2;
    204 
    205         for (c2=schema->classes; c2; c2=c2->next) {
     204        const char **poss_inf = NULL;
     205        const char **sys_poss_inf = NULL;
     206
     207        for (c2 = schema->classes; c2; c2 = c2->next) {
    206208                const char **superiors = schema_posssuperiors(schema, c2);
    207                 if (c2->systemOnly == false
    208                     && c2->objectClassCategory != 2
    209                     && c2->objectClassCategory != 3
    210                     && str_list_check(superiors, schema_class->lDAPDisplayName)) {
    211                         if (schema_class->possibleInferiors == NULL) {
    212                                 schema_class->possibleInferiors = const_str_list(str_list_make_empty(schema_class));
    213                         }
    214                         schema_class->possibleInferiors = str_list_add_const(schema_class->possibleInferiors,
    215                                                         c2->lDAPDisplayName);
    216                 }
    217         }
    218         schema_class->possibleInferiors = str_list_unique(schema_class->possibleInferiors);
    219 }
    220 
    221 static void schema_fill_system_possible_inferiors(const struct dsdb_schema *schema,
    222                                                   struct dsdb_class *schema_class)
    223 {
    224         struct dsdb_class *c2;
    225 
    226         for (c2=schema->classes; c2; c2=c2->next) {
    227                 const char **superiors = schema_posssuperiors(schema, c2);
    228                 if (c2->objectClassCategory != 2
    229                     && c2->objectClassCategory != 3
    230                     && str_list_check(superiors, schema_class->lDAPDisplayName)) {
    231                         if (schema_class->systemPossibleInferiors == NULL) {
    232                                 schema_class->systemPossibleInferiors = const_str_list(str_list_make_empty(schema_class));
    233                         }
    234                         schema_class->systemPossibleInferiors = str_list_add_const(schema_class->systemPossibleInferiors,
    235                                                         c2->lDAPDisplayName);
    236                 }
    237         }
    238         schema_class->systemPossibleInferiors = str_list_unique(schema_class->systemPossibleInferiors);
     209                if (c2->objectClassCategory != 2 &&
     210                    c2->objectClassCategory != 3 &&
     211                    str_list_check(superiors, schema_class->lDAPDisplayName))
     212                {
     213                        if (c2->systemOnly == false) {
     214                                if (poss_inf == NULL) {
     215                                        poss_inf = const_str_list(str_list_make_empty(schema_class));
     216                                }
     217                                poss_inf = str_list_add_const(poss_inf,
     218                                                              c2->lDAPDisplayName);
     219                        }
     220                        if (sys_poss_inf == NULL) {
     221                                sys_poss_inf = const_str_list(str_list_make_empty(schema_class));
     222                        }
     223                        sys_poss_inf = str_list_add_const(sys_poss_inf,
     224                                                          c2->lDAPDisplayName);
     225                }
     226        }
     227        schema_class->systemPossibleInferiors = str_list_unique(sys_poss_inf);
     228        schema_class->possibleInferiors = str_list_unique(poss_inf);
    239229}
    240230
     
    330320        struct dsdb_class *schema_class;
    331321
     322        /* make sure we start with a clean cache */
     323        for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {
     324                ZERO_STRUCT(schema_class->tmp);
     325        }
     326
    332327        schema_fill_from_ids(schema);
    333328
     
    339334        for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {
    340335                schema_fill_possible_inferiors(schema, schema_class);
    341                 schema_fill_system_possible_inferiors(schema, schema_class);
    342336        }
    343337
    344338        /* free up our internal cache elements */
    345339        for (schema_class=schema->classes; schema_class; schema_class=schema_class->next) {
    346                 talloc_free(schema_class->supclasses);
    347                 talloc_free(schema_class->subclasses_direct);
    348                 talloc_free(schema_class->subclasses);
    349                 talloc_free(schema_class->posssuperiors);
    350                 schema_class->supclasses = NULL;
    351                 schema_class->subclasses_direct = NULL;
    352                 schema_class->subclasses = NULL;
    353                 schema_class->posssuperiors = NULL;
     340                TALLOC_FREE(schema_class->tmp.supclasses);
     341                TALLOC_FREE(schema_class->tmp.subclasses_direct);
     342                TALLOC_FREE(schema_class->tmp.subclasses);
     343                TALLOC_FREE(schema_class->tmp.posssuperiors);
    354344        }
    355345
  • vendor/current/source4/dsdb/schema/schema_init.c

    r740 r988  
    4040                return NULL;
    4141        }
     42        schema->refresh_interval = 120;
    4243
    4344        return schema;
     
    5657        if (!schema_copy) {
    5758                return NULL;
    58         }
    59 
    60         /* schema base_dn */
    61         schema_copy->base_dn = ldb_dn_copy(schema_copy, schema->base_dn);
    62         if (!schema_copy->base_dn) {
    63                 goto failed;
    6459        }
    6560
     
    9489        schema_copy->num_attributes = schema->num_attributes;
    9590
     91        schema_copy->refresh_interval = schema->refresh_interval;
     92
    9693        /* rebuild indexes */
    9794        ret = dsdb_setup_sorted_accessors(ldb, schema_copy);
     
    10198
    10299        /* leave reload_seq_number = 0 so it will be refresh ASAP */
    103         schema_copy->refresh_fn = schema->refresh_fn;
    104         schema_copy->loaded_from_module = schema->loaded_from_module;
    105100
    106101        return schema_copy;
     
    459454        unsigned int i;
    460455        for (i=0;attrs[i];i++) {
    461                 if (strcasecmp(attr, attrs[i]) == 0) {
     456                if (ldb_attr_cmp(attr, attrs[i]) == 0) {
    462457                        return true;
    463458                }
     
    615610} while (0)
    616611
    617 WERROR dsdb_attribute_from_ldb(struct ldb_context *ldb,
    618                                struct dsdb_schema *schema,
    619                                struct ldb_message *msg)
     612/** Create an dsdb_attribute out of ldb message, attr must be already talloced
     613 */
     614
     615WERROR dsdb_attribute_from_ldb(const struct dsdb_schema *schema,
     616                               struct ldb_message *msg,
     617                               struct dsdb_attribute *attr)
    620618{
    621619        WERROR status;
    622         struct dsdb_attribute *attr = talloc_zero(schema, struct dsdb_attribute);
    623         if (!attr) {
    624                 return WERR_NOMEM;
     620        if (attr == NULL) {
     621                DEBUG(0, ("%s: attr is null, it's expected not to be so\n", __location__));
     622                return WERR_INVALID_PARAM;
    625623        }
    626624
     
    691689        GET_BOOL_LDB(msg, "systemOnly", attr, systemOnly, false);
    692690
     691        return WERR_OK;
     692}
     693
     694WERROR dsdb_set_attribute_from_ldb_dups(struct ldb_context *ldb,
     695                                        struct dsdb_schema *schema,
     696                                        struct ldb_message *msg,
     697                                        bool checkdups)
     698{
     699        WERROR status;
     700        struct dsdb_attribute *attr = talloc_zero(schema, struct dsdb_attribute);
     701        if (!attr) {
     702                return WERR_NOMEM;
     703        }
     704
     705        status = dsdb_attribute_from_ldb(schema, msg, attr);
     706        if (!W_ERROR_IS_OK(status)) {
     707                return status;
     708        }
     709
    693710        attr->syntax = dsdb_syntax_for_attribute(attr);
    694711        if (!attr->syntax) {
     
    706723        }
    707724
     725        if (checkdups) {
     726                const struct dsdb_attribute *a2;
     727                struct dsdb_attribute **a;
     728                uint32_t i;
     729
     730                a2 = dsdb_attribute_by_attributeID_id(schema,
     731                                                      attr->attributeID_id);
     732                if (a2 == NULL) {
     733                        goto done;
     734                }
     735
     736                i = schema->attributes_to_remove_size;
     737                a = talloc_realloc(schema, schema->attributes_to_remove,
     738                                   struct dsdb_attribute *, i + 1);
     739                if (a == NULL) {
     740                        return WERR_NOMEM;
     741                }
     742                /* Mark the old attribute as to be removed */
     743                a[i] = discard_const_p(struct dsdb_attribute, a2);
     744                schema->attributes_to_remove = a;
     745                schema->attributes_to_remove_size++;
     746        }
     747
     748done:
    708749        DLIST_ADD(schema->attributes, attr);
    709750        return WERR_OK;
    710751}
    711752
    712 WERROR dsdb_class_from_ldb(struct dsdb_schema *schema,
    713                            struct ldb_message *msg)
     753WERROR dsdb_set_attribute_from_ldb(struct ldb_context *ldb,
     754                                   struct dsdb_schema *schema,
     755                                   struct ldb_message *msg)
     756{
     757        return dsdb_set_attribute_from_ldb_dups(ldb, schema, msg, false);
     758}
     759
     760WERROR dsdb_set_class_from_ldb_dups(struct dsdb_schema *schema,
     761                                    struct ldb_message *msg,
     762                                    bool checkdups)
    714763{
    715764        WERROR status;
     
    758807
    759808        GET_UINT32_LDB(msg, "schemaFlagsEx", obj, schemaFlagsEx);
     809        GET_UINT32_LDB(msg, "systemFlags", obj, systemFlags);
    760810        GET_BLOB_LDB(msg, "msDs-Schema-Extensions", obj, obj, msDs_Schema_Extensions);
    761811
     
    768818        GET_BOOL_LDB(msg, "systemOnly", obj, systemOnly, false);
    769819
     820        if (checkdups) {
     821                const struct dsdb_class *c2;
     822                struct dsdb_class **c;
     823                uint32_t i;
     824
     825                c2 = dsdb_class_by_governsID_id(schema, obj->governsID_id);
     826                if (c2 == NULL) {
     827                        goto done;
     828                }
     829
     830                i = schema->classes_to_remove_size;
     831                c = talloc_realloc(schema, schema->classes_to_remove,
     832                                   struct dsdb_class *, i + 1);
     833                if (c == NULL) {
     834                        return WERR_NOMEM;
     835                }
     836                /* Mark the old class to be removed */
     837                c[i] = discard_const_p(struct dsdb_class, c2);
     838                schema->classes_to_remove = c;
     839                schema->classes_to_remove_size++;
     840        }
     841
     842done:
    770843        DLIST_ADD(schema->classes, obj);
    771844        return WERR_OK;
    772845}
    773846
     847WERROR dsdb_set_class_from_ldb(struct dsdb_schema *schema,
     848                               struct ldb_message *msg)
     849{
     850        return dsdb_set_class_from_ldb_dups(schema, msg, false);
     851}
     852
    774853#define dsdb_oom(error_string, mem_ctx) *error_string = talloc_asprintf(mem_ctx, "dsdb out of memory at %s:%d\n", __FILE__, __LINE__)
    775854
    776855/*
     856 Fill a DSDB schema from the ldb results provided.  This is called
     857 directly when a schema must be created with a pre-initialised prefixMap
     858*/
     859
     860int dsdb_load_ldb_results_into_schema(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
     861                                      struct dsdb_schema *schema,
     862                                      struct ldb_result *attrs_class_res,
     863                                      char **error_string)
     864{
     865        unsigned int i;
     866
     867        schema->ts_last_change = 0;
     868        for (i=0; i < attrs_class_res->count; i++) {
     869                WERROR status = dsdb_schema_set_el_from_ldb_msg(ldb, schema, attrs_class_res->msgs[i]);
     870                if (!W_ERROR_IS_OK(status)) {
     871                        *error_string = talloc_asprintf(mem_ctx,
     872                                      "dsdb_load_ldb_results_into_schema: failed to load attribute or class definition: %s:%s",
     873                                      ldb_dn_get_linearized(attrs_class_res->msgs[i]->dn),
     874                                      win_errstr(status));
     875                        DEBUG(0,(__location__ ": %s\n", *error_string));
     876                        return LDB_ERR_CONSTRAINT_VIOLATION;
     877                }
     878        }
     879
     880        return LDB_SUCCESS;
     881}
     882
     883/*
    777884 Create a DSDB schema from the ldb results provided.  This is called
    778885 directly when the schema is provisioned from an on-disk LDIF file, or
     
    782889int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
    783890                                 struct ldb_result *schema_res,
    784                                  struct ldb_result *attrs_res, struct ldb_result *objectclass_res,
     891                                 struct ldb_result *attrs_class_res,
    785892                                 struct dsdb_schema **schema_out,
    786893                                 char **error_string)
    787894{
    788895        WERROR status;
    789         unsigned int i;
    790896        const struct ldb_val *prefix_val;
    791897        const struct ldb_val *info_val;
    792898        struct ldb_val info_val_default;
    793899        struct dsdb_schema *schema;
    794 
    795         schema = dsdb_new_schema(mem_ctx);
     900        void *lp_opaque = ldb_get_opaque(ldb, "loadparm");
     901        int ret;
     902
     903        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
     904        if (!tmp_ctx) {
     905                dsdb_oom(error_string, mem_ctx);
     906                return ldb_operr(ldb);
     907        }
     908
     909        schema = dsdb_new_schema(tmp_ctx);
    796910        if (!schema) {
    797911                dsdb_oom(error_string, mem_ctx);
     912                talloc_free(tmp_ctx);
    798913                return ldb_operr(ldb);
    799914        }
    800915
    801         schema->base_dn = talloc_steal(schema, schema_res->msgs[0]->dn);
     916        if (lp_opaque) {
     917                struct loadparm_context *lp_ctx = talloc_get_type_abort(lp_opaque, struct loadparm_context);
     918                schema->refresh_interval = lpcfg_parm_int(lp_ctx, NULL, "dsdb", "schema_reload_interval", schema->refresh_interval);
     919                lp_ctx = talloc_get_type(ldb_get_opaque(ldb, "loadparm"),
     920                                         struct loadparm_context);
     921                schema->fsmo.update_allowed = lpcfg_parm_bool(lp_ctx, NULL,
     922                                                              "dsdb", "schema update allowed",
     923                                                              false);
     924        }
    802925
    803926        prefix_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "prefixMap");
     
    806929                                                "schema_fsmo_init: no prefixMap attribute found");
    807930                DEBUG(0,(__location__ ": %s\n", *error_string));
     931                talloc_free(tmp_ctx);
    808932                return LDB_ERR_CONSTRAINT_VIOLATION;
    809933        }
     
    816940                                                        win_errstr(status));
    817941                        DEBUG(0,(__location__ ": %s\n", *error_string));
     942                        talloc_free(tmp_ctx);
    818943                        return ldb_operr(ldb);
    819944                }
     
    827952                              win_errstr(status));
    828953                DEBUG(0,(__location__ ": %s\n", *error_string));
     954                talloc_free(tmp_ctx);
    829955                return LDB_ERR_CONSTRAINT_VIOLATION;
    830956        }
    831957
    832         for (i=0; i < attrs_res->count; i++) {
    833                 status = dsdb_attribute_from_ldb(ldb, schema, attrs_res->msgs[i]);
    834                 if (!W_ERROR_IS_OK(status)) {
    835                         *error_string = talloc_asprintf(mem_ctx,
    836                                       "schema_fsmo_init: failed to load attribute definition: %s:%s",
    837                                       ldb_dn_get_linearized(attrs_res->msgs[i]->dn),
    838                                       win_errstr(status));
    839                         DEBUG(0,(__location__ ": %s\n", *error_string));
    840                         return LDB_ERR_CONSTRAINT_VIOLATION;
    841                 }
    842         }
    843 
    844         for (i=0; i < objectclass_res->count; i++) {
    845                 status = dsdb_class_from_ldb(schema, objectclass_res->msgs[i]);
    846                 if (!W_ERROR_IS_OK(status)) {
    847                         *error_string = talloc_asprintf(mem_ctx,
    848                                       "schema_fsmo_init: failed to load class definition: %s:%s",
    849                                       ldb_dn_get_linearized(objectclass_res->msgs[i]->dn),
    850                                       win_errstr(status));
    851                         DEBUG(0,(__location__ ": %s\n", *error_string));
    852                         return LDB_ERR_CONSTRAINT_VIOLATION;
    853                 }
     958        ret = dsdb_load_ldb_results_into_schema(mem_ctx, ldb, schema, attrs_class_res, error_string);
     959        if (ret != LDB_SUCCESS) {
     960                talloc_free(tmp_ctx);
     961                return ret;
    854962        }
    855963
    856964        schema->fsmo.master_dn = ldb_msg_find_attr_as_dn(ldb, schema, schema_res->msgs[0], "fSMORoleOwner");
    857         if (ldb_dn_compare(samdb_ntds_settings_dn(ldb), schema->fsmo.master_dn) == 0) {
     965        if (ldb_dn_compare(samdb_ntds_settings_dn(ldb, tmp_ctx), schema->fsmo.master_dn) == 0) {
    858966                schema->fsmo.we_are_master = true;
    859967        } else {
     
    861969        }
    862970
    863         DEBUG(5, ("schema_fsmo_init: we are master: %s\n",
    864                   (schema->fsmo.we_are_master?"yes":"no")));
    865 
    866         *schema_out = schema;
     971        DEBUG(5, ("schema_fsmo_init: we are master[%s] updates allowed[%s]\n",
     972                  (schema->fsmo.we_are_master?"yes":"no"),
     973                  (schema->fsmo.update_allowed?"yes":"no")));
     974
     975        *schema_out = talloc_steal(mem_ctx, schema);
     976        talloc_free(tmp_ctx);
    867977        return LDB_SUCCESS;
    868978}
  • vendor/current/source4/dsdb/schema/schema_prefixmap.c

    r740 r988  
    156156
    157157        /* dup memory for bin-oid prefix to be added */
    158         bin_oid = data_blob_dup_talloc(pfm, &bin_oid);
     158        bin_oid = data_blob_dup_talloc(pfm, bin_oid);
    159159        W_ERROR_HAVE_NO_MEMORY(bin_oid.data);
    160160
     
    312312                /* return error in read-only mode */
    313313                if (!can_change_pfm) {
     314                        DEBUG(0, ("Unable to convert %s to an attid, and can_change_pfm=false!\n", oid));
    314315                        return werr;
    315316                }
     
    616617        /* copy entries from schema_prefixMap */
    617618        for (i = 0; i < pfm->length; i++) {
    618                 blob = data_blob_dup_talloc(ctr, &pfm->prefixes[i].bin_oid);
     619                blob = data_blob_dup_talloc(ctr, pfm->prefixes[i].bin_oid);
    619620                if (!blob.data) {
    620621                        talloc_free(ctr);
  • vendor/current/source4/dsdb/schema/schema_query.c

    r740 r988  
    2323#include "includes.h"
    2424#include "dsdb/samdb/samdb.h"
     25#include <ldb_module.h>
    2526#include "lib/util/binsearch.h"
    2627#include "lib/util/tsort.h"
     28#include "util/dlinklist.h"
    2729
    2830static const char **dsdb_full_attribute_list_internal(TALLOC_CTX *mem_ctx,
     
    329331}
    330332
    331 /* Return a full attribute list for a given class list (as a ldb_message_element)
     333/* Return a full attribute list for a given class list
    332334
    333335   Via attribute_list_from_class() this calls itself when recursing on auxiliary classes
     
    444446        return &attr->schemaIDGUID;
    445447}
     448
     449/*
     450 * Sort a "objectClass" attribute (LDB message element "objectclass_element")
     451 * into correct order and validate that all object classes specified actually
     452 * exist in the schema.
     453 * The output is written in an existing LDB message element
     454 * "out_objectclass_element" where the values will be allocated on "mem_ctx".
     455 */
     456int dsdb_sort_objectClass_attr(struct ldb_context *ldb,
     457                               const struct dsdb_schema *schema,
     458                               const struct ldb_message_element *objectclass_element,
     459                               TALLOC_CTX *mem_ctx,
     460                               struct ldb_message_element *out_objectclass_element)
     461{
     462        unsigned int i, lowest;
     463        struct class_list {
     464                struct class_list *prev, *next;
     465                const struct dsdb_class *objectclass;
     466        } *unsorted = NULL, *sorted = NULL, *current = NULL,
     467          *poss_parent = NULL, *new_parent = NULL,
     468          *current_lowest = NULL, *current_lowest_struct = NULL;
     469        struct ldb_message_element *el;
     470        TALLOC_CTX *tmp_mem_ctx;
     471
     472        tmp_mem_ctx = talloc_new(mem_ctx);
     473        if (tmp_mem_ctx == NULL) {
     474                return ldb_oom(ldb);
     475        }
     476
     477        /*
     478         * DESIGN:
     479         *
     480         * We work on 4 different 'bins' (implemented here as linked lists):
     481         *
     482         * * sorted:       the eventual list, in the order we wish to push
     483         *                 into the database.  This is the only ordered list.
     484         *
     485         * * parent_class: The current parent class 'bin' we are
     486         *                 trying to find subclasses for
     487         *
     488         * * subclass:     The subclasses we have found so far
     489         *
     490         * * unsorted:     The remaining objectClasses
     491         *
     492         * The process is a matter of filtering objectClasses up from
     493         * unsorted into sorted.  Order is irrelevent in the later 3 'bins'.
     494         *
     495         * We start with 'top' (found and promoted to parent_class
     496         * initially).  Then we find (in unsorted) all the direct
     497         * subclasses of 'top'.  parent_classes is concatenated onto
     498         * the end of 'sorted', and subclass becomes the list in
     499         * parent_class.
     500         *
     501         * We then repeat, until we find no more subclasses.  Any left
     502         * over classes are added to the end.
     503         *
     504         */
     505
     506        /*
     507         * Firstly, dump all the "objectClass" values into the unsorted bin,
     508         * except for 'top', which is special
     509         */
     510        for (i=0; i < objectclass_element->num_values; i++) {
     511                current = talloc(tmp_mem_ctx, struct class_list);
     512                if (!current) {
     513                        talloc_free(tmp_mem_ctx);
     514                        return ldb_oom(ldb);
     515                }
     516                current->objectclass = dsdb_class_by_lDAPDisplayName_ldb_val(schema, &objectclass_element->values[i]);
     517                if (!current->objectclass) {
     518                        ldb_asprintf_errstring(ldb, "objectclass %.*s is not a valid objectClass in schema",
     519                                               (int)objectclass_element->values[i].length, (const char *)objectclass_element->values[i].data);
     520                        /* This looks weird, but windows apparently returns this for invalid objectClass values */
     521                        talloc_free(tmp_mem_ctx);
     522                        return LDB_ERR_NO_SUCH_ATTRIBUTE;
     523                } else if (current->objectclass->isDefunct) {
     524                        ldb_asprintf_errstring(ldb, "objectclass %.*s marked as isDefunct objectClass in schema - not valid for new objects",
     525                                               (int)objectclass_element->values[i].length, (const char *)objectclass_element->values[i].data);
     526                        /* This looks weird, but windows apparently returns this for invalid objectClass values */
     527                        talloc_free(tmp_mem_ctx);
     528                        return LDB_ERR_NO_SUCH_ATTRIBUTE;
     529                }
     530
     531                /* Don't add top to list, we will do that later */
     532                if (ldb_attr_cmp("top", current->objectclass->lDAPDisplayName) != 0) {
     533                        DLIST_ADD_END(unsorted, current);
     534                }
     535        }
     536
     537
     538        /* Add top here, to prevent duplicates */
     539        current = talloc(tmp_mem_ctx, struct class_list);
     540        current->objectclass = dsdb_class_by_lDAPDisplayName(schema, "top");
     541        DLIST_ADD_END(sorted, current);
     542
     543        /* For each object: find parent chain */
     544        for (current = unsorted; current != NULL; current = current->next) {
     545                for (poss_parent = unsorted; poss_parent; poss_parent = poss_parent->next) {
     546                        if (ldb_attr_cmp(poss_parent->objectclass->lDAPDisplayName, current->objectclass->subClassOf) == 0) {
     547                                break;
     548                        }
     549                }
     550                /* If we didn't get to the end of the list, we need to add this parent */
     551                if (poss_parent || (ldb_attr_cmp("top", current->objectclass->subClassOf) == 0)) {
     552                        continue;
     553                }
     554
     555                new_parent = talloc(tmp_mem_ctx, struct class_list);
     556                new_parent->objectclass = dsdb_class_by_lDAPDisplayName(schema, current->objectclass->subClassOf);
     557                DLIST_ADD_END(unsorted, new_parent);
     558        }
     559
     560        /* For each object: order by hierarchy */
     561        while (unsorted != NULL) {
     562                lowest = UINT_MAX;
     563                current_lowest = current_lowest_struct = NULL;
     564                for (current = unsorted; current != NULL; current = current->next) {
     565                        if (current->objectclass->subClass_order <= lowest) {
     566                                /*
     567                                 * According to MS-ADTS 3.1.1.1.4 structural
     568                                 * and 88 object classes are always listed after
     569                                 * the other class types in a subclass hierarchy
     570                                 */
     571                                if (current->objectclass->objectClassCategory > 1) {
     572                                        current_lowest = current;
     573                                } else {
     574                                        current_lowest_struct = current;
     575                                }
     576                                lowest = current->objectclass->subClass_order;
     577                        }
     578                }
     579                if (current_lowest == NULL) {
     580                        current_lowest = current_lowest_struct;
     581                }
     582
     583                if (current_lowest != NULL) {
     584                        DLIST_REMOVE(unsorted,current_lowest);
     585                        DLIST_ADD_END(sorted,current_lowest);
     586                }
     587        }
     588
     589        /* Now rebuild the sorted "objectClass" message element */
     590        el = out_objectclass_element;
     591
     592        el->flags = objectclass_element->flags;
     593        el->name = talloc_strdup(mem_ctx, objectclass_element->name);
     594        if (el->name == NULL) {
     595                talloc_free(tmp_mem_ctx);
     596                return ldb_oom(ldb);
     597        }
     598        el->num_values = 0;
     599        el->values = NULL;
     600        for (current = sorted; current != NULL; current = current->next) {
     601                el->values = talloc_realloc(mem_ctx, el->values,
     602                                            struct ldb_val, el->num_values + 1);
     603                if (el->values == NULL) {
     604                        talloc_free(tmp_mem_ctx);
     605                        return ldb_oom(ldb);
     606                }
     607                el->values[el->num_values] = data_blob_string_const(current->objectclass->lDAPDisplayName);
     608
     609                ++(el->num_values);
     610        }
     611
     612        talloc_free(tmp_mem_ctx);
     613        return LDB_SUCCESS;
     614}
  • vendor/current/source4/dsdb/schema/schema_set.c

    r740 r988  
    55   Copyright (C) Stefan Metzmacher <metze@samba.org> 2006-2007
    66   Copyright (C) Andrew Bartlett <abartlet@samba.org> 2006-2008
     7   Copyright (C) Matthieu Patou <mat@matws.net> 2011
    78
    89   This program is free software; you can redistribute it and/or modify
     
    3031#include "lib/util/tsort.h"
    3132
     33/* change this when we change something in our schema code that
     34 * requires a re-index of the database
     35 */
     36#define SAMDB_INDEXING_VERSION "2"
     37
    3238/*
    3339  override the name to attribute handler function
     
    4551        return a->ldb_schema_attribute;
    4652}
    47 
    48 static int dsdb_schema_set_attributes(struct ldb_context *ldb, struct dsdb_schema *schema, bool write_attributes)
     53/*
     54 * Set the attribute handlers onto the LDB, and potentially write the
     55 * @INDEXLIST, @IDXONE and @ATTRIBUTES records.  The @ATTRIBUTES records
     56 * are required so we can operate on a schema-less database (say the
     57 * backend during emergency fixes) and during the schema load.
     58 */
     59static int dsdb_schema_set_indices_and_attributes(struct ldb_context *ldb, struct dsdb_schema *schema, bool write_indices_and_attributes)
    4960{
    5061        int ret = LDB_SUCCESS;
     
    6071        ldb_schema_attribute_set_override_handler(ldb, dsdb_attribute_handler_override, schema);
    6172
    62         if (!write_attributes) {
     73        if (!write_indices_and_attributes) {
    6374                return ret;
    6475        }
     
    91102
    92103        ret = ldb_msg_add_string(msg_idx, "@IDXONE", "1");
     104        if (ret != LDB_SUCCESS) {
     105                goto op_error;
     106        }
     107
     108
     109        ret = ldb_msg_add_string(msg_idx, "@IDXVERSION", SAMDB_INDEXING_VERSION);
    93110        if (ret != LDB_SUCCESS) {
    94111                goto op_error;
     
    200217}
    201218
     219
     220/*
     221  create extra attribute shortcuts
     222 */
     223static void dsdb_setup_attribute_shortcuts(struct ldb_context *ldb, struct dsdb_schema *schema)
     224{
     225        struct dsdb_attribute *attribute;
     226
     227        /* setup fast access to one_way_link and DN format */
     228        for (attribute=schema->attributes; attribute; attribute=attribute->next) {
     229                attribute->dn_format = dsdb_dn_oid_to_format(attribute->syntax->ldap_oid);
     230
     231                if (attribute->dn_format == DSDB_INVALID_DN) {
     232                        attribute->one_way_link = false;
     233                        continue;
     234                }
     235
     236                /* these are not considered to be one way links for
     237                   the purpose of DN link fixups */
     238                if (ldb_attr_cmp("distinguishedName", attribute->lDAPDisplayName) == 0 ||
     239                    ldb_attr_cmp("objectCategory", attribute->lDAPDisplayName) == 0) {
     240                        attribute->one_way_link = false;
     241                        continue;
     242                }
     243
     244                if (attribute->linkID == 0) {
     245                        attribute->one_way_link = true;
     246                        continue;
     247                }
     248                /* handle attributes with a linkID but no backlink */
     249                if ((attribute->linkID & 1) == 0 &&
     250                    dsdb_attribute_by_linkID(schema, attribute->linkID + 1) == NULL) {
     251                        attribute->one_way_link = true;
     252                        continue;
     253                }
     254                attribute->one_way_link = false;
     255        }
     256}
     257
    202258static int uint32_cmp(uint32_t c1, uint32_t c2)
    203259{
     
    272328        unsigned int i;
    273329        unsigned int num_int_id;
     330        int ret;
     331
     332        for (i=0; i < schema->classes_to_remove_size; i++) {
     333                DLIST_REMOVE(schema->classes, schema->classes_to_remove[i]);
     334                TALLOC_FREE(schema->classes_to_remove[i]);
     335        }
     336        for (i=0; i < schema->attributes_to_remove_size; i++) {
     337                DLIST_REMOVE(schema->attributes, schema->attributes_to_remove[i]);
     338                TALLOC_FREE(schema->attributes_to_remove[i]);
     339        }
     340
     341        TALLOC_FREE(schema->classes_to_remove);
     342        schema->classes_to_remove_size = 0;
     343        TALLOC_FREE(schema->attributes_to_remove);
     344        schema->attributes_to_remove_size = 0;
    274345
    275346        /* free all caches */
     
    354425        TYPESAFE_QSORT(schema->attributes_by_linkID, schema->num_attributes, dsdb_compare_attribute_by_linkID);
    355426
     427        dsdb_setup_attribute_shortcuts(ldb, schema);
     428
     429        ret = schema_fill_constructed(schema);
     430        if (ret != LDB_SUCCESS) {
     431                dsdb_sorted_accessors_free(schema);
     432                return ret;
     433        }
     434
    356435        return LDB_SUCCESS;
    357436
     
    361440}
    362441
    363 int dsdb_setup_schema_inversion(struct ldb_context *ldb, struct dsdb_schema *schema)
    364 {
    365         /* Walk the list of schema classes */
    366 
    367         /*  For each subClassOf, add us to subclasses of the parent */
    368 
    369         /* collect these subclasses into a recursive list of total subclasses, preserving order */
    370 
    371         /* For each subclass under 'top', write the index from it's
    372          * order as an integer in the dsdb_class (for sorting
    373          * objectClass lists efficiently) */
    374 
    375         /* Walk the list of schema classes */
    376 
    377         /*  Create a 'total possible superiors' on each class */
    378         return LDB_SUCCESS;
    379 }
    380 
    381442/**
    382443 * Attach the schema to an opaque pointer on the ldb,
    383444 * so ldb modules can find it
    384445 */
     446int dsdb_set_schema_refresh_function(struct ldb_context *ldb,
     447                                     dsdb_schema_refresh_fn refresh_fn,
     448                                     struct ldb_module *module)
     449{
     450        int ret = ldb_set_opaque(ldb, "dsdb_schema_refresh_fn", refresh_fn);
     451        if (ret != LDB_SUCCESS) {
     452                return ret;
     453        }
     454
     455        ret = ldb_set_opaque(ldb, "dsdb_schema_refresh_fn_private_data", module);
     456        if (ret != LDB_SUCCESS) {
     457                return ret;
     458        }
     459        return LDB_SUCCESS;
     460}
     461
     462/**
     463 * Attach the schema to an opaque pointer on the ldb,
     464 * so ldb modules can find it
     465 */
    385466int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
    386467{
     
    389470
    390471        ret = dsdb_setup_sorted_accessors(ldb, schema);
    391         if (ret != LDB_SUCCESS) {
    392                 return ret;
    393         }
    394 
    395         ret = schema_fill_constructed(schema);
    396472        if (ret != LDB_SUCCESS) {
    397473                return ret;
     
    412488        }
    413489
     490        talloc_steal(ldb, schema);
     491
    414492        ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", NULL);
    415493        if (ret != LDB_SUCCESS) {
     
    418496
    419497        /* Set the new attributes based on the new schema */
    420         ret = dsdb_schema_set_attributes(ldb, schema, true);
     498        ret = dsdb_schema_set_indices_and_attributes(ldb, schema, true);
    421499        if (ret != LDB_SUCCESS) {
    422500                return ret;
     
    433511/**
    434512 * Make this ldb use a specified schema, already fully calculated and belonging to another ldb
     513 *
     514 * The write_indices_and_attributes controls writing of the @ records
     515 * because we cannot write to a database that does not yet exist on
     516 * disk.
    435517 */
    436518int dsdb_reference_schema(struct ldb_context *ldb, struct dsdb_schema *schema,
    437                           bool write_attributes)
     519                          bool write_indices_and_attributes)
    438520{
    439521        int ret;
     
    459541        }
    460542
    461         ret = dsdb_schema_set_attributes(ldb, schema, write_attributes);
     543        ret = ldb_set_opaque(ldb, "dsdb_refresh_fn", NULL);
     544        if (ret != LDB_SUCCESS) {
     545                return ret;
     546        }
     547
     548        ret = ldb_set_opaque(ldb, "dsdb_refresh_fn_private_data", NULL);
     549        if (ret != LDB_SUCCESS) {
     550                return ret;
     551        }
     552
     553        ret = dsdb_schema_set_indices_and_attributes(ldb, schema, write_indices_and_attributes);
    462554        if (ret != LDB_SUCCESS) {
    463555                return ret;
     
    474566        int ret;
    475567        void *use_global_schema = (void *)1;
    476         if (!global_schema) {
     568        ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", use_global_schema);
     569        if (ret != LDB_SUCCESS) {
     570                return ret;
     571        }
     572
     573        if (global_schema == NULL) {
    477574                return LDB_SUCCESS;
    478575        }
    479         ret = ldb_set_opaque(ldb, "dsdb_use_global_schema", use_global_schema);
    480         if (ret != LDB_SUCCESS) {
    481                 return ret;
    482         }
    483576
    484577        /* Set the new attributes based on the new schema */
    485         ret = dsdb_schema_set_attributes(ldb, global_schema, false /* Don't write attributes, it's expensive */);
     578        ret = dsdb_schema_set_indices_and_attributes(ldb, global_schema, false /* Don't write indices and attributes, it's expensive */);
    486579        if (ret == LDB_SUCCESS) {
    487580                /* Keep a reference to this schema, just in case the original copy is replaced */
     
    508601{
    509602        const void *p;
    510         struct dsdb_schema *schema_out;
    511         struct dsdb_schema *schema_in;
     603        struct dsdb_schema *schema_out = NULL;
     604        struct dsdb_schema *schema_in = NULL;
     605        dsdb_schema_refresh_fn refresh_fn;
     606        struct ldb_module *loaded_from_module;
    512607        bool use_global_schema;
    513608        TALLOC_CTX *tmp_ctx = talloc_new(reference_ctx);
    514         if (!tmp_ctx) {
     609        if (tmp_ctx == NULL) {
    515610                return NULL;
    516611        }
     
    522617        } else {
    523618                p = ldb_get_opaque(ldb, "dsdb_schema");
    524 
    525                 schema_in = talloc_get_type(p, struct dsdb_schema);
    526                 if (!schema_in) {
    527                         talloc_free(tmp_ctx);
    528                         return NULL;
    529                 }
    530         }
    531 
    532         if (schema_in->refresh_fn && !schema_in->refresh_in_progress) {
    533                 if (!talloc_reference(tmp_ctx, schema_in)) {
    534                         /*
    535                          * ensure that the schema_in->refresh_in_progress
    536                          * remains valid for the right amount of time
    537                          */
    538                         talloc_free(tmp_ctx);
    539                         return NULL;
    540                 }
    541                 schema_in->refresh_in_progress = true;
    542                 /* This may change schema, if it needs to reload it from disk */
    543                 schema_out = schema_in->refresh_fn(schema_in->loaded_from_module,
    544                                                    schema_in,
    545                                                    use_global_schema);
    546                 schema_in->refresh_in_progress = false;
     619                if (p != NULL) {
     620                        schema_in = talloc_get_type_abort(p, struct dsdb_schema);
     621                }
     622        }
     623
     624        refresh_fn = ldb_get_opaque(ldb, "dsdb_schema_refresh_fn");
     625        if (refresh_fn) {
     626                loaded_from_module = ldb_get_opaque(ldb, "dsdb_schema_refresh_fn_private_data");
     627
     628                SMB_ASSERT(loaded_from_module && (ldb_module_get_ctx(loaded_from_module) == ldb));
     629        }
     630
     631        if (refresh_fn) {
     632                /* We need to guard against recurisve calls here */
     633                if (ldb_set_opaque(ldb, "dsdb_schema_refresh_fn", NULL) != LDB_SUCCESS) {
     634                        ldb_debug_set(ldb, LDB_DEBUG_FATAL,
     635                                      "dsdb_get_schema: clearing dsdb_schema_refresh_fn failed");
     636                } else {
     637                        schema_out = refresh_fn(loaded_from_module,
     638                                                ldb_get_event_context(ldb),
     639                                                schema_in,
     640                                                use_global_schema);
     641                }
     642                if (ldb_set_opaque(ldb, "dsdb_schema_refresh_fn", refresh_fn) != LDB_SUCCESS) {
     643                        ldb_debug_set(ldb, LDB_DEBUG_FATAL,
     644                                      "dsdb_get_schema: re-setting dsdb_schema_refresh_fn failed");
     645                }
     646                if (!schema_out) {
     647                        schema_out = schema_in;
     648                        ldb_debug_set(ldb, LDB_DEBUG_FATAL,
     649                                      "dsdb_get_schema: refresh_fn() failed");
     650                }
    547651        } else {
    548652                schema_out = schema_in;
     
    624728
    625729/**
    626  * Add an element to the schema (attribute or class) from an LDB message
    627  */
    628 WERROR dsdb_schema_set_el_from_ldb_msg(struct ldb_context *ldb, struct dsdb_schema *schema,
    629                                        struct ldb_message *msg)
    630 {
     730 * @brief Add a new element to the schema and checks if it's a duplicate
     731 *
     732 * This function will add a new element to the schema and checks for existing
     733 * duplicates.
     734 *
     735 * @param[in]  ldb                A pointer to an LDB context
     736 *
     737 * @param[in]  schema             A pointer to the dsdb_schema where the element
     738 *                                will be added.
     739 *
     740 * @param[in]  msg                The ldb_message object representing the element
     741 *                                to add.
     742 *
     743 * @param[in]  checkdups          A boolean to indicate if checks for duplicates
     744 *                                should be done.
     745 *
     746 * @return                        A WERROR code
     747 */
     748WERROR dsdb_schema_set_el_from_ldb_msg_dups(struct ldb_context *ldb, struct dsdb_schema *schema,
     749                                            struct ldb_message *msg, bool checkdups)
     750{
     751        const char* tstring;
     752        time_t ts;
     753        tstring = ldb_msg_find_attr_as_string(msg, "whenChanged", NULL);
     754        /* keep a trace of the ts of the most recently changed object */
     755        if (tstring) {
     756                ts = ldb_string_to_time(tstring);
     757                if (ts > schema->ts_last_change) {
     758                        schema->ts_last_change = ts;
     759                }
     760        }
    631761        if (samdb_find_attribute(ldb, msg,
    632762                                 "objectclass", "attributeSchema") != NULL) {
    633                 return dsdb_attribute_from_ldb(ldb, schema, msg);
     763
     764                return dsdb_set_attribute_from_ldb_dups(ldb, schema, msg, checkdups);
    634765        } else if (samdb_find_attribute(ldb, msg,
    635766                                 "objectclass", "classSchema") != NULL) {
    636                 return dsdb_class_from_ldb(schema, msg);
    637         }
    638 
     767                return dsdb_set_class_from_ldb_dups(schema, msg, checkdups);
     768        }
    639769        /* Don't fail on things not classes or attributes */
    640770        return WERR_OK;
     771}
     772
     773WERROR dsdb_schema_set_el_from_ldb_msg(struct ldb_context *ldb,
     774                                       struct dsdb_schema *schema,
     775                                       struct ldb_message *msg)
     776{
     777        return dsdb_schema_set_el_from_ldb_msg_dups(ldb, schema, msg, false);
    641778}
    642779
     
    647784 */
    648785
    649 WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb, const char *pf, const char *df)
     786WERROR dsdb_set_schema_from_ldif(struct ldb_context *ldb,
     787                                 const char *pf, const char *df,
     788                                 const char *dn)
    650789{
    651790        struct ldb_ldif *ldif;
     
    666805
    667806        schema = dsdb_new_schema(mem_ctx);
    668 
     807        if (!schema) {
     808                goto nomem;
     809        }
    669810        schema->fsmo.we_are_master = true;
    670         schema->fsmo.master_dn = ldb_dn_new_fmt(schema, ldb, "@PROVISION_SCHEMA_MASTER");
     811        schema->fsmo.update_allowed = true;
     812        schema->fsmo.master_dn = ldb_dn_new(schema, ldb, "@PROVISION_SCHEMA_MASTER");
    671813        if (!schema->fsmo.master_dn) {
    672814                goto nomem;
     
    708850        }
    709851
     852        schema->ts_last_change = 0;
    710853        /* load the attribute and class definitions out of df */
    711854        while ((ldif = ldb_ldif_read_string(ldb, &df))) {
  • vendor/current/source4/dsdb/schema/schema_syntax.c

    r740 r988  
    210210
    211211        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    212                 return WERR_FOOBAR;
     212                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    213213        }
    214214
     
    230230                W_ERROR_HAVE_NO_MEMORY(blobs[i].data);
    231231
    232                 if (strcmp("TRUE", (const char *)in->values[i].data) == 0) {
     232                if (in->values[i].length >= 4 &&
     233                    strncmp("TRUE", (const char *)in->values[i].data, in->values[i].length) == 0) {
    233234                        SIVAL(blobs[i].data, 0, 0x00000001);
    234                 } else if (strcmp("FALSE", (const char *)in->values[i].data) == 0) {
     235                } else if (in->values[i].length >= 5 &&
     236                           strncmp("FALSE", (const char *)in->values[i].data, in->values[i].length) == 0) {
    235237                        SIVAL(blobs[i].data, 0, 0x00000000);
    236238                } else {
     
    249251
    250252        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    251                 return WERR_FOOBAR;
     253                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    252254        }
    253255
    254256        for (i=0; i < in->num_values; i++) {
    255                 int t, f;
    256 
    257                 t = strncmp("TRUE",
     257                if (in->values[i].length == 0) {
     258                        return WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
     259                }
     260
     261                if (in->values[i].length >= 4 &&
     262                    strncmp("TRUE",
    258263                            (const char *)in->values[i].data,
    259                             in->values[i].length);
    260                 f = strncmp("FALSE",
     264                            in->values[i].length) == 0) {
     265                        continue;
     266                }
     267                if (in->values[i].length >= 5 &&
     268                    strncmp("FALSE",
    261269                            (const char *)in->values[i].data,
    262                             in->values[i].length);
    263 
    264                 if (t != 0 && f != 0) {
    265                         return WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
    266                 }
     270                            in->values[i].length) == 0) {
     271                        continue;
     272                }
     273                return WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
    267274        }
    268275
     
    319326
    320327        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    321                 return WERR_FOOBAR;
     328                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    322329        }
    323330
     
    358365
    359366        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    360                 return WERR_FOOBAR;
     367                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    361368        }
    362369
     
    446453
    447454        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    448                 return WERR_FOOBAR;
     455                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    449456        }
    450457
     
    483490
    484491        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    485                 return WERR_FOOBAR;
     492                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    486493        }
    487494
     
    551558
    552559                v = BVAL(in->value_ctr.values[i].blob->data, 0);
     560                if (v == 0) {
     561                        /* special case for 1601 zero timestamp */
     562                        out->values[i] = data_blob_string_const("16010101000000.0Z");
     563                        continue;
     564                }
    553565                v *= 10000000;
    554566                t = nt_time_to_unix(v);
     
    581593
    582594        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    583                 return WERR_FOOBAR;
     595                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    584596        }
    585597
     
    604616                W_ERROR_HAVE_NO_MEMORY(blobs[i].data);
    605617
     618                if (ldb_val_string_cmp(&in->values[i], "16010101000000.0Z") == 0) {
     619                        SBVALS(blobs[i].data, 0, 0);
     620                        continue;
     621                }
     622
    606623                t = ldb_string_utc_to_time((const char *)in->values[i].data);
    607624                unix_to_nt_time(&v, t);
     
    621638
    622639        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    623                 return WERR_FOOBAR;
     640                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    624641        }
    625642
     
    634651                memcpy(buf, in->values[i].data, in->values[i].length);
    635652
    636                 errno = 0;
    637653                t = ldb_string_utc_to_time(buf);
    638                 if (errno != 0) {
     654                if (t == 0) {
    639655                        return WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
    640656                }
     
    691707
    692708                v = BVAL(in->value_ctr.values[i].blob->data, 0);
     709                if (v == 0) {
     710                        /* special case for 1601 zero timestamp */
     711                        out->values[i] = data_blob_string_const("16010101000000.0Z");
     712                        continue;
     713                }
    693714                v *= 10000000;
    694715                t = nt_time_to_unix(v);
     
    713734
    714735        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    715                 return WERR_FOOBAR;
     736                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    716737        }
    717738
     
    737758                W_ERROR_HAVE_NO_MEMORY(blobs[i].data);
    738759
     760                if (ldb_val_string_cmp(&in->values[i], "16010101000000.0Z") == 0) {
     761                        SBVALS(blobs[i].data, 0, 0);
     762                        continue;
     763                }
     764
    739765                ret = ldb_val_to_time(&in->values[i], &t);
    740766                if (ret != LDB_SUCCESS) {
     
    757783
    758784        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    759                 return WERR_FOOBAR;
     785                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    760786        }
    761787
     
    776802
    777803                if (attr->rangeUpper) {
    778                         if ((int32_t)t > (int32_t)*attr->rangeLower) {
     804                        if ((int32_t)t > (int32_t)*attr->rangeUpper) {
    779805                                return WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
    780806                        }
     
    811837
    812838                out->values[i] = data_blob_dup_talloc(out->values,
    813                                                       in->value_ctr.values[i].blob);
     839                                                      *in->value_ctr.values[i].blob);
    814840                W_ERROR_HAVE_NO_MEMORY(out->values[i].data);
    815841        }
     
    828854
    829855        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    830                 return WERR_FOOBAR;
     856                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    831857        }
    832858
     
    845871                out->value_ctr.values[i].blob   = &blobs[i];
    846872
    847                 blobs[i] = data_blob_dup_talloc(blobs, &in->values[i]);
     873                blobs[i] = data_blob_dup_talloc(blobs, in->values[i]);
    848874                W_ERROR_HAVE_NO_MEMORY(blobs[i].data);
    849875        }
     
    857883{
    858884        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    859                 return WERR_FOOBAR;
     885                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    860886        }
    861887
     
    883909
    884910        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    885                 return WERR_FOOBAR;
     911                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    886912        }
    887913
     
    10291055
    10301056                if (in->value_ctr.values[i].blob == NULL) {
     1057                        DEBUG(0, ("Attribute has no value\n"));
    10311058                        return WERR_FOOBAR;
    10321059                }
    10331060
    10341061                if (in->value_ctr.values[i].blob->length != 4) {
     1062                        DEBUG(0, ("Attribute has a value with 0 length\n"));
    10351063                        return WERR_FOOBAR;
    10361064                }
     
    10671095{
    10681096        unsigned int i;
    1069 
    1070         SMB_ASSERT(ctx->pfm_remote);
     1097        const struct dsdb_schema_prefixmap *prefixmap;
     1098
     1099        if (ctx->pfm_remote != NULL) {
     1100                prefixmap = ctx->pfm_remote;
     1101        } else {
     1102                prefixmap = ctx->schema->prefixmap;
     1103        }
     1104        SMB_ASSERT(prefixmap);
    10711105
    10721106        out->flags      = 0;
     
    10931127                attid = IVAL(in->value_ctr.values[i].blob->data, 0);
    10941128
    1095                 status = dsdb_schema_pfm_oid_from_attid(ctx->pfm_remote, attid,
     1129                status = dsdb_schema_pfm_oid_from_attid(prefixmap, attid,
    10961130                                                        out->values, &oid);
    10971131                if (!W_ERROR_IS_OK(status)) {
     
    12331267                obj_attr = dsdb_attribute_by_lDAPDisplayName(ctx->schema, (const char *)in->values[i].data);
    12341268                if (!obj_attr) {
     1269                        DEBUG(0, ("Unable to find attribute %s in the schema\n", (const char *)in->values[i].data));
    12351270                        return WERR_FOOBAR;
    12361271                }
     
    13351370{
    13361371        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    1337                 return WERR_FOOBAR;
     1372                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    13381373        }
    13391374
     
    13801415                const char *oid = (const char*)in->values[i].data;
    13811416
     1417                if (in->values[i].length == 0) {
     1418                        talloc_free(tmp_ctx);
     1419                        return WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
     1420                }
     1421
    13821422                if (!ber_write_OID_String(tmp_ctx, &blob, oid)) {
    13831423                        DEBUG(0,("ber_write_OID_String() failed for %s\n", oid));
     
    14131453
    14141454        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    1415                 return WERR_FOOBAR;
     1455                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    14161456        }
    14171457
     
    14711511
    14721512        for (i=0; i < out->num_values; i++) {
     1513                size_t converted_size = 0;
    14731514                char *str;
    14741515
     
    14851526                                           in->value_ctr.values[i].blob->data,
    14861527                                           in->value_ctr.values[i].blob->length,
    1487                                            (void **)&str, NULL, false)) {
    1488                         return WERR_FOOBAR;
    1489                 }
    1490 
    1491                 out->values[i] = data_blob_string_const(str);
     1528                                           (void **)&str, &converted_size)) {
     1529                        return WERR_FOOBAR;
     1530                }
     1531
     1532                out->values[i] = data_blob_const(str, converted_size);
    14921533        }
    14931534
     
    15051546
    15061547        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    1507                 return WERR_FOOBAR;
     1548                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    15081549        }
    15091550
     
    15251566                                           CH_UNIX, CH_UTF16,
    15261567                                           in->values[i].data, in->values[i].length,
    1527                                            (void **)&blobs[i].data, &blobs[i].length, false)) {
     1568                                           (void **)&blobs[i].data, &blobs[i].length)) {
    15281569                        return WERR_FOOBAR;
    15291570                }
     
    15421583
    15431584        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    1544                 return WERR_FOOBAR;
     1585                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    15451586        }
    15461587
     
    15501591                                   val->length,
    15511592                                   (void **)&dst,
    1552                                    &size, false);
     1593                                   &size);
    15531594        TALLOC_FREE(dst);
    15541595        if (!ok) {
     
    15791620
    15801621        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    1581                 return WERR_FOOBAR;
     1622                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    15821623        }
    15831624
     
    17181759
    17191760        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    1720                 return WERR_FOOBAR;
     1761                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    17211762        }
    17221763
     
    18001841
    18011842        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    1802                 return WERR_FOOBAR;
     1843                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    18031844        }
    18041845
     
    18831924
    18841925        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    1885                 return WERR_FOOBAR;
     1926                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    18861927        }
    18871928
     
    19692010                }
    19702011
    1971                 status = GUID_to_ndr_blob(&id3.guid, tmp_ctx, &guid_blob);
    1972                 if (!NT_STATUS_IS_OK(status)) {
    1973                         talloc_free(tmp_ctx);
    1974                         return ntstatus_to_werror(status);
    1975                 }
    1976 
    1977                 ret = ldb_dn_set_extended_component(dn, "GUID", &guid_blob);
    1978                 if (ret != LDB_SUCCESS) {
    1979                         talloc_free(tmp_ctx);
    1980                         return WERR_FOOBAR;
    1981                 }
    1982 
    1983                 talloc_free(guid_blob.data);
     2012                if (!GUID_all_zero(&id3.guid)) {
     2013                        status = GUID_to_ndr_blob(&id3.guid, tmp_ctx, &guid_blob);
     2014                        if (!NT_STATUS_IS_OK(status)) {
     2015                                talloc_free(tmp_ctx);
     2016                                return ntstatus_to_werror(status);
     2017                        }
     2018
     2019                        ret = ldb_dn_set_extended_component(dn, "GUID", &guid_blob);
     2020                        if (ret != LDB_SUCCESS) {
     2021                                talloc_free(tmp_ctx);
     2022                                return WERR_FOOBAR;
     2023                        }
     2024                        talloc_free(guid_blob.data);
     2025                }
    19842026
    19852027                if (id3.__ndr_size_sid) {
     
    20242066
    20252067        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    2026                 return WERR_FOOBAR;
     2068                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    20272069        }
    20282070
     
    21032145
    21042146        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    2105                 return WERR_FOOBAR;
     2147                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    21062148        }
    21072149
     
    21732215
    21742216        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    2175                 return WERR_FOOBAR;
     2217                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    21762218        }
    21772219
     
    22282270        for (i=0; i < out->num_values; i++) {
    22292271                size_t len;
     2272                size_t converted_size = 0;
    22302273                char *str;
    22312274
     
    22472290                                           in->value_ctr.values[i].blob->data+4,
    22482291                                           in->value_ctr.values[i].blob->length-4,
    2249                                            (void **)&str, NULL, false)) {
     2292                                           (void **)&str, &converted_size)) {
    22502293                        return WERR_FOOBAR;
    22512294                }
     
    22672310
    22682311        if (attr->attributeID_id == DRSUAPI_ATTID_INVALID) {
    2269                 return WERR_FOOBAR;
     2312                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    22702313        }
    22712314
     
    22902333                                           in->values[i].data,
    22912334                                           in->values[i].length,
    2292                                            (void **)&data, &ret, false)) {
     2335                                           (void **)&data, &ret)) {
    22932336                        return WERR_FOOBAR;
    22942337                }
     
    23292372                .validate_ldb           = dsdb_syntax_BOOL_validate_ldb,
    23302373                .equality               = "booleanMatch",
    2331                 .comment                = "Boolean"
     2374                .comment                = "Boolean",
     2375                .auto_normalise         = true
    23322376        },{
    23332377                .name                   = "Integer",
     
    23402384                .equality               = "integerMatch",
    23412385                .comment                = "Integer",
    2342                 .ldb_syntax             = LDB_SYNTAX_SAMBA_INT32
     2386                .ldb_syntax             = LDB_SYNTAX_SAMBA_INT32,
     2387                .auto_normalise         = true
    23432388        },{
    23442389                .name                   = "String(Octet)",
     
    23512396                .equality               = "octetStringMatch",
    23522397                .comment                = "Octet String",
     2398                .userParameters         = true
    23532399        },{
    23542400                .name                   = "String(Sid)",
     
    23812427                .ldb_to_drsuapi         = dsdb_syntax_INT32_ldb_to_drsuapi,
    23822428                .validate_ldb           = dsdb_syntax_INT32_validate_ldb,
    2383                 .ldb_syntax             = LDB_SYNTAX_SAMBA_INT32
     2429                .ldb_syntax             = LDB_SYNTAX_SAMBA_INT32,
     2430                .auto_normalise         = true
    23842431        },{
    23852432        /* not used in w2k3 forest */
     
    24372484                .equality               = "generalizedTimeMatch",
    24382485                .comment                = "UTC Time",
     2486                .auto_normalise         = true
    24392487        },{
    24402488                .name                   = "String(Generalized-Time)",
     
    24472495                .equality               = "generalizedTimeMatch",
    24482496                .comment                = "Generalized Time",
    2449                 .ldb_syntax             = LDB_SYNTAX_UTC_TIME,
     2497                .auto_normalise         = true
    24502498        },{
    24512499        /* not used in w2k3 schema */
     
    24862534                .comment                = "Large Integer",
    24872535                .ldb_syntax             = LDB_SYNTAX_INTEGER,
     2536                .auto_normalise         = true
    24882537        },{
    24892538                .name                   = "String(NT-Sec-Desc)",
     
    25572606        /* not used in w2k3 schema */
    25582607                .name                   = "Object(Access-Point)",
    2559                 .ldap_oid               = "1.3.6.1.4.1.1466.115.121.1.2",
     2608                .ldap_oid               = DSDB_SYNTAX_ACCESS_POINT,
    25602609                .oMSyntax               = 127,
    25612610                .oMObjectClass          = OMOBJECTCLASS("\x2b\x0c\x02\x87\x73\x1c\x00\x85\x3e"),
     
    26182667
    26192668        for (i=0; i < ARRAY_SIZE(dsdb_syntaxes); i++) {
     2669                /*
     2670                 * We must pretend that userParamters was declared
     2671                 * binary string, so we can store the 'UTF16' (not
     2672                 * really string) structure as given over SAMR to samba
     2673                 */
     2674                if (dsdb_syntaxes[i].userParameters &&
     2675                    (strcasecmp(attr->lDAPDisplayName, "userParameters") == 0))
     2676                {
     2677                        return &dsdb_syntaxes[i];
     2678                }
    26202679                if (attr->oMSyntax != dsdb_syntaxes[i].oMSyntax) continue;
    26212680
     
    26432702                                     const struct drsuapi_DsReplicaAttribute *in,
    26442703                                     TALLOC_CTX *mem_ctx,
    2645                                      struct ldb_message_element *out)
     2704                                     struct ldb_message_element *out,
     2705                                     enum drsuapi_DsAttributeId *local_attid_as_enum)
    26462706{
    26472707        const struct dsdb_attribute *sa;
     
    26592719                        DEBUG(0,(__location__ ": Can't find local ATTID for 0x%08X\n",
    26602720                                 in->attid));
    2661                         return WERR_FOOBAR;
     2721                        return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    26622722                }
    26632723                break;
     
    26762736        if (!sa) {
    26772737                DEBUG(1,(__location__ ": Unknown attributeID_id 0x%08X\n", in->attid));
    2678                 return WERR_FOOBAR;
     2738                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
     2739        }
     2740
     2741        /*
     2742         * We return the same class of attid as we were given.  That
     2743         * is, we trust the remote server not to use an
     2744         * msDS-IntId value in the schema partition
     2745         */
     2746        if (local_attid_as_enum != NULL) {
     2747                *local_attid_as_enum = (enum drsuapi_DsAttributeId)attid_local;
    26792748        }
    26802749
     
    26932762        sa = dsdb_attribute_by_lDAPDisplayName(schema, in->name);
    26942763        if (!sa) {
    2695                 return WERR_FOOBAR;
     2764                return WERR_DS_ATT_NOT_DEF_IN_SCHEMA;
    26962765        }
    26972766
  • vendor/current/source4/dsdb/schema/tests/schema_syntax.c

    r740 r988  
    7575        torture_assert(tctx, ldif, "Failed to parse LDIF for authOrig");
    7676
    77         werr = dsdb_attribute_from_ldb(ldb, schema, ldif->msg);
     77        werr = dsdb_set_attribute_from_ldb(ldb, schema, ldif->msg);
    7878        ldb_ldif_read_free(ldb, ldif);
    79         torture_assert_werr_ok(tctx, werr, "dsdb_attribute_from_ldb() failed!");
     79        torture_assert_werr_ok(tctx, werr, "dsdb_set_attribute_from_ldb() failed!");
    8080
    8181        ldb_res = dsdb_set_schema(ldb, schema);
     
    206206        torture_assert(tctx, priv, "No memory");
    207207
    208         priv->ldb = provision_get_schema(priv, tctx->lp_ctx, NULL);
     208        priv->ldb = provision_get_schema(priv, tctx->lp_ctx, NULL, NULL);
    209209        torture_assert(tctx, priv->ldb, "Failed to load schema from disk");
    210210
Note: See TracChangeset for help on using the changeset viewer.