case ADMINISTRATOR:
return ldb_next_request(module, req);
default:
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(req, "kludge_acl_change: "
"attempted database modify not permitted. User %s is not SYSTEM or an administrator",
user_name(req, module)));
if (req->operation == LDB_REQ_ADD) {
if (attribute->num_values > 1) {
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "sambaPassword_handle: "
"attempted set of multiple sambaPassword attributes on %s rejected",
ldb_dn_linearize(mem_ctx, dn)));
} else if (((attribute->flags & LDB_FLAG_MOD_MASK) == LDB_FLAG_MOD_ADD)
|| ((attribute->flags & LDB_FLAG_MOD_MASK) == LDB_FLAG_MOD_REPLACE)) {
if (attribute->num_values > 1) {
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "sambaPassword_handle: "
"attempted set of multiple sambaPassword attributes on %s rejected",
ldb_dn_linearize(mem_ctx, dn)));
talloc_free(search_request);
if (old_res->count != 1) {
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "password_hash_handle: "
"(pre) search for %s found %d != 1 objects, for entry we just modified",
ldb_dn_linearize(mem_ctx, dn),
talloc_free(search_request);
if (res->count != 1) {
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "password_hash_handle: "
"search for %s found %d != 1 objects, for entry we just added/modified",
ldb_dn_linearize(mem_ctx, dn),
/* Not a 'person', so the rest of this doesn't make
* sense. How we got a sambaPassword this far I don't
* know... */
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "password_hash_handle: "
"attempted set of sambaPassword on non-'person' object %s rejected",
ldb_dn_linearize(mem_ctx, dn)));
if (dom_res->count != 1) {
/* What happend? The user we are modifying must be odd... */
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "password_hash_handle: "
"search for domain %s found %d != 1 objects",
dom_sid_string(mem_ctx, domain_sid),
char *samAccountName = talloc_strdup(mem_ctx, ldb_msg_find_string(res->msgs[0], "samAccountName", NULL));
char *saltbody;
if (!samAccountName) {
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "password_hash_handle: "
"generation of new kerberos keys failed: %s is a computer without a samAccountName",
ldb_dn_linearize(mem_ctx, dn)));
} else {
const char *samAccountName = ldb_msg_find_string(res->msgs[0], "samAccountName", NULL);
if (!samAccountName) {
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "password_hash_handle: "
"generation of new kerberos keys failed: %s has no samAccountName",
ldb_dn_linearize(mem_ctx, dn)));
if (krb5_ret) {
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "password_hash_handle: "
"generation of a saltking principal failed: %s",
smb_get_krb5_error_message(smb_krb5_context->krb5_context,
krb5_free_principal(smb_krb5_context->krb5_context, salt_principal);
if (krb5_ret) {
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "password_hash_handle: "
"generation of new kerberos keys failed: %s",
smb_get_krb5_error_message(smb_krb5_context->krb5_context,
newreq.controls = req->controls;
ret = ldb_request(proxy->upstream, &newreq);
if (ret != LDB_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldb_errstring(proxy->upstream)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldb_errstring(proxy->upstream)));
return -1;
}
str = ldb_msg_find_string(res->msgs[0], "nextRid", NULL);
if (str == NULL) {
- ldb_set_errstring(module, talloc_asprintf(mem_ctx, "attribute nextRid not found in %s\n", ldb_dn_linearize(res, dn)));
+ ldb_set_errstring(module->ldb,
+ talloc_asprintf(mem_ctx, "attribute nextRid not found in %s\n",
+ ldb_dn_linearize(res, dn)));
talloc_free(res);
return -1;
}
"objectSid=%s",
ldap_encode_ndr_dom_sid(mem_ctx, sid));
if (ret > 0) {
- ldb_set_errstring(module, talloc_asprintf(mem_ctx, "Attempt to add record with SID %s rejected, because this SID is already in the database", dom_sid_string(mem_ctx, sid)));
+ ldb_set_errstring(module->ldb,
+ talloc_asprintf(mem_ctx,
+ "Attempt to add record with SID %s rejected,"
+ " because this SID is already in the database",
+ dom_sid_string(mem_ctx, sid)));
/* We have a duplicate SID, we must reject the add */
talloc_free(dom_msgs);
return LDB_ERR_CONSTRAINT_VIOLATION;
rdn = ldb_dn_get_rdn(msg2, msg2->dn);
if (strcasecmp(rdn->name, "cn") != 0) {
- ldb_set_errstring(module, talloc_asprintf(module, "Bad RDN (%s=) for user/computer, should be CN=!\n", rdn->name));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Bad RDN (%s=) for user/computer, should be CN=!\n", rdn->name));
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
rdn = ldb_dn_get_rdn(msg2, msg2->dn);
if (strcasecmp(rdn->name, "cn") != 0) {
- ldb_set_errstring(module, talloc_asprintf(module, "Bad RDN (%s=) for ForeignSecurityPrincipal, should be CN=!", rdn->name));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Bad RDN (%s=) for ForeignSecurityPrincipal, should be CN=!", rdn->name));
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
sid = dom_sid_parse_talloc(msg2, (const char *)rdn->value.data);
if (!sid) {
- ldb_set_errstring(module, talloc_asprintf(module, "No valid found SID in ForeignSecurityPrincipal CN!"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "No valid found SID in ForeignSecurityPrincipal CN!"));
talloc_free(mem_ctx);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
ldap_encode_ndr_dom_sid(mem_ctx, dom_sid));
if (ret >= 1) {
const char *name = samdb_result_string(dom_msgs[0], "name", NULL);
- ldb_set_errstring(module, talloc_asprintf(mem_ctx, "Attempt to add foreign SID record with SID %s rejected, because this domian (%s) is already in the database", dom_sid_string(mem_ctx, sid), name));
+ ldb_set_errstring(module->ldb, talloc_asprintf(mem_ctx, "Attempt to add foreign SID record with SID %s rejected, because this domian (%s) is already in the database", dom_sid_string(mem_ctx, sid), name));
/* We don't really like the idea of foreign sids that are not foreign */
return LDB_ERR_CONSTRAINT_VIOLATION;
} else if (ret == -1) {
return LDB_SUCCESS;
}
-void ldb_set_errstring(struct ldb_module *module, char *err_string)
+void ldb_set_errstring(struct ldb_context *ldb, char *err_string)
{
- if (module->ldb->err_string) {
- talloc_free(module->ldb->err_string);
+ if (ldb->err_string) {
+ talloc_free(ldb->err_string);
}
- module->ldb->err_string = talloc_steal(module->ldb, err_string);
+ ldb->err_string = talloc_steal(ldb, err_string);
}
void ldb_reset_err_string(struct ldb_context *ldb)
if (status != LDB_SUCCESS) {
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb->modules,
+ ldb_set_errstring(ldb,
talloc_asprintf(ldb, "ldb transaction start error %d", status));
}
}
if (status != LDB_SUCCESS) {
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb->modules,
+ ldb_set_errstring(ldb,
talloc_asprintf(ldb, "ldb transaction commit error %d", status));
}
}
if (status != LDB_SUCCESS) {
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb->modules,
+ ldb_set_errstring(ldb,
talloc_asprintf(ldb, "ldb transaction cancel error %d", status));
}
}
}
if (ldb->err_string == NULL) {
/* no error string was setup by the backend */
- ldb_set_errstring(ldb->modules,
+ ldb_set_errstring(ldb,
talloc_asprintf(ldb, "ldb error %d", status));
}
ldb_transaction_cancel(ldb);
tree = ldb_parse_tree(ldb, expression);
if (tree == NULL) {
- ldb_set_errstring(ldb->modules, talloc_strdup(ldb, "Unable to parse search expression"));
+ ldb_set_errstring(ldb, talloc_strdup(ldb, "Unable to parse search expression"));
return -1;
}
msg = talloc_vasprintf(ldb, fmt, ap);
va_end(ap);
if (msg != NULL) {
- ldb_set_errstring(ldb->modules, msg);
+ ldb_set_errstring(ldb, msg);
ldb_debug(ldb, level, "%s", msg);
}
}
enum ldb_async_wait_type {
LDB_WAIT_ALL,
+ LDB_WAIT_ONCE,
LDB_WAIT_NONE
};
enum ldb_async_state {
+ LDB_ASYNC_INIT,
LDB_ASYNC_PENDING,
LDB_ASYNC_DONE
};
int ldb_next_del_trans(struct ldb_module *module);
int ldb_next_second_stage_init(struct ldb_module *module);
-void ldb_set_errstring(struct ldb_module *module, char *err_string);
+void ldb_set_errstring(struct ldb_context *ldb, char *err_string);
void ldb_reset_err_string(struct ldb_context *ldb);
/* The following definitions come from lib/ldb/common/ldb_debug.c */
}
if (msg->r.SearchResultDone.resultcode) {
if (msg->r.SearchResultDone.errormessage) {
- ldb_set_errstring(ac->module, talloc_strdup(ac->module, msg->r.SearchResultDone.errormessage));
+ ldb_set_errstring(ac->module->ldb, talloc_strdup(ac->module, msg->r.SearchResultDone.errormessage));
}
}
h = talloc_zero(ildb->ldap, struct ldb_async_handle);
if (h == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return LDB_ERR_OPERATIONS_ERROR;
}
ildb_ac = talloc(h, struct ildb_async_context);
if (ildb_ac == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
talloc_free(h);
return LDB_ERR_OPERATIONS_ERROR;
}
req = ldap_request_send(ildb->ldap, msg);
if (req == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "async send request failed"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "async send request failed"));
return LDB_ERR_OPERATIONS_ERROR;
}
*handle = NULL;
if (!callback || !context) {
- ldb_set_errstring(module, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context"));
return LDB_ERR_OPERATIONS_ERROR;
}
if (tree == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "Invalid expression parse tree"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Invalid expression parse tree"));
return LDB_ERR_OPERATIONS_ERROR;
}
msg = new_ldap_message(ildb);
if (msg == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "Out of Memory"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
return LDB_ERR_OPERATIONS_ERROR;
}
msg->r.SearchRequest.basedn = ldb_dn_linearize(msg, base);
}
if (msg->r.SearchRequest.basedn == NULL) {
- ldb_set_errstring(module, talloc_asprintf(module, "Unable to determine baseDN"));
+ ldb_set_errstring(module->ldb, talloc_asprintf(module, "Unable to determine baseDN"));
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
int n;
if (!context) {
- ldb_set_errstring(ldb->modules, talloc_asprintf(ldb, "NULL Context in callback"));
+ ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context in callback"));
return LDB_ERR_OPERATIONS_ERROR;
}
return LDB_ERR_OTHER;
}
break;
+ case LDB_WAIT_ONCE:
+ handle->state = LDB_ASYNC_INIT;
+ while (handle->status == LDB_SUCCESS && handle->state == LDB_ASYNC_INIT) {
+ if (event_loop_once(ac->req->conn->event.event_ctx) != 0) {
+ return LDB_ERR_OTHER;
+ }
+ }
+ break;
case LDB_WAIT_ALL:
while (handle->status == LDB_SUCCESS && handle->state != LDB_ASYNC_DONE) {
if (event_loop_once(ac->req->conn->event.event_ctx) != 0) {
lldb->last_rc = ldap_rename_s(lldb->ldap, old_dn, newrdn, parentdn, 1, NULL, NULL);
if (lldb->last_rc != LDAP_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
ret = -1;
}
lldb->last_rc = ldap_delete_s(lldb->ldap, dn);
if (lldb->last_rc != LDAP_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
ret = -1;
}
0, &ldapres);
talloc_free(search_base);
if (lldb->last_rc != LDAP_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
return lldb->last_rc;
}
lldb->last_rc = ldap_add_s(lldb->ldap, dn, mods);
if (lldb->last_rc != LDAP_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
ret = -1;
}
lldb->last_rc = ldap_modify_s(lldb->ldap, dn, mods);
if (lldb->last_rc != LDAP_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(lldb->last_rc)));
ret = -1;
}
ret = sqlite3_exec(lsqlite3->sqlite, query, lsqlite3_search_callback, &msgs, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
ret = sqlite3_exec(lsqlite3->sqlite, insert, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
ret = sqlite3_exec(lsqlite3->sqlite, mod, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
ret = sqlite3_exec(lsqlite3->sqlite, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
if (errmsg) {
- ldb_set_errstring(module, talloc_strdup(module, errmsg));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, errmsg));
free(errmsg);
}
ret = LDB_ERR_OTHER;
if (ltdb_check_at_attributes_values(&msg->elements[i].values[j]) != 0) {
char *err_string = talloc_strdup(module, "Invalid attribute value in an @ATTRIBUTES entry");
if (err_string) {
- ldb_set_errstring(module, err_string);
+ ldb_set_errstring(module->ldb, err_string);
}
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
for (j=0;j<el->num_values;j++) {
if (ldb_msg_find_val(el2, &el->values[j])) {
err_string = talloc_strdup(module, "Type or value exists");
- if (err_string) ldb_set_errstring(module, err_string);
+ if (err_string) ldb_set_errstring(module->ldb, err_string);
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto failed;
}
if (msg_delete_attribute(module, ldb, msg2,
msg->elements[i].name) != 0) {
err_string = talloc_asprintf(module, "No such attribute: %s", msg->elements[i].name);
- if (err_string) ldb_set_errstring(module, err_string);
+ if (err_string) ldb_set_errstring(module->ldb, err_string);
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
msg->elements[i].name,
&msg->elements[i].values[j]) != 0) {
err_string = talloc_asprintf(module, "No such attribute: %s", msg->elements[i].name);
- if (err_string) ldb_set_errstring(module, err_string);
+ if (err_string) ldb_set_errstring(module->ldb, err_string);
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
err_string = talloc_asprintf(module, "Invalid ldb_modify flags on %s: 0x%x",
msg->elements[i].name,
msg->elements[i].flags & LDB_FLAG_MOD_MASK);
- if (err_string) ldb_set_errstring(module, err_string);
+ if (err_string) ldb_set_errstring(module->ldb, err_string);
ret = LDB_ERR_PROTOCOL_ERROR;
goto failed;
}
ltdb_delete(module, newdn);
}
- ldb_set_errstring(module, error_str);
+ ldb_set_errstring(module->ldb, error_str);
talloc_free(msg);
talloc_free(newattrs);
if (mpret != LDB_SUCCESS) {
- ldb_set_errstring(module, talloc_strdup(module, ldb_errstring(privdat->mapped_ldb)));
+ ldb_set_errstring(module->ldb, talloc_strdup(module, ldb_errstring(privdat->mapped_ldb)));
return mpret;
}
res = search_request->op.search.res;
talloc_steal(mem_ctx, res);
if (res->count != 1) {
- ldb_set_errstring(module,
+ ldb_set_errstring(module->ldb,
talloc_asprintf(mem_ctx, "objectClass_handle: "
"search for %s found %d != 1 objects, for entry we just added/modified",
ldb_dn_linearize(mem_ctx, msg->dn),
if (!h) {
error = talloc_strdup(module, "WINS_LDB: INTERNAL ERROR: no winsdb_handle present!");
ldb_debug(module->ldb, LDB_DEBUG_FATAL, "%s", error);
- ldb_set_errstring(module, error);
+ ldb_set_errstring(module->ldb, error);
return LDB_ERR_OTHER;
}