dsdb/schema: Move some dsdb_dn functions that are schema-specific.
authorJelmer Vernooij <jelmer@samba.org>
Sun, 10 Oct 2010 19:37:58 +0000 (21:37 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Sun, 10 Oct 2010 23:06:35 +0000 (01:06 +0200)
source4/dsdb/common/dsdb_dn.c
source4/dsdb/schema/dsdb_dn.c [new file with mode: 0644]
source4/dsdb/schema/schema.h
source4/dsdb/wscript_build

index 85ba9b760597804c457e67bdee8d19bd2caea7a3..3e0f4653fd400365d06d00f66b3548de319f37cc 100644 (file)
@@ -328,84 +328,6 @@ int dsdb_dn_string_comparison(struct ldb_context *ldb, void *mem_ctx,
        return ldb_any_comparison(ldb, mem_ctx, dsdb_dn_string_canonicalise, v1, v2);
 }
 
-
-/*
-   convert a dsdb_dn to a linked attribute data blob
-*/
-WERROR dsdb_dn_la_to_blob(struct ldb_context *sam_ctx,
-                         const struct dsdb_attribute *schema_attrib,
-                         const struct dsdb_schema *schema,
-                         TALLOC_CTX *mem_ctx,
-                         struct dsdb_dn *dsdb_dn, DATA_BLOB **blob)
-{
-       struct ldb_val v;
-       WERROR werr;
-       struct ldb_message_element val_el;
-       struct drsuapi_DsReplicaAttribute drs;
-       struct dsdb_syntax_ctx syntax_ctx;
-
-       /* use default syntax conversion context */
-       dsdb_syntax_ctx_init(&syntax_ctx, sam_ctx, schema);
-
-       /* we need a message_element with just one value in it */
-       v = data_blob_string_const(dsdb_dn_get_extended_linearized(mem_ctx, dsdb_dn, 1));
-
-       val_el.name = schema_attrib->lDAPDisplayName;
-       val_el.values = &v;
-       val_el.num_values = 1;
-
-       werr = schema_attrib->syntax->ldb_to_drsuapi(&syntax_ctx, schema_attrib, &val_el, mem_ctx, &drs);
-       W_ERROR_NOT_OK_RETURN(werr);
-
-       if (drs.value_ctr.num_values != 1) {
-               DEBUG(1,(__location__ ": Failed to build DRS blob for linked attribute %s\n",
-                        schema_attrib->lDAPDisplayName));
-               return WERR_DS_DRA_INTERNAL_ERROR;
-       }
-
-       *blob = drs.value_ctr.values[0].blob;
-       return WERR_OK;
-}
-
-/*
-  convert a data blob to a dsdb_dn
- */
-WERROR dsdb_dn_la_from_blob(struct ldb_context *sam_ctx,
-                           const struct dsdb_attribute *schema_attrib,
-                           const struct dsdb_schema *schema,
-                           TALLOC_CTX *mem_ctx,
-                           DATA_BLOB *blob,
-                           struct dsdb_dn **dsdb_dn)
-{
-       WERROR werr;
-       struct ldb_message_element new_el;
-       struct drsuapi_DsReplicaAttribute drs;
-       struct drsuapi_DsAttributeValue val;
-       struct dsdb_syntax_ctx syntax_ctx;
-
-       /* use default syntax conversion context */
-       dsdb_syntax_ctx_init(&syntax_ctx, sam_ctx, schema);
-
-       drs.value_ctr.num_values = 1;
-       drs.value_ctr.values = &val;
-       val.blob = blob;
-
-       werr = schema_attrib->syntax->drsuapi_to_ldb(&syntax_ctx, schema_attrib, &drs, mem_ctx, &new_el);
-       W_ERROR_NOT_OK_RETURN(werr);
-
-       if (new_el.num_values != 1) {
-               return WERR_INTERNAL_ERROR;
-       }
-
-       *dsdb_dn = dsdb_dn_parse(mem_ctx, sam_ctx, &new_el.values[0], schema_attrib->syntax->ldap_oid);
-       if (!*dsdb_dn) {
-               return WERR_INTERNAL_ERROR;
-       }
-
-       return WERR_OK;
-}
-
-
 /*
   format a drsuapi_DsReplicaObjectIdentifier naming context as a string
  */
diff --git a/source4/dsdb/schema/dsdb_dn.c b/source4/dsdb/schema/dsdb_dn.c
new file mode 100644 (file)
index 0000000..bd945bc
--- /dev/null
@@ -0,0 +1,102 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+
+   Copyright (C) Andrew Tridgell 2009
+   Copyright (C) Andrew Bartlett <abartlet@samba.org> 2009
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "dsdb/samdb/samdb.h"
+#include "lib/ldb/include/ldb_module.h"
+#include "librpc/ndr/libndr.h"
+#include "libcli/security/dom_sid.h"
+
+/*
+   convert a dsdb_dn to a linked attribute data blob
+*/
+WERROR dsdb_dn_la_to_blob(struct ldb_context *sam_ctx,
+                         const struct dsdb_attribute *schema_attrib,
+                         const struct dsdb_schema *schema,
+                         TALLOC_CTX *mem_ctx,
+                         struct dsdb_dn *dsdb_dn, DATA_BLOB **blob)
+{
+       struct ldb_val v;
+       WERROR werr;
+       struct ldb_message_element val_el;
+       struct drsuapi_DsReplicaAttribute drs;
+       struct dsdb_syntax_ctx syntax_ctx;
+
+       /* use default syntax conversion context */
+       dsdb_syntax_ctx_init(&syntax_ctx, sam_ctx, schema);
+
+       /* we need a message_element with just one value in it */
+       v = data_blob_string_const(dsdb_dn_get_extended_linearized(mem_ctx, dsdb_dn, 1));
+
+       val_el.name = schema_attrib->lDAPDisplayName;
+       val_el.values = &v;
+       val_el.num_values = 1;
+
+       werr = schema_attrib->syntax->ldb_to_drsuapi(&syntax_ctx, schema_attrib, &val_el, mem_ctx, &drs);
+       W_ERROR_NOT_OK_RETURN(werr);
+
+       if (drs.value_ctr.num_values != 1) {
+               DEBUG(1,(__location__ ": Failed to build DRS blob for linked attribute %s\n",
+                        schema_attrib->lDAPDisplayName));
+               return WERR_DS_DRA_INTERNAL_ERROR;
+       }
+
+       *blob = drs.value_ctr.values[0].blob;
+       return WERR_OK;
+}
+
+/*
+  convert a data blob to a dsdb_dn
+ */
+WERROR dsdb_dn_la_from_blob(struct ldb_context *sam_ctx,
+                           const struct dsdb_attribute *schema_attrib,
+                           const struct dsdb_schema *schema,
+                           TALLOC_CTX *mem_ctx,
+                           DATA_BLOB *blob,
+                           struct dsdb_dn **dsdb_dn)
+{
+       WERROR werr;
+       struct ldb_message_element new_el;
+       struct drsuapi_DsReplicaAttribute drs;
+       struct drsuapi_DsAttributeValue val;
+       struct dsdb_syntax_ctx syntax_ctx;
+
+       /* use default syntax conversion context */
+       dsdb_syntax_ctx_init(&syntax_ctx, sam_ctx, schema);
+
+       drs.value_ctr.num_values = 1;
+       drs.value_ctr.values = &val;
+       val.blob = blob;
+
+       werr = schema_attrib->syntax->drsuapi_to_ldb(&syntax_ctx, schema_attrib, &drs, mem_ctx, &new_el);
+       W_ERROR_NOT_OK_RETURN(werr);
+
+       if (new_el.num_values != 1) {
+               return WERR_INTERNAL_ERROR;
+       }
+
+       *dsdb_dn = dsdb_dn_parse(mem_ctx, sam_ctx, &new_el.values[0], schema_attrib->syntax->ldap_oid);
+       if (!*dsdb_dn) {
+               return WERR_INTERNAL_ERROR;
+       }
+
+       return WERR_OK;
+}
index 8c73fd56d4dbab736c5db9301381afbdb19d6563..fd1e090b85da086d3f0edf3b5d265652f81a96b2 100644 (file)
@@ -27,6 +27,7 @@
 struct dsdb_attribute;
 struct dsdb_class;
 struct dsdb_schema;
+struct dsdb_dn;
 
 struct dsdb_syntax_ctx {
        struct ldb_context *ldb;
index 90d265f09edcabf92ad1c45d84e65b0e876a15f2..4ad3e1347321f5cbd83150dcd99c19f06508a878 100644 (file)
@@ -18,9 +18,10 @@ bld.SAMBA_SUBSYSTEM('SAMDB_COMMON',
 
 
 bld.SAMBA_SUBSYSTEM('SAMDB_SCHEMA',
-       source='schema/schema_init.c schema/schema_set.c schema/schema_query.c schema/schema_syntax.c schema/schema_description.c schema/schema_convert_to_ol.c schema/schema_inferiors.c schema/schema_prefixmap.c schema/schema_info_attr.c schema/schema_filtered.c',
+       source='schema/schema_init.c schema/schema_set.c schema/schema_query.c schema/schema_syntax.c schema/schema_description.c schema/schema_convert_to_ol.c schema/schema_inferiors.c schema/schema_prefixmap.c schema/schema_info_attr.c schema/schema_filtered.c schema/dsdb_dn.c',
        autoproto='schema/proto.h',
-       deps='SAMDB_COMMON NDR_DRSUAPI NDR_DRSBLOBS LDBSAMBA tevent'
+       # FIXME: Why does this use DSDB_MODULE_HELPERS?
+       deps='SAMDB_COMMON NDR_DRSUAPI NDR_DRSBLOBS LDBSAMBA tevent DSDB_MODULE_HELPERS'
        )