summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/samdb/ldb_modules/rootdse.c70
1 files changed, 17 insertions, 53 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/rootdse.c b/source4/dsdb/samdb/ldb_modules/rootdse.c
index 9cc2e65df6..99e8844ba1 100644
--- a/source4/dsdb/samdb/ldb_modules/rootdse.c
+++ b/source4/dsdb/samdb/ldb_modules/rootdse.c
@@ -47,6 +47,7 @@ struct private_data {
struct rootdse_context {
struct ldb_module *module;
struct ldb_request *req;
+ struct ldb_val netlogon;
};
/*
@@ -478,6 +479,12 @@ static int rootdse_add_dynamic(struct rootdse_context *ac, struct ldb_message *m
}
}
+ if (ac->netlogon.length > 0) {
+ if (ldb_msg_add_value(msg, "netlogon", &ac->netlogon, NULL) != LDB_SUCCESS) {
+ goto failed;
+ }
+ }
+
/* TODO: lots more dynamic attributes should be added here */
edn_control = ldb_request_get_control(ac->req, LDB_CONTROL_EXTENDED_DN_OID);
@@ -598,16 +605,6 @@ static int rootdse_callback(struct ldb_request *req, struct ldb_reply *ares)
switch (ares->type) {
case LDB_REPLY_ENTRY:
- /*
- * if the client explicit asks for the 'netlogon' attribute
- * the reply_entry needs to be skipped
- */
- if (ac->req->op.search.attrs &&
- ldb_attr_in_list(ac->req->op.search.attrs, "netlogon")) {
- talloc_free(ares);
- return LDB_SUCCESS;
- }
-
/* for each record returned post-process to add any dynamic
attributes that have been asked for */
ret = rootdse_add_dynamic(ac, ares->message);
@@ -756,9 +753,7 @@ static int rootdse_handle_netlogon(struct rootdse_context *ac)
int version = -1;
NTSTATUS status;
struct netlogon_samlogon_response netlogon;
- struct ldb_message *msg = NULL;
- int ret, error = LDB_ERR_OPERATIONS_ERROR;
- struct ldb_val blob;
+ int ret = LDB_ERR_OPERATIONS_ERROR;
ldb = ldb_module_get_ctx(ac->module);
tree = ac->req->op.search.tree;
@@ -783,47 +778,15 @@ static int rootdse_handle_netlogon(struct rootdse_context *ac)
goto failed;
}
- status = push_netlogon_samlogon_response(&blob, tmp_ctx, &netlogon);
+ status = push_netlogon_samlogon_response(&ac->netlogon, ac, &netlogon);
if (!NT_STATUS_IS_OK(status)) {
goto failed;
}
- msg = ldb_msg_new(tmp_ctx);
- if (!msg) {
- error = ldb_oom(ldb);
- goto failed;
- }
-
- msg->dn = ldb_dn_new(msg, ldb, "");
- if (!msg->dn) {
- error = ldb_oom(ldb);
- goto failed;
- }
-
- ret = ldb_msg_add_value(msg, "netlogon", &blob, NULL);
- if (ret != LDB_SUCCESS) {
- error = ret;
- goto failed;
- }
-
- ret = ldb_module_send_entry(ac->req, msg, NULL);
- if (ret != LDB_SUCCESS) {
- error = ret;
- goto failed;
- }
-
- ret = ldb_module_done(ac->req, NULL, NULL, LDB_SUCCESS);
- if (ret != LDB_SUCCESS) {
- error = ret;
- goto failed;
- }
-
- talloc_free(tmp_ctx);
- return LDB_SUCCESS;
-
+ ret = LDB_SUCCESS;
failed:
talloc_free(tmp_ctx);
- return ldb_module_done(ac->req, NULL, NULL, error);
+ return ret;
}
static int rootdse_search(struct ldb_module *module, struct ldb_request *req)
@@ -856,11 +819,12 @@ static int rootdse_search(struct ldb_module *module, struct ldb_request *req)
return ldb_operr(ldb);
}
- if (req->op.search.attrs &&
- req->op.search.attrs[0] &&
- req->op.search.attrs[1] == NULL &&
- ldb_attr_cmp(req->op.search.attrs[0], "netlogon") == 0) {
- return rootdse_handle_netlogon(ac);
+ if (do_attribute_explicit(req->op.search.attrs, "netlogon")) {
+ ret = rootdse_handle_netlogon(ac);
+ /* We have to return an empty result, so dont forward `ret' */
+ if (ret != LDB_SUCCESS) {
+ return ldb_module_done(ac->req, NULL, NULL, LDB_SUCCESS);
+ }
}
/* in our db we store the rootDSE with a DN of @ROOTDSE */