flags |= SECINFO_SACL;
}
}
- ldb_msg_add_fmt(msg, "sDRightsEffective", "%u", flags);
- return LDB_SUCCESS;
+ return samdb_msg_add_uint(ldb_module_get_ctx(module), msg, msg,
+ "sDRightsEffective", flags);
}
static int acl_add(struct ldb_module *module, struct ldb_request *req)
*/
instanceType = INSTANCE_TYPE_WRITE;
- ret = ldb_msg_add_fmt(msg, "instanceType", "%u", instanceType);
+ ret = samdb_msg_add_uint(ldb, msg, msg, "instanceType", instanceType);
if (ret != LDB_SUCCESS) {
return ret;
}
enum ndr_err_code ndr_err;
const struct ldb_val *omd_value;
struct replPropertyMetaDataBlob *omd;
+ int ret;
omd_value = ldb_msg_find_ldb_val(msg, "replPropertyMetaData");
if (!omd_value) {
}
for (i=0; i<omd->ctr.ctr1.count; i++) {
if (omd->ctr.ctr1.array[i].attid == DRSUAPI_ATTRIBUTE_unicodePwd) {
- ldb_msg_add_fmt(msg, "msDS-KeyVersionNumber", "%u", omd->ctr.ctr1.array[i].version);
+ ret = samdb_msg_add_uint(ldb_module_get_ctx(module),
+ msg, msg,
+ "msDS-KeyVersionNumber",
+ omd->ctr.ctr1.array[i].version);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(omd);
+ return ret;
+ }
break;
}
}
uint64_t seq_num;
int ret = ldb_sequence_number(ldb, LDB_SEQ_HIGHEST_SEQ, &seq_num);
if (ret == LDB_SUCCESS) {
- if (ldb_msg_add_fmt(msg, "highestCommittedUSN",
- "%llu", (unsigned long long)seq_num) != LDB_SUCCESS) {
+ if (samdb_msg_add_uint64(ldb, msg, msg,
+ "highestCommittedUSN",
+ seq_num) != LDB_SUCCESS) {
goto failed;
}
}
n++;
}
- if (ldb_msg_add_fmt(msg, "dsSchemaAttrCount",
- "%u", n) != LDB_SUCCESS) {
+ if (samdb_msg_add_uint(ldb, msg, msg, "dsSchemaAttrCount",
+ n) != LDB_SUCCESS) {
goto failed;
}
}
n++;
}
- if (ldb_msg_add_fmt(msg, "dsSchemaClassCount",
- "%u", n) != LDB_SUCCESS) {
+ if (samdb_msg_add_uint(ldb, msg, msg, "dsSchemaClassCount",
+ n) != LDB_SUCCESS) {
goto failed;
}
}
if (schema && do_attribute_explicit(attrs, "dsSchemaPrefixCount")) {
- if (ldb_msg_add_fmt(msg, "dsSchemaPrefixCount",
- "%u", schema->prefixmap->length) != LDB_SUCCESS) {
+ if (samdb_msg_add_uint(ldb, msg, msg, "dsSchemaPrefixCount",
+ schema->prefixmap->length) != LDB_SUCCESS) {
goto failed;
}
}
return ldb_operr(ldb);
}
- ret = ldb_msg_add_fmt(ac->msg, "msDS-SecondaryKrbTgtNumber", "%u", krbtgt_number);
+ ret = samdb_msg_add_uint(ldb, ac->msg, ac->msg,
+ "msDS-SecondaryKrbTgtNumber", krbtgt_number);
if (ret != LDB_SUCCESS) {
return ldb_operr(ldb);
}
struct ldb_message_element *el, *el2;
enum sid_generator sid_generator;
struct dom_sid *sid;
+ const char *tempstr;
int ret;
/* make sure that "sAMAccountType" is not specified */
if (strcmp(ac->type, "user") == 0) {
/* Step 1.2: Default values */
+ tempstr = talloc_asprintf(ac->msg, "%d", UF_NORMAL_ACCOUNT);
+ if (tempstr == NULL) return ldb_operr(ldb);
ret = samdb_find_or_add_attribute(ldb, ac->msg,
- "userAccountControl",
- talloc_asprintf(ac->msg, "%d", UF_NORMAL_ACCOUNT));
+ "userAccountControl", tempstr);
if (ret != LDB_SUCCESS) return ret;
ret = samdb_find_or_add_attribute(ldb, ac->msg,
"badPwdCount", "0");
} else if (strcmp(ac->type, "group") == 0) {
/* Step 2.2: Default values */
+ tempstr = talloc_asprintf(ac->msg, "%d",
+ GTYPE_SECURITY_GLOBAL_GROUP);
+ if (tempstr == NULL) return ldb_operr(ldb);
ret = samdb_find_or_add_attribute(ldb, ac->msg,
- "groupType",
- talloc_asprintf(ac->msg, "%d", GTYPE_SECURITY_GLOBAL_GROUP));
+ "groupType", tempstr);
if (ret != LDB_SUCCESS) return ret;
/* Step 2.3: "groupType" -> "sAMAccountType" */
msg->dn = ldb_dn_new(msg, s->ldap2.ldb, s->dest_dsa.computer_dn_str);
NT_STATUS_HAVE_NO_MEMORY(msg->dn);
- ret = ldb_msg_add_fmt(msg, "userAccountControl", "%u", user_account_control);
- if (ret != 0) {
+ ret = samdb_msg_add_uint(s->ldap2.ldb, msg, msg, "userAccountControl",
+ user_account_control);
+ if (ret != LDB_SUCCESS) {
talloc_free(msg);
return NT_STATUS_NO_MEMORY;
}
msg->dn = ldb_dn_new(msg, s->ldap.ldb, s->dest_dsa.computer_dn_str);
NT_STATUS_HAVE_NO_MEMORY(msg->dn);
- ret = ldb_msg_add_fmt(msg, "userAccountControl", "%u", user_account_control);
- if (ret != 0) {
+ ret = samdb_msg_add_uint(s->ldap.ldb, msg, msg, "userAccountControl",
+ user_account_control);
+ if (ret != LDB_SUCCESS) {
talloc_free(msg);
return NT_STATUS_NO_MEMORY;
}
return NT_STATUS_NO_MEMORY;
}
- ret = ldb_msg_add_fmt(msg, "userAccountControl", "%u",
- UF_INTERDOMAIN_TRUST_ACCOUNT);
+ ret = samdb_msg_add_uint(sam_ldb, msg, msg, "userAccountControl",
+ UF_INTERDOMAIN_TRUST_ACCOUNT);
if (ret != LDB_SUCCESS) {
return NT_STATUS_NO_MEMORY;
}
}
static NTSTATUS update_uint32_t_value(TALLOC_CTX *mem_ctx,
+ struct ldb_context *sam_ldb,
struct ldb_message *orig,
struct ldb_message *dest,
const char *attribute,
{
const struct ldb_val *orig_val;
uint32_t orig_uint = 0;
- char *str_val;
int flags = 0;
int ret;
return NT_STATUS_NO_MEMORY;
}
- str_val = talloc_asprintf(mem_ctx, "%u", value);
- if (!str_val) {
- return NT_STATUS_NO_MEMORY;
- }
- ret = ldb_msg_add_steal_string(dest, attribute, str_val);
+ ret = samdb_msg_add_uint(sam_ldb, dest, dest, attribute, value);
if (ret != LDB_SUCCESS) {
return NT_STATUS_NO_MEMORY;
}
msg->dn = dom_msg->dn;
if (posix_offset) {
- nt_status = update_uint32_t_value(mem_ctx, dom_msg, msg,
+ nt_status = update_uint32_t_value(mem_ctx, p_state->sam_ldb,
+ dom_msg, msg,
"trustPosixOffset",
*posix_offset, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {
uint32_t tmp;
int origtype;
- nt_status = update_uint32_t_value(mem_ctx, dom_msg, msg,
+ nt_status = update_uint32_t_value(mem_ctx, p_state->sam_ldb,
+ dom_msg, msg,
"trustDirection",
info_ex->trust_direction,
&origdir);
return NT_STATUS_INVALID_PARAMETER;
}
- nt_status = update_uint32_t_value(mem_ctx, dom_msg, msg,
+ nt_status = update_uint32_t_value(mem_ctx, p_state->sam_ldb,
+ dom_msg, msg,
"trustAttributes",
info_ex->trust_attributes,
&origattrs);
}
if (enc_types) {
- nt_status = update_uint32_t_value(mem_ctx, dom_msg, msg,
+ nt_status = update_uint32_t_value(mem_ctx, p_state->sam_ldb,
+ dom_msg, msg,
"msDS-SupportedEncryptionTypes",
*enc_types, NULL);
if (!NT_STATUS_IS_OK(nt_status)) {