summaryrefslogtreecommitdiff
path: root/source4/dsdb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/dsdb')
-rw-r--r--source4/dsdb/common/util.c33
-rw-r--r--source4/dsdb/samdb/ldb_modules/linked_attributes.c22
-rw-r--r--source4/dsdb/samdb/ldb_modules/normalise.c2
-rw-r--r--source4/dsdb/samdb/ldb_modules/tests/samba3sam.py4
-rw-r--r--source4/dsdb/schema/schema_syntax.c5
5 files changed, 50 insertions, 16 deletions
diff --git a/source4/dsdb/common/util.c b/source4/dsdb/common/util.c
index 69e456274c..2161286e08 100644
--- a/source4/dsdb/common/util.c
+++ b/source4/dsdb/common/util.c
@@ -657,6 +657,28 @@ uint32_t samdb_result_acct_flags(struct ldb_context *sam_ctx, TALLOC_CTX *mem_ct
return acct_flags;
}
+struct lsa_BinaryString samdb_result_parameters(TALLOC_CTX *mem_ctx,
+ struct ldb_message *msg,
+ const char *attr)
+{
+ struct lsa_BinaryString s;
+ const struct ldb_val *val = ldb_msg_find_ldb_val(msg, attr);
+
+ ZERO_STRUCT(s);
+
+ if (!val) {
+ return s;
+ }
+
+ s.array = talloc_array(mem_ctx, uint16_t, val->length/2);
+ if (!s.array) {
+ return s;
+ }
+ s.length = s.size = val->length/2;
+ memcpy(s.array, val->data, val->length);
+
+ return s;
+}
/* Find an attribute, with a particular value */
@@ -897,6 +919,17 @@ int samdb_msg_add_logon_hours(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx,
}
/*
+ add a parameters element to a message
+*/
+int samdb_msg_add_parameters(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
+ const char *attr_name, struct lsa_BinaryString *parameters)
+{
+ struct ldb_val val;
+ val.length = parameters->length * 2;
+ val.data = (uint8_t *)parameters->array;
+ return ldb_msg_add_value(msg, attr_name, &val, NULL);
+}
+/*
add a general value element to a message
*/
int samdb_msg_add_value(struct ldb_context *sam_ldb, TALLOC_CTX *mem_ctx, struct ldb_message *msg,
diff --git a/source4/dsdb/samdb/ldb_modules/linked_attributes.c b/source4/dsdb/samdb/ldb_modules/linked_attributes.c
index 190a66cdb3..dd199c0137 100644
--- a/source4/dsdb/samdb/ldb_modules/linked_attributes.c
+++ b/source4/dsdb/samdb/ldb_modules/linked_attributes.c
@@ -79,15 +79,17 @@ static struct la_context *linked_attributes_init(struct ldb_module *module,
/* Common routine to handle reading the attributes and creating a
* series of modify requests */
static int la_store_op(struct la_context *ac,
- enum la_op op, char *dn,
+ enum la_op op, struct ldb_val *dn,
const char *name, const char *value)
{
struct la_op_store *os, *tmp;
struct ldb_dn *op_dn;
- op_dn = ldb_dn_new(ac, ac->module->ldb, dn);
+ op_dn = ldb_dn_from_ldb_val(ac, ac->module->ldb, dn);
if (!op_dn) {
- return LDB_ERR_OPERATIONS_ERROR;
+ ldb_asprintf_errstring(ac->module->ldb,
+ "could not parse attribute as a DN");
+ return LDB_ERR_INVALID_DN_SYNTAX;
}
/* optimize out del - add operations that would end up
@@ -177,7 +179,7 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request *
int ret;
int i, j;
- if (ldb_dn_is_special(req->op.mod.message->dn)) {
+ if (ldb_dn_is_special(req->op.add.message->dn)) {
/* do not manipulate our control entries */
return ldb_next_request(module, req);
}
@@ -233,7 +235,7 @@ static int linked_attributes_add(struct ldb_module *module, struct ldb_request *
for (j = 0; j < el->num_values; j++) {
ret = la_store_op(ac, LA_OP_ADD,
- (char *)el->values[j].data,
+ &el->values[j],
attr_name, attr_val);
if (ret != LDB_SUCCESS) {
return ret;
@@ -327,7 +329,7 @@ static int la_mod_search_callback(struct ldb_request *req, struct ldb_reply *are
/* make sure we manage each value */
for (j = 0; j < search_el->num_values; j++) {
ret = la_store_op(ac, LA_OP_DEL,
- (char *)search_el->values[j].data,
+ &search_el->values[j],
attr_name, dn);
if (ret != LDB_SUCCESS) {
talloc_free(ares);
@@ -445,7 +447,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques
/* For each value being added, we need to setup the adds */
for (j = 0; j < el->num_values; j++) {
ret = la_store_op(ac, LA_OP_ADD,
- (char *)el->values[j].data,
+ &el->values[j],
attr_name, attr_val);
if (ret != LDB_SUCCESS) {
return ret;
@@ -459,7 +461,7 @@ static int linked_attributes_modify(struct ldb_module *module, struct ldb_reques
/* For each value being deleted, we need to setup the delete */
for (j = 0; j < el->num_values; j++) {
ret = la_store_op(ac, LA_OP_DEL,
- (char *)el->values[j].data,
+ &el->values[j],
attr_name, attr_val);
if (ret != LDB_SUCCESS) {
return ret;
@@ -701,7 +703,7 @@ static int la_op_search_callback(struct ldb_request *req,
}
for (j = 0; j < el->num_values; j++) {
ret = la_store_op(ac, LA_OP_DEL,
- (char *)el->values[j].data,
+ &el->values[j],
attr_name, deldn);
if (ret != LDB_SUCCESS) {
talloc_free(ares);
@@ -710,7 +712,7 @@ static int la_op_search_callback(struct ldb_request *req,
}
if (!adddn) continue;
ret = la_store_op(ac, LA_OP_ADD,
- (char *)el->values[j].data,
+ &el->values[j],
attr_name, adddn);
if (ret != LDB_SUCCESS) {
talloc_free(ares);
diff --git a/source4/dsdb/samdb/ldb_modules/normalise.c b/source4/dsdb/samdb/ldb_modules/normalise.c
index 70513bd644..2366bc7856 100644
--- a/source4/dsdb/samdb/ldb_modules/normalise.c
+++ b/source4/dsdb/samdb/ldb_modules/normalise.c
@@ -120,7 +120,7 @@ static int normalize_search_callback(struct ldb_request *req, struct ldb_reply *
}
for (j = 0; j < msg->elements[i].num_values; j++) {
const char *dn_str;
- struct ldb_dn *dn = ldb_dn_new(ac, ac->module->ldb, (const char *)msg->elements[i].values[j].data);
+ struct ldb_dn *dn = ldb_dn_from_ldb_val(ac, ac->module->ldb, &msg->elements[i].values[j]);
if (!dn) {
return ldb_module_done(ac->req, NULL, NULL, LDB_ERR_OPERATIONS_ERROR);
}
diff --git a/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py b/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py
index 1fc531902d..7162edcb3d 100644
--- a/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py
+++ b/source4/dsdb/samdb/ldb_modules/tests/samba3sam.py
@@ -27,7 +27,7 @@ import ldb
from ldb import SCOPE_DEFAULT, SCOPE_BASE, SCOPE_SUBTREE
from samba import Ldb, substitute_var
from samba.tests import LdbTestCase, TestCaseInTempDir, cmdline_loadparm
-import samba.dcerpc.security
+import samba.dcerpc.dom_sid
import samba.security
import samba.ndr
@@ -116,7 +116,7 @@ class MapBaseTestCase(TestCaseInTempDir):
super(MapBaseTestCase, self).tearDown()
def assertSidEquals(self, text, ndr_sid):
- sid_obj1 = samba.ndr.ndr_unpack(samba.dcerpc.security.dom_sid,
+ sid_obj1 = samba.ndr.ndr_unpack(samba.dcerpc.dom_sid.dom_sid,
str(ndr_sid[0]))
sid_obj2 = samba.security.Sid(text)
# For now, this is the only way we can compare these since the
diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c
index e0e6b3fc77..cee74c0593 100644
--- a/source4/dsdb/schema/schema_syntax.c
+++ b/source4/dsdb/schema/schema_syntax.c
@@ -1322,9 +1322,6 @@ static const struct dsdb_syntax dsdb_syntaxes[] = {
.attributeSyntax_oid = "2.5.5.14",
.drsuapi_to_ldb = dsdb_syntax_FOOBAR_drsuapi_to_ldb,
.ldb_to_drsuapi = dsdb_syntax_FOOBAR_ldb_to_drsuapi,
- .equality = "distinguishedNameMatch",
- .comment = "OctetString: String+DN",
- .ldb_syntax = LDB_SYNTAX_DN,
},{
/* not used in w2k3 schema */
.name = "Object(DN-String)",
@@ -1334,6 +1331,8 @@ static const struct dsdb_syntax dsdb_syntaxes[] = {
.attributeSyntax_oid = "2.5.5.14",
.drsuapi_to_ldb = dsdb_syntax_FOOBAR_drsuapi_to_ldb,
.ldb_to_drsuapi = dsdb_syntax_FOOBAR_ldb_to_drsuapi,
+ .equality = "distinguishedNameMatch",
+ .comment = "OctetString: String+DN",
.ldb_syntax = LDB_SYNTAX_DN,
}
};