summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-10-26 18:33:32 +0300
committerKamen Mazdrashki <kamenim@samba.org>2010-10-26 22:17:41 +0300
commit0fc2427224c2826e5ee0b09631ae77d0b08b5ba9 (patch)
tree500d8d8c747eaa9d5e4d330117d5f91b5573e603 /source4/dsdb/schema
parent5e108fc5f94e6a08083f8852a59fc4b79b198af8 (diff)
downloadsamba-0fc2427224c2826e5ee0b09631ae77d0b08b5ba9.tar.gz
samba-0fc2427224c2826e5ee0b09631ae77d0b08b5ba9.tar.bz2
samba-0fc2427224c2826e5ee0b09631ae77d0b08b5ba9.zip
s4-prefixMap: split dsdb_schema_make_attid() function into read-only and
read-write functions. dsdb_schema_make_attid() may change prefixMap implicitly and this is not always desired behavior. The problem was that (1) callers had no control on this behavior (2) callers had no way to know wheter prefixMap has been changed which can lead to hard to find bugs like prefixMap is changed in read operation
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r--source4/dsdb/schema/schema_prefixmap.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/source4/dsdb/schema/schema_prefixmap.c b/source4/dsdb/schema/schema_prefixmap.c
index 86c6b8df8d..18920500d6 100644
--- a/source4/dsdb/schema/schema_prefixmap.c
+++ b/source4/dsdb/schema/schema_prefixmap.c
@@ -259,9 +259,14 @@ WERROR dsdb_schema_pfm_find_oid(const struct dsdb_schema_prefixmap *pfm,
/**
* Make ATTID for given OID
+ * If OID is not in prefixMap, new prefix
+ * may be added depending on 'can_change_pfm' flag
* Reference: [MS-DRSR] section 5.12.2
*/
-WERROR dsdb_schema_pfm_make_attid(struct dsdb_schema_prefixmap *pfm, const char *oid, uint32_t *attid)
+static WERROR dsdb_schema_pfm_make_attid_impl(struct dsdb_schema_prefixmap *pfm,
+ const char *oid,
+ bool can_change_pfm,
+ uint32_t *attid)
{
WERROR werr;
uint32_t idx;
@@ -287,6 +292,11 @@ WERROR dsdb_schema_pfm_make_attid(struct dsdb_schema_prefixmap *pfm, const char
/* free memory allocated for bin_oid */
data_blob_free(&bin_oid);
} else {
+ /* return error in read-only mode */
+ if (!can_change_pfm) {
+ return werr;
+ }
+
/* entry does not exists, add it */
werr = _dsdb_schema_pfm_add_entry(pfm, bin_oid, &idx);
W_ERROR_NOT_OK_RETURN(werr);
@@ -309,6 +319,33 @@ WERROR dsdb_schema_pfm_make_attid(struct dsdb_schema_prefixmap *pfm, const char
return WERR_OK;
}
+/**
+ * Make ATTID for given OID
+ * Reference: [MS-DRSR] section 5.12.2
+ *
+ * Note: This function may change prefixMap if prefix
+ * for supplied 'oid' doesn't exists yet.
+ * It is recommended to be used mostly when caller
+ * want to add new prefixes.
+ * Otherwise dsdb_schema_pfm_attid_from_oid() should be used.
+ */
+WERROR dsdb_schema_pfm_make_attid(struct dsdb_schema_prefixmap *pfm,
+ const char *oid,
+ uint32_t *attid)
+{
+ return dsdb_schema_pfm_make_attid_impl(pfm, oid, true, attid);
+}
+
+/**
+ * Make ATTID for given OID
+ * Reference: [MS-DRSR] section 5.12.2
+ */
+WERROR dsdb_schema_pfm_attid_from_oid(struct dsdb_schema_prefixmap *pfm,
+ const char *oid,
+ uint32_t *attid)
+{
+ return dsdb_schema_pfm_make_attid_impl(pfm, oid, false, attid);
+}
/**
* Make OID for given ATTID.