dsdb: Allow "cn" to be missing on schema import
authorAndrew Bartlett <abartlet@samba.org>
Thu, 26 May 2016 22:28:26 +0000 (10:28 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 6 Jun 2016 06:50:09 +0000 (08:50 +0200)
This avoids a segfault when we remove the duplication of this value from dsdb_convert_object_ex()

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

index d03880792417f42a56c0b6f5827a1912444a684d..2e6177346c778ed2bab4acd3e7d8eed03cb0b098 100644 (file)
@@ -623,6 +623,16 @@ WERROR dsdb_attribute_from_ldb(const struct dsdb_schema *schema,
        }
 
        GET_STRING_LDB(msg, "cn", attr, attr, cn, false);
+
+       /*
+        * This allows for the fact that the CN attribute is not
+        * replicated over DRS, it is only replicated under the alias
+        * 'name'.
+        */
+       if (attr->cn == NULL) {
+               GET_STRING_LDB(msg, "name", attr, attr, cn, true);
+       }
+
        GET_STRING_LDB(msg, "lDAPDisplayName", attr, attr, lDAPDisplayName, true);
        GET_STRING_LDB(msg, "attributeID", attr, attr, attributeID_oid, true);
        if (!schema->prefixmap || schema->prefixmap->length == 0) {
@@ -767,6 +777,16 @@ WERROR dsdb_set_class_from_ldb_dups(struct dsdb_schema *schema,
                return WERR_NOMEM;
        }
        GET_STRING_LDB(msg, "cn", obj, obj, cn, false);
+
+       /*
+        * This allows for the fact that the CN attribute is not
+        * replicated over DRS, it is only replicated under the alias
+        * 'name'.
+        */
+       if (obj->cn == NULL) {
+               GET_STRING_LDB(msg, "name", obj, obj, cn, true);
+       }
+
        GET_STRING_LDB(msg, "lDAPDisplayName", obj, obj, lDAPDisplayName, true);
        GET_STRING_LDB(msg, "governsID", obj, obj, governsID_oid, true);
        if (!schema->prefixmap || schema->prefixmap->length == 0) {