Fix the mess with ldb includes.
[metze/samba/wip.git] / source4 / utils / ad2oLschema.c
index e229bd104b0a20168e531cf26d4a67f7809210c2..236b1fa3506554a4903f572241ca18a3cc852a0e 100644 (file)
@@ -32,7 +32,7 @@
  */
 
 #include "includes.h"
-#include "ldb_includes.h"
+#include "ldb.h"
 #include "system/locale.h"
 #include "lib/ldb/tools/cmdline.h"
 #include "param/param.h"
@@ -75,18 +75,16 @@ static struct ldb_dn *find_schema_dn(struct ldb_context *ldb, TALLOC_CTX *mem_ct
        }
        
        /* Search for rootdse */
-       ldb_ret = ldb_search(ldb, basedn, LDB_SCOPE_BASE, NULL, rootdse_attrs, &rootdse_res);
+       ldb_ret = ldb_search(ldb, mem_ctx, &rootdse_res,
+                            basedn, LDB_SCOPE_BASE, rootdse_attrs, NULL);
        if (ldb_ret != LDB_SUCCESS) {
-               ldb_ret = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, 
-                                "(&(objectClass=dMD)(cn=Schema))", 
-                                NULL, &schema_res);
+               ldb_ret = ldb_search(ldb, mem_ctx, &schema_res, basedn, LDB_SCOPE_SUBTREE,
+                                    NULL, "(&(objectClass=dMD)(cn=Schema))");
                if (ldb_ret) {
                        printf("cn=Schema Search failed: %s\n", ldb_errstring(ldb));
                        return NULL;
                }
 
-               talloc_steal(mem_ctx, schema_res);
-
                if (schema_res->count != 1) {
                        talloc_free(schema_res);
                        printf("Failed to find rootDSE");
@@ -223,13 +221,11 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_sch
 
        for (attribute=schema->attributes; attribute; attribute = attribute->next) {
                const char *name = attribute->lDAPDisplayName;
-               const char *description = attribute->adminDescription;
                const char *oid = attribute->attributeID_oid;
                const char *syntax = attribute->attributeSyntax_oid;
                const char *equality = NULL, *substring = NULL;
                bool single_value = attribute->isSingleValued;
 
-               const struct dsdb_syntax *map = find_syntax_map_by_ad_syntax(attribute->oMSyntax);
                char *schema_entry = NULL;
                int j;
 
@@ -247,11 +243,11 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_sch
                        }
                }
                
-               if (map) {
+               if (attribute->syntax) {
                        /* We might have been asked to remap this oid,
                         * due to a conflict, or lack of
                         * implementation */
-                       syntax = map->ldap_oid;
+                       syntax = attribute->syntax->ldap_oid;
                        /* We might have been asked to remap this oid, due to a conflict */
                        for (j=0; syntax && oid_map && oid_map[j].old_oid; j++) {
                                if (strcasecmp(syntax, oid_map[j].old_oid) == 0) {
@@ -260,8 +256,8 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_sch
                                }
                        }
                        
-                       equality = map->equality;
-                       substring = map->substring;
+                       equality = attribute->syntax->equality;
+                       substring = attribute->syntax->substring;
                }
 
                /* We might have been asked to remap this name, due to a conflict */
@@ -272,7 +268,19 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_sch
                        }
                }
                
-               schema_entry = schema_attribute_description(mem_ctx, target, seperator, oid, name, description, equality, substring, syntax, single_value, false);
+               schema_entry = schema_attribute_description(mem_ctx, 
+                                                           target, 
+                                                           seperator, 
+                                                           oid, 
+                                                           name, 
+                                                           equality, 
+                                                           substring, 
+                                                           syntax, 
+                                                           single_value, 
+                                                           false,
+                                                           NULL, NULL,
+                                                           NULL, NULL,
+                                                           false, false);
 
                if (schema_entry == NULL) {
                        ret.failures++;
@@ -293,12 +301,11 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_sch
        /* This is already sorted to have 'top' and similar classes first */
        for (objectclass=schema->classes; objectclass; objectclass = objectclass->next) {
                const char *name = objectclass->lDAPDisplayName;
-               const char *description = objectclass->adminDescription;
                const char *oid = objectclass->governsID_oid;
                const char *subClassOf = objectclass->subClassOf;
                int objectClassCategory = objectclass->objectClassCategory;
-               char **must;
-               char **may;
+               const char **must;
+               const char **may;
                char *schema_entry = NULL;
                const char *objectclass_name_as_list[] = {
                        objectclass->lDAPDisplayName,
@@ -358,11 +365,11 @@ static struct schema_conv process_convert(struct ldb_context *ldb, enum dsdb_sch
                                                        oid, 
                                                        name,
                                                        NULL, 
-                                                       description,
                                                        subClassOf,
                                                        objectClassCategory,
                                                        must,
-                                                       may);
+                                                       may,
+                                                       NULL);
                if (schema_entry == NULL) {
                        ret.failures++;
                        return ret;