s4:provision - Removed dependency on full Samba 3 schema from FDS
[samba.git] / source4 / lib / ldb-samba / ldif_handlers.c
index 59f8622a376a1d452a45dac0cecab1feb6f80b2e..a74687173adfd74bc7f4b98bb4bd746e48ed3017 100644 (file)
@@ -2,7 +2,7 @@
    ldb database library - ldif handlers for Samba
 
    Copyright (C) Andrew Tridgell 2005
-   Copyright (C) Andrew Bartlett 2006-2007
+   Copyright (C) Andrew Bartlett 2006-2009
    Copyright (C) Matthias Dieter Wallnöfer 2009
      ** NOTE! The following LGPL license applies to the ldb
      ** library. This does NOT imply that all of Samba is released
@@ -92,7 +92,7 @@ static int ldif_read_objectSid(struct ldb_context *ldb, void *mem_ctx,
 /*
   convert a NDR formatted blob to a ldif formatted objectSid
 */
-static int ldif_write_objectSid(struct ldb_context *ldb, void *mem_ctx,
+int ldif_write_objectSid(struct ldb_context *ldb, void *mem_ctx,
                                const struct ldb_val *in, struct ldb_val *out)
 {
        struct dom_sid *sid;
@@ -116,7 +116,7 @@ static int ldif_write_objectSid(struct ldb_context *ldb, void *mem_ctx,
        return 0;
 }
 
-static bool ldif_comparision_objectSid_isString(const struct ldb_val *v)
+bool ldif_comparision_objectSid_isString(const struct ldb_val *v)
 {
        if (v->length < 3) {
                return false;
@@ -477,26 +477,8 @@ static int ldif_comparison_objectCategory(struct ldb_context *ldb, void *mem_ctx
                                          const struct ldb_val *v1,
                                          const struct ldb_val *v2)
 {
-
-       int ret, ret1, ret2;
-       struct ldb_val v1_canon, v2_canon;
-       TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
-
-       /* I could try and bail if tmp_ctx was NULL, but what return
-        * value would I use?
-        *
-        * It seems easier to continue on the NULL context 
-        */
-       ret1 = ldif_canonicalise_objectCategory(ldb, tmp_ctx, v1, &v1_canon);
-       ret2 = ldif_canonicalise_objectCategory(ldb, tmp_ctx, v2, &v2_canon);
-
-       if (ret1 == LDB_SUCCESS && ret2 == LDB_SUCCESS) {
-               ret = data_blob_cmp(&v1_canon, &v2_canon);
-       } else {
-               ret = data_blob_cmp(v1, v2);
-       }
-       talloc_free(tmp_ctx);
-       return ret;
+       return ldb_any_comparison(ldb, mem_ctx, ldif_canonicalise_objectCategory,
+                                 v1, v2);
 }
 
 /*
@@ -693,26 +675,8 @@ static int ldif_comparison_prefixMap(struct ldb_context *ldb, void *mem_ctx,
                                     const struct ldb_val *v1,
                                     const struct ldb_val *v2)
 {
-
-       int ret, ret1, ret2;
-       struct ldb_val v1_canon, v2_canon;
-       TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
-
-       /* I could try and bail if tmp_ctx was NULL, but what return
-        * value would I use?
-        *
-        * It seems easier to continue on the NULL context 
-        */
-       ret1 = ldif_canonicalise_prefixMap(ldb, tmp_ctx, v1, &v1_canon);
-       ret2 = ldif_canonicalise_prefixMap(ldb, tmp_ctx, v2, &v2_canon);
-
-       if (ret1 == LDB_SUCCESS && ret2 == LDB_SUCCESS) {
-               ret = data_blob_cmp(&v1_canon, &v2_canon);
-       } else {
-               ret = data_blob_cmp(v1, v2);
-       }
-       talloc_free(tmp_ctx);
-       return ret;
+       return ldb_any_comparison(ldb, mem_ctx, ldif_canonicalise_prefixMap,
+                                 v1, v2);
 }
 
 /* Canonicalisation of two 32-bit integers */
@@ -784,7 +748,7 @@ static int ldif_write_replUpToDateVector(struct ldb_context *ldb, void *mem_ctx,
 static int extended_dn_write_hex(struct ldb_context *ldb, void *mem_ctx,
                                 const struct ldb_val *in, struct ldb_val *out)
 {
-       *out = data_blob_string_const(data_blob_hex_string(mem_ctx, in));
+       *out = data_blob_string_const(data_blob_hex_string_lower(mem_ctx, in));
        if (!out->data) {
                return -1;
        }
@@ -846,6 +810,18 @@ static const struct ldb_schema_syntax samba_syntaxes[] = {
                .ldif_write_fn    = ldif_write_replUpToDateVector,
                .canonicalise_fn  = ldb_handler_copy,
                .comparison_fn    = ldb_comparison_binary
+       },{
+               .name             = DSDB_SYNTAX_BINARY_DN,
+               .ldif_read_fn     = ldb_handler_copy,
+               .ldif_write_fn    = ldb_handler_copy,
+               .canonicalise_fn  = dsdb_dn_binary_canonicalise,
+               .comparison_fn    = dsdb_dn_binary_comparison
+       },{
+               .name             = DSDB_SYNTAX_STRING_DN,
+               .ldif_read_fn     = ldb_handler_copy,
+               .ldif_write_fn    = ldb_handler_copy,
+               .canonicalise_fn  = dsdb_dn_string_canonicalise,
+               .comparison_fn    = dsdb_dn_string_comparison
        },
 };
 
@@ -879,6 +855,7 @@ static const struct {
        { "objectGUID",                 LDB_SYNTAX_SAMBA_GUID },
        { "invocationId",               LDB_SYNTAX_SAMBA_GUID },
        { "schemaIDGUID",               LDB_SYNTAX_SAMBA_GUID },
+       { "oMSyntax",                   LDB_SYNTAX_SAMBA_INT32 },
        { "attributeSecurityGUID",      LDB_SYNTAX_SAMBA_GUID },
        { "parentGUID",                 LDB_SYNTAX_SAMBA_GUID },
        { "siteGUID",                   LDB_SYNTAX_SAMBA_GUID },