dsdb: specify attributes when loading schema
authorAndrew Bartlett <abartlet@samba.org>
Fri, 14 Oct 2016 02:43:46 +0000 (15:43 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 1 Dec 2016 04:54:22 +0000 (05:54 +0100)
The LDB code performs better when the required attributes are listed, even when it is almost
all the attributes

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/dsdb/samdb/ldb_modules/schema_load.c
source4/dsdb/schema/schema.h

index 6f15a3b3f73cd8bef0d026783ad16cf09d21b9fb..d9814e2d83cf560f3947f6f87c2f4ae058c14b55 100644 (file)
@@ -278,12 +278,18 @@ static int dsdb_schema_from_db(struct ldb_module *module,
        struct ldb_dn *schema_dn = ldb_get_schema_basedn(ldb);
        struct ldb_result *schema_res;
        struct ldb_result *res;
-       static const char *schema_attrs[] = {
+       static const char *schema_head_attrs[] = {
                "prefixMap",
                "schemaInfo",
                "fSMORoleOwner",
                NULL
        };
+       static const char *schema_attrs[] = {
+               DSDB_SCHEMA_COMMON_ATTRS,
+               DSDB_SCHEMA_ATTR_ATTRS,
+               DSDB_SCHEMA_CLASS_ATTRS,
+               NULL
+       };
        unsigned flags;
 
        tmp_ctx = talloc_new(module);
@@ -299,7 +305,7 @@ static int dsdb_schema_from_db(struct ldb_module *module,
         * setup the prefix mappings and schema info
         */
        ret = dsdb_module_search_dn(module, tmp_ctx, &schema_res,
-                                   schema_dn, schema_attrs,
+                                   schema_dn, schema_head_attrs,
                                    DSDB_FLAG_NEXT_MODULE, NULL);
        if (ret == LDB_ERR_NO_SUCH_OBJECT) {
                ldb_reset_err_string(ldb);
@@ -314,10 +320,11 @@ static int dsdb_schema_from_db(struct ldb_module *module,
        }
 
        /*
-        * load the attribute definitions
+        * load the attribute definitions.
         */
        ret = dsdb_module_search(module, tmp_ctx, &res,
-                                schema_dn, LDB_SCOPE_ONELEVEL, NULL,
+                                schema_dn, LDB_SCOPE_ONELEVEL,
+                                schema_attrs,
                                 DSDB_FLAG_NEXT_MODULE |
                                 DSDB_SEARCH_SHOW_DN_IN_STORAGE_FORMAT,
                                 NULL,
index ee2b850530ded15da222fb9d128dc8522629077b..75e4886b0279bfbdfb58e09399d47db906a23e9f 100644 (file)
@@ -266,6 +266,57 @@ struct dsdb_schema {
        bool resolving_in_progress;
 };
 
+#define DSDB_SCHEMA_COMMON_ATTRS                       \
+               "objectClass",                          \
+               "cn",                                   \
+               "lDAPDisplayName",                      \
+               "schemaIDGUID",                         \
+               "objectGUID",                           \
+               "systemFlags",                          \
+               "schemaFlagsEx",                        \
+               "msDs-Schema-Extensions",               \
+               "showInAdvancedViewOnly",               \
+               "adminDisplayName",                     \
+               "adminDescription",                     \
+               "isDefunct",                            \
+               "systemOnly"
+
+#define DSDB_SCHEMA_ATTR_ATTRS                         \
+               "attributeID",                          \
+               "msDS-IntId",                           \
+               "mAPIID",                               \
+               "attributeSecurityGUID",                \
+               "searchFlags",                          \
+               "isMemberOfPartialAttributeSet",        \
+               "linkID",                               \
+               "attributeSyntax",                      \
+               "oMSyntax",                             \
+               "oMObjectClass",                        \
+               "isSingleValued",                       \
+               "rangeLower",                           \
+               "rangeUpper",                           \
+               "extendedCharsAllowed",                 \
+               "classDisplayName",                     \
+               "isEphemeral"
+
+#define DSDB_SCHEMA_CLASS_ATTRS                                \
+                "governsID",                           \
+               "objectClassCategory",                  \
+               "rDNAttID",                             \
+               "defaultObjectCategory",                \
+               "subClassOf",                           \
+               "systemAuxiliaryClass",                 \
+               "auxiliaryClass",                       \
+               "systemMustContain",                    \
+               "systemMayContain",                     \
+               "mustContain",                          \
+               "mayContain",                           \
+               "systemPossSuperiors",                  \
+               "possSuperiors",                        \
+               "defaultSecurityDescriptor",            \
+               "classDisplayName",                     \
+               "defaultHidingValue"
+
 enum dsdb_attr_list_query {
        DSDB_SCHEMA_ALL_MAY,
        DSDB_SCHEMA_ALL_MUST,