2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher 2004
5 Copyright (C) Matthias Dieter Wallnöfer 2009
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "ldap_server/ldap_server.h"
23 #include "../lib/util/dlinklist.h"
24 #include "auth/credentials/credentials.h"
25 #include "auth/gensec/gensec.h"
26 #include "auth/gensec/gensec_internal.h" /* TODO: remove this */
27 #include "auth/common_auth.h"
28 #include "param/param.h"
29 #include "smbd/service_stream.h"
30 #include "dsdb/samdb/samdb.h"
31 #include <ldb_errors.h>
32 #include <ldb_module.h>
34 #include "lib/tsocket/tsocket.h"
35 #include "libcli/ldap/ldap_proto.h"
36 #include "source4/auth/auth.h"
38 static int map_ldb_error(TALLOC_CTX *mem_ctx, int ldb_err,
39 const char *add_err_string, const char **errstring)
43 /* Certain LDB modules need to return very special WERROR codes. Proof
44 * for them here and if they exist skip the rest of the mapping. */
45 if (add_err_string != NULL) {
47 strtol(add_err_string, &endptr, 16);
48 if (endptr != add_err_string) {
49 *errstring = add_err_string;
54 /* Otherwise we calculate here a generic, but appropriate WERROR. */
60 case LDB_ERR_OPERATIONS_ERROR:
61 err = WERR_DS_OPERATIONS_ERROR;
63 case LDB_ERR_PROTOCOL_ERROR:
64 err = WERR_DS_PROTOCOL_ERROR;
66 case LDB_ERR_TIME_LIMIT_EXCEEDED:
67 err = WERR_DS_TIMELIMIT_EXCEEDED;
69 case LDB_ERR_SIZE_LIMIT_EXCEEDED:
70 err = WERR_DS_SIZELIMIT_EXCEEDED;
72 case LDB_ERR_COMPARE_FALSE:
73 err = WERR_DS_COMPARE_FALSE;
75 case LDB_ERR_COMPARE_TRUE:
76 err = WERR_DS_COMPARE_TRUE;
78 case LDB_ERR_AUTH_METHOD_NOT_SUPPORTED:
79 err = WERR_DS_AUTH_METHOD_NOT_SUPPORTED;
81 case LDB_ERR_STRONG_AUTH_REQUIRED:
82 err = WERR_DS_STRONG_AUTH_REQUIRED;
84 case LDB_ERR_REFERRAL:
85 err = WERR_DS_REFERRAL;
87 case LDB_ERR_ADMIN_LIMIT_EXCEEDED:
88 err = WERR_DS_ADMIN_LIMIT_EXCEEDED;
90 case LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION:
91 err = WERR_DS_UNAVAILABLE_CRIT_EXTENSION;
93 case LDB_ERR_CONFIDENTIALITY_REQUIRED:
94 err = WERR_DS_CONFIDENTIALITY_REQUIRED;
96 case LDB_ERR_SASL_BIND_IN_PROGRESS:
99 case LDB_ERR_NO_SUCH_ATTRIBUTE:
100 err = WERR_DS_NO_ATTRIBUTE_OR_VALUE;
102 case LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE:
103 err = WERR_DS_ATTRIBUTE_TYPE_UNDEFINED;
105 case LDB_ERR_INAPPROPRIATE_MATCHING:
106 err = WERR_DS_INAPPROPRIATE_MATCHING;
108 case LDB_ERR_CONSTRAINT_VIOLATION:
109 err = WERR_DS_CONSTRAINT_VIOLATION;
111 case LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS:
112 err = WERR_DS_ATTRIBUTE_OR_VALUE_EXISTS;
114 case LDB_ERR_INVALID_ATTRIBUTE_SYNTAX:
115 err = WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
117 case LDB_ERR_NO_SUCH_OBJECT:
118 err = WERR_DS_NO_SUCH_OBJECT;
120 case LDB_ERR_ALIAS_PROBLEM:
121 err = WERR_DS_ALIAS_PROBLEM;
123 case LDB_ERR_INVALID_DN_SYNTAX:
124 err = WERR_DS_INVALID_DN_SYNTAX;
126 case LDB_ERR_ALIAS_DEREFERENCING_PROBLEM:
127 err = WERR_DS_ALIAS_DEREF_PROBLEM;
129 case LDB_ERR_INAPPROPRIATE_AUTHENTICATION:
130 err = WERR_DS_INAPPROPRIATE_AUTH;
132 case LDB_ERR_INVALID_CREDENTIALS:
133 err = WERR_ACCESS_DENIED;
135 case LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS:
136 err = WERR_DS_INSUFF_ACCESS_RIGHTS;
141 case LDB_ERR_UNAVAILABLE:
142 err = WERR_DS_UNAVAILABLE;
144 case LDB_ERR_UNWILLING_TO_PERFORM:
145 err = WERR_DS_UNWILLING_TO_PERFORM;
147 case LDB_ERR_LOOP_DETECT:
148 err = WERR_DS_LOOP_DETECT;
150 case LDB_ERR_NAMING_VIOLATION:
151 err = WERR_DS_NAMING_VIOLATION;
153 case LDB_ERR_OBJECT_CLASS_VIOLATION:
154 err = WERR_DS_OBJ_CLASS_VIOLATION;
156 case LDB_ERR_NOT_ALLOWED_ON_NON_LEAF:
157 err = WERR_DS_CANT_ON_NON_LEAF;
159 case LDB_ERR_NOT_ALLOWED_ON_RDN:
160 err = WERR_DS_CANT_ON_RDN;
162 case LDB_ERR_ENTRY_ALREADY_EXISTS:
163 err = WERR_DS_OBJ_STRING_NAME_EXISTS;
165 case LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED:
166 err = WERR_DS_CANT_MOD_OBJ_CLASS;
168 case LDB_ERR_AFFECTS_MULTIPLE_DSAS:
169 err = WERR_DS_AFFECTS_MULTIPLE_DSAS;
172 err = WERR_DS_GENERIC_ERROR;
176 *errstring = talloc_asprintf(mem_ctx, "%08X: %s", W_ERROR_V(err),
177 add_err_string != NULL ? add_err_string : ldb_strerror(ldb_err));
179 /* result is 1:1 for now */
184 connect to the sam database
186 int ldapsrv_backend_Init(struct ldapsrv_connection *conn,
189 int ret = samdb_connect_url(conn,
190 conn->connection->event.ctx,
193 conn->global_catalog ? LDB_FLG_RDONLY : 0,
195 conn->connection->remote_address,
198 if (ret != LDB_SUCCESS) {
202 if (conn->server_credentials) {
203 struct gensec_security *gensec_security = NULL;
204 const char **sasl_mechs = NULL;
207 status = samba_server_gensec_start(conn,
208 conn->connection->event.ctx,
209 conn->connection->msg_ctx,
211 conn->server_credentials,
214 if (!NT_STATUS_IS_OK(status)) {
215 DBG_ERR("samba_server_gensec_start failed: %s\n",
217 return LDB_ERR_OPERATIONS_ERROR;
220 /* ldb can have a different lifetime to conn, so we
221 need to ensure that sasl_mechs lives as long as the
223 sasl_mechs = gensec_security_sasl_names(gensec_security,
225 TALLOC_FREE(gensec_security);
226 if (sasl_mechs == NULL) {
227 DBG_ERR("Failed to get sasl mechs!\n");
228 return LDB_ERR_OPERATIONS_ERROR;
231 ldb_set_opaque(conn->ldb, "supportedSASLMechanisms", sasl_mechs);
237 struct ldapsrv_reply *ldapsrv_init_reply(struct ldapsrv_call *call, uint8_t type)
239 struct ldapsrv_reply *reply;
241 reply = talloc_zero(call, struct ldapsrv_reply);
245 reply->msg = talloc_zero(reply, struct ldap_message);
246 if (reply->msg == NULL) {
251 reply->msg->messageid = call->request->messageid;
252 reply->msg->type = type;
253 reply->msg->controls = NULL;
259 * Encode a reply to an LDAP client as ASN.1, free the original memory
261 static NTSTATUS ldapsrv_encode(TALLOC_CTX *mem_ctx,
262 struct ldapsrv_reply *reply)
264 bool bret = ldap_encode(reply->msg,
265 samba_ldap_control_handlers(),
268 TALLOC_FREE(reply->msg);
270 DEBUG(0,("Failed to encode ldap reply of type %d: "
271 "ldap_encode() failed\n",
273 return NT_STATUS_NO_MEMORY;
276 talloc_set_name_const(reply->blob.data,
277 "Outgoing, encoded single LDAP reply");
283 * Queue a reply (encoding it also), even if it would exceed the
284 * limit. This allows the error packet with LDAP_SIZE_LIMIT_EXCEEDED
287 static NTSTATUS ldapsrv_queue_reply_forced(struct ldapsrv_call *call,
288 struct ldapsrv_reply *reply)
290 NTSTATUS status = ldapsrv_encode(call, reply);
292 if (NT_STATUS_IS_OK(status)) {
293 DLIST_ADD_END(call->replies, reply);
299 * Queue a reply (encoding it also) but check we do not send more than
300 * LDAP_SERVER_MAX_REPLY_SIZE of responses as a way to limit the
301 * amount of data a client can make us allocate.
303 NTSTATUS ldapsrv_queue_reply(struct ldapsrv_call *call, struct ldapsrv_reply *reply)
305 NTSTATUS status = ldapsrv_encode(call, reply);
307 if (!NT_STATUS_IS_OK(status)) {
311 if (call->reply_size > call->reply_size + reply->blob.length
312 || call->reply_size + reply->blob.length > LDAP_SERVER_MAX_REPLY_SIZE) {
313 DBG_WARNING("Refusing to queue LDAP search response size "
314 "of more than %zu bytes\n",
315 LDAP_SERVER_MAX_REPLY_SIZE);
316 TALLOC_FREE(reply->blob.data);
317 return NT_STATUS_FILE_TOO_LARGE;
320 call->reply_size += reply->blob.length;
322 DLIST_ADD_END(call->replies, reply);
327 static NTSTATUS ldapsrv_unwilling(struct ldapsrv_call *call, int error)
329 struct ldapsrv_reply *reply;
330 struct ldap_ExtendedResponse *r;
332 DEBUG(10,("Unwilling type[%d] id[%d]\n", call->request->type, call->request->messageid));
334 reply = ldapsrv_init_reply(call, LDAP_TAG_ExtendedResponse);
336 return NT_STATUS_NO_MEMORY;
339 r = &reply->msg->r.ExtendedResponse;
340 r->response.resultcode = error;
341 r->response.dn = NULL;
342 r->response.errormessage = NULL;
343 r->response.referral = NULL;
347 ldapsrv_queue_reply(call, reply);
351 static int ldapsrv_add_with_controls(struct ldapsrv_call *call,
352 const struct ldb_message *message,
353 struct ldb_control **controls,
354 struct ldb_result *res)
356 struct ldb_context *ldb = call->conn->ldb;
357 struct ldb_request *req;
360 ret = ldb_msg_sanity_check(ldb, message);
361 if (ret != LDB_SUCCESS) {
365 ret = ldb_build_add_req(&req, ldb, ldb,
369 ldb_modify_default_callback,
372 if (ret != LDB_SUCCESS) return ret;
374 if (call->conn->global_catalog) {
375 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port");
377 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);
379 ret = ldb_transaction_start(ldb);
380 if (ret != LDB_SUCCESS) {
384 if (!call->conn->is_privileged) {
385 ldb_req_mark_untrusted(req);
388 LDB_REQ_SET_LOCATION(req);
390 ret = ldb_request(ldb, req);
391 if (ret == LDB_SUCCESS) {
392 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
395 if (ret == LDB_SUCCESS) {
396 ret = ldb_transaction_commit(ldb);
399 ldb_transaction_cancel(ldb);
406 /* create and execute a modify request */
407 static int ldapsrv_mod_with_controls(struct ldapsrv_call *call,
408 const struct ldb_message *message,
409 struct ldb_control **controls,
410 struct ldb_result *res)
412 struct ldb_context *ldb = call->conn->ldb;
413 struct ldb_request *req;
416 ret = ldb_msg_sanity_check(ldb, message);
417 if (ret != LDB_SUCCESS) {
421 ret = ldb_build_mod_req(&req, ldb, ldb,
425 ldb_modify_default_callback,
428 if (ret != LDB_SUCCESS) {
432 if (call->conn->global_catalog) {
433 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port");
435 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);
437 ret = ldb_transaction_start(ldb);
438 if (ret != LDB_SUCCESS) {
442 if (!call->conn->is_privileged) {
443 ldb_req_mark_untrusted(req);
446 LDB_REQ_SET_LOCATION(req);
448 ret = ldb_request(ldb, req);
449 if (ret == LDB_SUCCESS) {
450 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
453 if (ret == LDB_SUCCESS) {
454 ret = ldb_transaction_commit(ldb);
457 ldb_transaction_cancel(ldb);
464 /* create and execute a delete request */
465 static int ldapsrv_del_with_controls(struct ldapsrv_call *call,
467 struct ldb_control **controls,
468 struct ldb_result *res)
470 struct ldb_context *ldb = call->conn->ldb;
471 struct ldb_request *req;
474 ret = ldb_build_del_req(&req, ldb, ldb,
478 ldb_modify_default_callback,
481 if (ret != LDB_SUCCESS) return ret;
483 if (call->conn->global_catalog) {
484 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port");
486 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);
488 ret = ldb_transaction_start(ldb);
489 if (ret != LDB_SUCCESS) {
493 if (!call->conn->is_privileged) {
494 ldb_req_mark_untrusted(req);
497 LDB_REQ_SET_LOCATION(req);
499 ret = ldb_request(ldb, req);
500 if (ret == LDB_SUCCESS) {
501 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
504 if (ret == LDB_SUCCESS) {
505 ret = ldb_transaction_commit(ldb);
508 ldb_transaction_cancel(ldb);
515 static int ldapsrv_rename_with_controls(struct ldapsrv_call *call,
516 struct ldb_dn *olddn,
517 struct ldb_dn *newdn,
518 struct ldb_control **controls,
519 struct ldb_result *res)
521 struct ldb_context *ldb = call->conn->ldb;
522 struct ldb_request *req;
525 ret = ldb_build_rename_req(&req, ldb, ldb,
530 ldb_modify_default_callback,
533 if (ret != LDB_SUCCESS) return ret;
535 if (call->conn->global_catalog) {
536 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port");
538 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);
540 ret = ldb_transaction_start(ldb);
541 if (ret != LDB_SUCCESS) {
545 if (!call->conn->is_privileged) {
546 ldb_req_mark_untrusted(req);
549 LDB_REQ_SET_LOCATION(req);
551 ret = ldb_request(ldb, req);
552 if (ret == LDB_SUCCESS) {
553 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
556 if (ret == LDB_SUCCESS) {
557 ret = ldb_transaction_commit(ldb);
560 ldb_transaction_cancel(ldb);
569 struct ldapsrv_context {
570 struct ldapsrv_call *call;
573 struct ldb_control **controls;
574 size_t count; /* For notificaiton only */
577 static int ldap_server_search_callback(struct ldb_request *req, struct ldb_reply *ares)
579 struct ldapsrv_context *ctx = talloc_get_type(req->context, struct ldapsrv_context);
580 struct ldapsrv_call *call = ctx->call;
581 struct ldb_context *ldb = call->conn->ldb;
583 struct ldapsrv_reply *ent_r = NULL;
584 struct ldap_SearchResEntry *ent;
589 return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
591 if (ares->error != LDB_SUCCESS) {
592 return ldb_request_done(req, ares->error);
595 switch (ares->type) {
596 case LDB_REPLY_ENTRY:
598 struct ldb_message *msg = ares->message;
599 ent_r = ldapsrv_init_reply(call, LDAP_TAG_SearchResultEntry);
607 * Put the LDAP search response data under ent_r->msg
608 * so we can free that later once encoded
610 talloc_steal(ent_r->msg, msg);
612 ent = &ent_r->msg->r.SearchResultEntry;
613 ent->dn = ldb_dn_get_extended_linearized(ent_r, msg->dn,
615 ent->num_attributes = 0;
616 ent->attributes = NULL;
617 if (msg->num_elements == 0) {
620 ent->num_attributes = msg->num_elements;
621 ent->attributes = talloc_array(ent_r, struct ldb_message_element, ent->num_attributes);
622 if (ent->attributes == NULL) {
626 for (j=0; j < ent->num_attributes; j++) {
627 ent->attributes[j].name = msg->elements[j].name;
628 ent->attributes[j].num_values = 0;
629 ent->attributes[j].values = NULL;
630 if (ctx->attributesonly && (msg->elements[j].num_values == 0)) {
633 ent->attributes[j].num_values = msg->elements[j].num_values;
634 ent->attributes[j].values = msg->elements[j].values;
637 status = ldapsrv_queue_reply(call, ent_r);
638 if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_TOO_LARGE)) {
639 ret = ldb_request_done(req,
640 LDB_ERR_SIZE_LIMIT_EXCEEDED);
641 ldb_asprintf_errstring(ldb,
642 "LDAP search response size "
643 "limited to %zu bytes\n",
644 LDAP_SERVER_MAX_REPLY_SIZE);
645 } else if (!NT_STATUS_IS_OK(status)) {
646 ret = ldb_request_done(req,
653 case LDB_REPLY_REFERRAL:
655 struct ldap_SearchResRef *ent_ref;
658 * TODO: This should be handled by the notification
661 if (call->notification.busy) {
666 ent_r = ldapsrv_init_reply(call, LDAP_TAG_SearchResultReference);
672 * Put the LDAP referral data under ent_r->msg
673 * so we can free that later once encoded
675 talloc_steal(ent_r->msg, ares->referral);
677 ent_ref = &ent_r->msg->r.SearchResultReference;
678 ent_ref->referral = ares->referral;
680 status = ldapsrv_queue_reply(call, ent_r);
681 if (!NT_STATUS_IS_OK(status)) {
682 ret = LDB_ERR_OPERATIONS_ERROR;
691 * We don't queue the reply for this one, we let that
694 ctx->controls = talloc_move(ctx, &ares->controls);
697 return ldb_request_done(req, LDB_SUCCESS);
701 ret = LDB_ERR_OPERATIONS_ERROR;
709 static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
711 struct ldap_SearchRequest *req = &call->request->r.SearchRequest;
712 struct ldap_Result *done;
713 struct ldapsrv_reply *done_r;
714 TALLOC_CTX *local_ctx;
715 struct ldapsrv_context *callback_ctx = NULL;
716 struct ldb_context *samdb = talloc_get_type(call->conn->ldb, struct ldb_context);
717 struct ldb_dn *basedn;
718 struct ldb_request *lreq;
719 struct ldb_control *search_control;
720 struct ldb_search_options_control *search_options;
721 struct ldb_control *extended_dn_control;
722 struct ldb_extended_dn_control *extended_dn_decoded = NULL;
723 struct ldb_control *notification_control = NULL;
724 enum ldb_scope scope = LDB_SCOPE_DEFAULT;
725 const char **attrs = NULL;
726 const char *scope_str, *errstr = NULL;
730 int extended_type = 1;
732 DEBUG(10, ("SearchRequest"));
733 DEBUGADD(10, (" basedn: %s", req->basedn));
734 DEBUGADD(10, (" filter: %s\n", ldb_filter_from_tree(call, req->tree)));
736 local_ctx = talloc_new(call);
737 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
739 basedn = ldb_dn_new(local_ctx, samdb, req->basedn);
740 NT_STATUS_HAVE_NO_MEMORY(basedn);
742 DEBUG(10, ("SearchRequest: basedn: [%s]\n", req->basedn));
743 DEBUG(10, ("SearchRequest: filter: [%s]\n", ldb_filter_from_tree(call, req->tree)));
745 switch (req->scope) {
746 case LDAP_SEARCH_SCOPE_BASE:
748 scope = LDB_SCOPE_BASE;
750 case LDAP_SEARCH_SCOPE_SINGLE:
752 scope = LDB_SCOPE_ONELEVEL;
754 case LDAP_SEARCH_SCOPE_SUB:
756 scope = LDB_SCOPE_SUBTREE;
759 result = LDAP_PROTOCOL_ERROR;
760 map_ldb_error(local_ctx, LDB_ERR_PROTOCOL_ERROR, NULL,
762 errstr = talloc_asprintf(local_ctx,
763 "%s. Invalid scope", errstr);
766 DEBUG(10,("SearchRequest: scope: [%s]\n", scope_str));
768 if (req->num_attributes >= 1) {
769 attrs = talloc_array(local_ctx, const char *, req->num_attributes+1);
770 NT_STATUS_HAVE_NO_MEMORY(attrs);
772 for (i=0; i < req->num_attributes; i++) {
773 DEBUG(10,("SearchRequest: attrs: [%s]\n",req->attributes[i]));
774 attrs[i] = req->attributes[i];
779 DEBUG(5,("ldb_request %s dn=%s filter=%s\n",
780 scope_str, req->basedn, ldb_filter_from_tree(call, req->tree)));
782 callback_ctx = talloc_zero(local_ctx, struct ldapsrv_context);
783 NT_STATUS_HAVE_NO_MEMORY(callback_ctx);
784 callback_ctx->call = call;
785 callback_ctx->extended_type = extended_type;
786 callback_ctx->attributesonly = req->attributesonly;
788 ldb_ret = ldb_build_search_req_ex(&lreq, samdb, local_ctx,
791 call->request->controls,
793 ldap_server_search_callback,
796 if (ldb_ret != LDB_SUCCESS) {
800 if (call->conn->global_catalog) {
801 search_control = ldb_request_get_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID);
803 search_options = NULL;
804 if (search_control) {
805 search_options = talloc_get_type(search_control->data, struct ldb_search_options_control);
806 search_options->search_options |= LDB_SEARCH_OPTION_PHANTOM_ROOT;
808 search_options = talloc(lreq, struct ldb_search_options_control);
809 NT_STATUS_HAVE_NO_MEMORY(search_options);
810 search_options->search_options = LDB_SEARCH_OPTION_PHANTOM_ROOT;
811 ldb_request_add_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID, false, search_options);
814 ldb_request_add_control(lreq, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);
817 extended_dn_control = ldb_request_get_control(lreq, LDB_CONTROL_EXTENDED_DN_OID);
819 if (extended_dn_control) {
820 if (extended_dn_control->data) {
821 extended_dn_decoded = talloc_get_type(extended_dn_control->data, struct ldb_extended_dn_control);
822 extended_type = extended_dn_decoded->type;
826 callback_ctx->extended_type = extended_type;
829 notification_control = ldb_request_get_control(lreq, LDB_CONTROL_NOTIFICATION_OID);
830 if (notification_control != NULL) {
831 const struct ldapsrv_call *pc = NULL;
834 for (pc = call->conn->pending_calls; pc != NULL; pc = pc->next) {
838 if (count >= call->conn->limits.max_notifications) {
839 DEBUG(10,("SearchRequest: error MaxNotificationPerConn\n"));
840 result = map_ldb_error(local_ctx,
841 LDB_ERR_ADMIN_LIMIT_EXCEEDED,
842 "MaxNotificationPerConn reached",
848 * For now we need to do periodic retries on our own.
849 * As the dsdb_notification module will return after each run.
851 call->notification.busy = true;
855 const char *scheme = NULL;
856 switch (call->conn->referral_scheme) {
857 case LDAP_REFERRAL_SCHEME_LDAPS:
863 ldb_ret = ldb_set_opaque(
865 LDAP_REFERRAL_SCHEME_OPAQUE,
866 discard_const_p(char *, scheme));
867 if (ldb_ret != LDB_SUCCESS) {
872 ldb_set_timeout(samdb, lreq, req->timelimit);
874 if (!call->conn->is_privileged) {
875 ldb_req_mark_untrusted(lreq);
878 LDB_REQ_SET_LOCATION(lreq);
880 ldb_ret = ldb_request(samdb, lreq);
882 if (ldb_ret != LDB_SUCCESS) {
886 ldb_ret = ldb_wait(lreq->handle, LDB_WAIT_ALL);
888 if (ldb_ret == LDB_SUCCESS) {
889 if (call->notification.busy) {
890 /* Move/Add it to the end */
891 DLIST_DEMOTE(call->conn->pending_calls, call);
892 call->notification.generation =
893 call->conn->service->notification.generation;
895 if (callback_ctx->count != 0) {
896 call->notification.generation += 1;
897 ldapsrv_notification_retry_setup(call->conn->service,
901 talloc_free(local_ctx);
907 DLIST_REMOVE(call->conn->pending_calls, call);
908 call->notification.busy = false;
910 done_r = ldapsrv_init_reply(call, LDAP_TAG_SearchResultDone);
911 NT_STATUS_HAVE_NO_MEMORY(done_r);
913 done = &done_r->msg->r.SearchResultDone;
915 done->referral = NULL;
918 } else if (ldb_ret == LDB_SUCCESS) {
919 if (callback_ctx->controls) {
920 done_r->msg->controls = callback_ctx->controls;
921 talloc_steal(done_r->msg, callback_ctx->controls);
923 result = LDB_SUCCESS;
925 DEBUG(10,("SearchRequest: error\n"));
926 result = map_ldb_error(local_ctx, ldb_ret, ldb_errstring(samdb),
930 done->resultcode = result;
931 done->errormessage = (errstr?talloc_strdup(done_r, errstr):NULL);
933 talloc_free(local_ctx);
935 return ldapsrv_queue_reply_forced(call, done_r);
938 static NTSTATUS ldapsrv_ModifyRequest(struct ldapsrv_call *call)
940 struct ldap_ModifyRequest *req = &call->request->r.ModifyRequest;
941 struct ldap_Result *modify_result;
942 struct ldapsrv_reply *modify_reply;
943 TALLOC_CTX *local_ctx;
944 struct ldb_context *samdb = call->conn->ldb;
945 struct ldb_message *msg = NULL;
947 const char *errstr = NULL;
948 int result = LDAP_SUCCESS;
951 struct ldb_result *res = NULL;
953 DEBUG(10, ("ModifyRequest"));
954 DEBUGADD(10, (" dn: %s\n", req->dn));
956 local_ctx = talloc_named(call, 0, "ModifyRequest local memory context");
957 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
959 dn = ldb_dn_new(local_ctx, samdb, req->dn);
960 NT_STATUS_HAVE_NO_MEMORY(dn);
962 DEBUG(10, ("ModifyRequest: dn: [%s]\n", req->dn));
964 msg = ldb_msg_new(local_ctx);
965 NT_STATUS_HAVE_NO_MEMORY(msg);
969 if (req->num_mods > 0) {
970 msg->num_elements = req->num_mods;
971 msg->elements = talloc_array(msg, struct ldb_message_element, req->num_mods);
972 NT_STATUS_HAVE_NO_MEMORY(msg->elements);
974 for (i=0; i < msg->num_elements; i++) {
975 msg->elements[i].name = discard_const_p(char, req->mods[i].attrib.name);
976 msg->elements[i].num_values = 0;
977 msg->elements[i].values = NULL;
979 switch (req->mods[i].type) {
981 result = LDAP_PROTOCOL_ERROR;
982 map_ldb_error(local_ctx,
983 LDB_ERR_PROTOCOL_ERROR, NULL, &errstr);
984 errstr = talloc_asprintf(local_ctx,
985 "%s. Invalid LDAP_MODIFY_* type", errstr);
987 case LDAP_MODIFY_ADD:
988 msg->elements[i].flags = LDB_FLAG_MOD_ADD;
990 case LDAP_MODIFY_DELETE:
991 msg->elements[i].flags = LDB_FLAG_MOD_DELETE;
993 case LDAP_MODIFY_REPLACE:
994 msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
998 msg->elements[i].num_values = req->mods[i].attrib.num_values;
999 if (msg->elements[i].num_values > 0) {
1000 msg->elements[i].values = talloc_array(msg->elements, struct ldb_val,
1001 msg->elements[i].num_values);
1002 NT_STATUS_HAVE_NO_MEMORY(msg->elements[i].values);
1004 for (j=0; j < msg->elements[i].num_values; j++) {
1005 msg->elements[i].values[j].length = req->mods[i].attrib.values[j].length;
1006 msg->elements[i].values[j].data = req->mods[i].attrib.values[j].data;
1013 modify_reply = ldapsrv_init_reply(call, LDAP_TAG_ModifyResponse);
1014 NT_STATUS_HAVE_NO_MEMORY(modify_reply);
1016 if (result == LDAP_SUCCESS) {
1017 res = talloc_zero(local_ctx, struct ldb_result);
1018 NT_STATUS_HAVE_NO_MEMORY(res);
1019 ldb_ret = ldapsrv_mod_with_controls(call, msg, call->request->controls, res);
1020 result = map_ldb_error(local_ctx, ldb_ret, ldb_errstring(samdb),
1024 modify_result = &modify_reply->msg->r.ModifyResponse;
1025 modify_result->dn = NULL;
1026 if ((res != NULL) && (res->refs != NULL)) {
1027 modify_result->resultcode = map_ldb_error(local_ctx,
1030 modify_result->errormessage = (errstr?talloc_strdup(modify_reply, errstr):NULL);
1031 modify_result->referral = talloc_strdup(call, *res->refs);
1033 modify_result->resultcode = result;
1034 modify_result->errormessage = (errstr?talloc_strdup(modify_reply, errstr):NULL);
1035 modify_result->referral = NULL;
1037 talloc_free(local_ctx);
1039 return ldapsrv_queue_reply(call, modify_reply);
1043 static NTSTATUS ldapsrv_AddRequest(struct ldapsrv_call *call)
1045 struct ldap_AddRequest *req = &call->request->r.AddRequest;
1046 struct ldap_Result *add_result;
1047 struct ldapsrv_reply *add_reply;
1048 TALLOC_CTX *local_ctx;
1049 struct ldb_context *samdb = call->conn->ldb;
1050 struct ldb_message *msg = NULL;
1052 const char *errstr = NULL;
1053 int result = LDAP_SUCCESS;
1056 struct ldb_result *res = NULL;
1058 DEBUG(10, ("AddRequest"));
1059 DEBUGADD(10, (" dn: %s\n", req->dn));
1061 local_ctx = talloc_named(call, 0, "AddRequest local memory context");
1062 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
1064 dn = ldb_dn_new(local_ctx, samdb, req->dn);
1065 NT_STATUS_HAVE_NO_MEMORY(dn);
1067 DEBUG(10, ("AddRequest: dn: [%s]\n", req->dn));
1069 msg = talloc(local_ctx, struct ldb_message);
1070 NT_STATUS_HAVE_NO_MEMORY(msg);
1073 msg->num_elements = 0;
1074 msg->elements = NULL;
1076 if (req->num_attributes > 0) {
1077 msg->num_elements = req->num_attributes;
1078 msg->elements = talloc_array(msg, struct ldb_message_element, msg->num_elements);
1079 NT_STATUS_HAVE_NO_MEMORY(msg->elements);
1081 for (i=0; i < msg->num_elements; i++) {
1082 msg->elements[i].name = discard_const_p(char, req->attributes[i].name);
1083 msg->elements[i].flags = 0;
1084 msg->elements[i].num_values = 0;
1085 msg->elements[i].values = NULL;
1087 if (req->attributes[i].num_values > 0) {
1088 msg->elements[i].num_values = req->attributes[i].num_values;
1089 msg->elements[i].values = talloc_array(msg->elements, struct ldb_val,
1090 msg->elements[i].num_values);
1091 NT_STATUS_HAVE_NO_MEMORY(msg->elements[i].values);
1093 for (j=0; j < msg->elements[i].num_values; j++) {
1094 msg->elements[i].values[j].length = req->attributes[i].values[j].length;
1095 msg->elements[i].values[j].data = req->attributes[i].values[j].data;
1101 add_reply = ldapsrv_init_reply(call, LDAP_TAG_AddResponse);
1102 NT_STATUS_HAVE_NO_MEMORY(add_reply);
1104 if (result == LDAP_SUCCESS) {
1105 res = talloc_zero(local_ctx, struct ldb_result);
1106 NT_STATUS_HAVE_NO_MEMORY(res);
1107 ldb_ret = ldapsrv_add_with_controls(call, msg, call->request->controls, res);
1108 result = map_ldb_error(local_ctx, ldb_ret, ldb_errstring(samdb),
1112 add_result = &add_reply->msg->r.AddResponse;
1113 add_result->dn = NULL;
1114 if ((res != NULL) && (res->refs != NULL)) {
1115 add_result->resultcode = map_ldb_error(local_ctx,
1116 LDB_ERR_REFERRAL, NULL,
1118 add_result->errormessage = (errstr?talloc_strdup(add_reply,errstr):NULL);
1119 add_result->referral = talloc_strdup(call, *res->refs);
1121 add_result->resultcode = result;
1122 add_result->errormessage = (errstr?talloc_strdup(add_reply,errstr):NULL);
1123 add_result->referral = NULL;
1125 talloc_free(local_ctx);
1127 return ldapsrv_queue_reply(call, add_reply);
1131 static NTSTATUS ldapsrv_DelRequest(struct ldapsrv_call *call)
1133 struct ldap_DelRequest *req = &call->request->r.DelRequest;
1134 struct ldap_Result *del_result;
1135 struct ldapsrv_reply *del_reply;
1136 TALLOC_CTX *local_ctx;
1137 struct ldb_context *samdb = call->conn->ldb;
1139 const char *errstr = NULL;
1140 int result = LDAP_SUCCESS;
1142 struct ldb_result *res = NULL;
1144 DEBUG(10, ("DelRequest"));
1145 DEBUGADD(10, (" dn: %s\n", req->dn));
1147 local_ctx = talloc_named(call, 0, "DelRequest local memory context");
1148 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
1150 dn = ldb_dn_new(local_ctx, samdb, req->dn);
1151 NT_STATUS_HAVE_NO_MEMORY(dn);
1153 DEBUG(10, ("DelRequest: dn: [%s]\n", req->dn));
1155 del_reply = ldapsrv_init_reply(call, LDAP_TAG_DelResponse);
1156 NT_STATUS_HAVE_NO_MEMORY(del_reply);
1158 if (result == LDAP_SUCCESS) {
1159 res = talloc_zero(local_ctx, struct ldb_result);
1160 NT_STATUS_HAVE_NO_MEMORY(res);
1161 ldb_ret = ldapsrv_del_with_controls(call, dn, call->request->controls, res);
1162 result = map_ldb_error(local_ctx, ldb_ret, ldb_errstring(samdb),
1166 del_result = &del_reply->msg->r.DelResponse;
1167 del_result->dn = NULL;
1168 if ((res != NULL) && (res->refs != NULL)) {
1169 del_result->resultcode = map_ldb_error(local_ctx,
1170 LDB_ERR_REFERRAL, NULL,
1172 del_result->errormessage = (errstr?talloc_strdup(del_reply,errstr):NULL);
1173 del_result->referral = talloc_strdup(call, *res->refs);
1175 del_result->resultcode = result;
1176 del_result->errormessage = (errstr?talloc_strdup(del_reply,errstr):NULL);
1177 del_result->referral = NULL;
1180 talloc_free(local_ctx);
1182 return ldapsrv_queue_reply(call, del_reply);
1185 static NTSTATUS ldapsrv_ModifyDNRequest(struct ldapsrv_call *call)
1187 struct ldap_ModifyDNRequest *req = &call->request->r.ModifyDNRequest;
1188 struct ldap_Result *modifydn;
1189 struct ldapsrv_reply *modifydn_r;
1190 TALLOC_CTX *local_ctx;
1191 struct ldb_context *samdb = call->conn->ldb;
1192 struct ldb_dn *olddn, *newdn=NULL, *newrdn;
1193 struct ldb_dn *parentdn = NULL;
1194 const char *errstr = NULL;
1195 int result = LDAP_SUCCESS;
1197 struct ldb_result *res = NULL;
1199 DEBUG(10, ("ModifyDNRequest"));
1200 DEBUGADD(10, (" dn: %s", req->dn));
1201 DEBUGADD(10, (" newrdn: %s\n", req->newrdn));
1203 local_ctx = talloc_named(call, 0, "ModifyDNRequest local memory context");
1204 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
1206 olddn = ldb_dn_new(local_ctx, samdb, req->dn);
1207 NT_STATUS_HAVE_NO_MEMORY(olddn);
1209 newrdn = ldb_dn_new(local_ctx, samdb, req->newrdn);
1210 NT_STATUS_HAVE_NO_MEMORY(newrdn);
1212 DEBUG(10, ("ModifyDNRequest: olddn: [%s]\n", req->dn));
1213 DEBUG(10, ("ModifyDNRequest: newrdn: [%s]\n", req->newrdn));
1215 if (ldb_dn_get_comp_num(newrdn) == 0) {
1216 result = LDAP_PROTOCOL_ERROR;
1217 map_ldb_error(local_ctx, LDB_ERR_PROTOCOL_ERROR, NULL,
1222 if (ldb_dn_get_comp_num(newrdn) > 1) {
1223 result = LDAP_NAMING_VIOLATION;
1224 map_ldb_error(local_ctx, LDB_ERR_NAMING_VIOLATION, NULL,
1229 /* we can't handle the rename if we should not remove the old dn */
1230 if (!req->deleteolddn) {
1231 result = LDAP_UNWILLING_TO_PERFORM;
1232 map_ldb_error(local_ctx, LDB_ERR_UNWILLING_TO_PERFORM, NULL,
1234 errstr = talloc_asprintf(local_ctx,
1235 "%s. Old RDN must be deleted", errstr);
1239 if (req->newsuperior) {
1240 DEBUG(10, ("ModifyDNRequest: newsuperior: [%s]\n", req->newsuperior));
1241 parentdn = ldb_dn_new(local_ctx, samdb, req->newsuperior);
1245 parentdn = ldb_dn_get_parent(local_ctx, olddn);
1248 result = LDAP_NO_SUCH_OBJECT;
1249 map_ldb_error(local_ctx, LDB_ERR_NO_SUCH_OBJECT, NULL, &errstr);
1253 if ( ! ldb_dn_add_child(parentdn, newrdn)) {
1254 result = LDAP_OTHER;
1255 map_ldb_error(local_ctx, LDB_ERR_OTHER, NULL, &errstr);
1261 modifydn_r = ldapsrv_init_reply(call, LDAP_TAG_ModifyDNResponse);
1262 NT_STATUS_HAVE_NO_MEMORY(modifydn_r);
1264 if (result == LDAP_SUCCESS) {
1265 res = talloc_zero(local_ctx, struct ldb_result);
1266 NT_STATUS_HAVE_NO_MEMORY(res);
1267 ldb_ret = ldapsrv_rename_with_controls(call, olddn, newdn, call->request->controls, res);
1268 result = map_ldb_error(local_ctx, ldb_ret, ldb_errstring(samdb),
1272 modifydn = &modifydn_r->msg->r.ModifyDNResponse;
1273 modifydn->dn = NULL;
1274 if ((res != NULL) && (res->refs != NULL)) {
1275 modifydn->resultcode = map_ldb_error(local_ctx,
1276 LDB_ERR_REFERRAL, NULL,
1278 modifydn->errormessage = (errstr?talloc_strdup(modifydn_r,errstr):NULL);
1279 modifydn->referral = talloc_strdup(call, *res->refs);
1281 modifydn->resultcode = result;
1282 modifydn->errormessage = (errstr?talloc_strdup(modifydn_r,errstr):NULL);
1283 modifydn->referral = NULL;
1286 talloc_free(local_ctx);
1288 return ldapsrv_queue_reply(call, modifydn_r);
1291 static NTSTATUS ldapsrv_CompareRequest(struct ldapsrv_call *call)
1293 struct ldap_CompareRequest *req = &call->request->r.CompareRequest;
1294 struct ldap_Result *compare;
1295 struct ldapsrv_reply *compare_r;
1296 TALLOC_CTX *local_ctx;
1297 struct ldb_context *samdb = call->conn->ldb;
1298 struct ldb_result *res = NULL;
1300 const char *attrs[1];
1301 const char *errstr = NULL;
1302 const char *filter = NULL;
1303 int result = LDAP_SUCCESS;
1306 DEBUG(10, ("CompareRequest"));
1307 DEBUGADD(10, (" dn: %s\n", req->dn));
1309 local_ctx = talloc_named(call, 0, "CompareRequest local_memory_context");
1310 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
1312 dn = ldb_dn_new(local_ctx, samdb, req->dn);
1313 NT_STATUS_HAVE_NO_MEMORY(dn);
1315 DEBUG(10, ("CompareRequest: dn: [%s]\n", req->dn));
1316 filter = talloc_asprintf(local_ctx, "(%s=%*s)", req->attribute,
1317 (int)req->value.length, req->value.data);
1318 NT_STATUS_HAVE_NO_MEMORY(filter);
1320 DEBUGADD(10, ("CompareRequest: attribute: [%s]\n", filter));
1324 compare_r = ldapsrv_init_reply(call, LDAP_TAG_CompareResponse);
1325 NT_STATUS_HAVE_NO_MEMORY(compare_r);
1327 if (result == LDAP_SUCCESS) {
1328 ldb_ret = ldb_search(samdb, local_ctx, &res,
1329 dn, LDB_SCOPE_BASE, attrs, "%s", filter);
1330 if (ldb_ret != LDB_SUCCESS) {
1331 result = map_ldb_error(local_ctx, ldb_ret,
1332 ldb_errstring(samdb), &errstr);
1333 DEBUG(10,("CompareRequest: error: %s\n", errstr));
1334 } else if (res->count == 0) {
1335 DEBUG(10,("CompareRequest: doesn't matched\n"));
1336 result = LDAP_COMPARE_FALSE;
1338 } else if (res->count == 1) {
1339 DEBUG(10,("CompareRequest: matched\n"));
1340 result = LDAP_COMPARE_TRUE;
1342 } else if (res->count > 1) {
1343 result = LDAP_OTHER;
1344 map_ldb_error(local_ctx, LDB_ERR_OTHER, NULL, &errstr);
1345 errstr = talloc_asprintf(local_ctx,
1346 "%s. Too many objects match!", errstr);
1347 DEBUG(10,("CompareRequest: %d results: %s\n", res->count, errstr));
1351 compare = &compare_r->msg->r.CompareResponse;
1353 compare->resultcode = result;
1354 compare->errormessage = (errstr?talloc_strdup(compare_r,errstr):NULL);
1355 compare->referral = NULL;
1357 talloc_free(local_ctx);
1359 return ldapsrv_queue_reply(call, compare_r);
1362 static NTSTATUS ldapsrv_AbandonRequest(struct ldapsrv_call *call)
1364 struct ldap_AbandonRequest *req = &call->request->r.AbandonRequest;
1365 struct ldapsrv_call *c = NULL;
1366 struct ldapsrv_call *n = NULL;
1368 DEBUG(10, ("AbandonRequest\n"));
1370 for (c = call->conn->pending_calls; c != NULL; c = n) {
1373 if (c->request->messageid != req->messageid) {
1377 DLIST_REMOVE(call->conn->pending_calls, c);
1381 return NT_STATUS_OK;
1384 static NTSTATUS ldapsrv_expired(struct ldapsrv_call *call)
1386 struct ldapsrv_reply *reply = NULL;
1387 struct ldap_ExtendedResponse *r = NULL;
1389 DBG_DEBUG("Sending connection expired message\n");
1391 reply = ldapsrv_init_reply(call, LDAP_TAG_ExtendedResponse);
1392 if (reply == NULL) {
1393 return NT_STATUS_NO_MEMORY;
1397 * According to RFC4511 section 4.4.1 this has a msgid of 0
1399 reply->msg->messageid = 0;
1401 r = &reply->msg->r.ExtendedResponse;
1402 r->response.resultcode = LDB_ERR_UNAVAILABLE;
1403 r->response.errormessage = "The server has timed out this connection";
1404 r->oid = "1.3.6.1.4.1.1466.20036"; /* see rfc4511 section 4.4.1 */
1406 ldapsrv_queue_reply(call, reply);
1407 return NT_STATUS_OK;
1410 NTSTATUS ldapsrv_do_call(struct ldapsrv_call *call)
1413 struct ldap_message *msg = call->request;
1414 struct ldapsrv_connection *conn = call->conn;
1418 expired = timeval_expired(&conn->limits.expire_time);
1420 status = ldapsrv_expired(call);
1421 if (!NT_STATUS_IS_OK(status)) {
1424 return NT_STATUS_NETWORK_SESSION_EXPIRED;
1427 /* Check for undecoded critical extensions */
1428 for (i=0; msg->controls && msg->controls[i]; i++) {
1429 if (!msg->controls_decoded[i] &&
1430 msg->controls[i]->critical) {
1431 DEBUG(3, ("ldapsrv_do_call: Critical extension %s is not known to this server\n",
1432 msg->controls[i]->oid));
1433 return ldapsrv_unwilling(call, LDAP_UNAVAILABLE_CRITICAL_EXTENSION);
1437 if (call->conn->authz_logged == false) {
1441 * We do not want to log anonymous access if the query
1442 * is just for the rootDSE, or it is a startTLS or a
1445 * A rootDSE search could also be done over
1446 * CLDAP anonymously for example, so these don't
1448 * Essentially we want to know about
1449 * access beyond that normally done prior to a
1453 switch(call->request->type) {
1454 case LDAP_TAG_BindRequest:
1455 case LDAP_TAG_UnbindRequest:
1456 case LDAP_TAG_AbandonRequest:
1459 case LDAP_TAG_ExtendedResponse: {
1460 struct ldap_ExtendedRequest *req = &call->request->r.ExtendedRequest;
1461 if (strcmp(req->oid, LDB_EXTENDED_START_TLS_OID) == 0) {
1466 case LDAP_TAG_SearchRequest: {
1467 struct ldap_SearchRequest *req = &call->request->r.SearchRequest;
1468 if (req->scope == LDAP_SEARCH_SCOPE_BASE) {
1469 if (req->basedn[0] == '\0') {
1480 const char *transport_protection = AUTHZ_TRANSPORT_PROTECTION_NONE;
1481 if (call->conn->sockets.active == call->conn->sockets.tls) {
1482 transport_protection = AUTHZ_TRANSPORT_PROTECTION_TLS;
1485 log_successful_authz_event(call->conn->connection->msg_ctx,
1486 call->conn->connection->lp_ctx,
1487 call->conn->connection->remote_address,
1488 call->conn->connection->local_address,
1491 transport_protection,
1492 call->conn->session_info);
1494 call->conn->authz_logged = true;
1498 switch(call->request->type) {
1499 case LDAP_TAG_BindRequest:
1500 return ldapsrv_BindRequest(call);
1501 case LDAP_TAG_UnbindRequest:
1502 return ldapsrv_UnbindRequest(call);
1503 case LDAP_TAG_SearchRequest:
1504 return ldapsrv_SearchRequest(call);
1505 case LDAP_TAG_ModifyRequest:
1506 status = ldapsrv_ModifyRequest(call);
1508 case LDAP_TAG_AddRequest:
1509 status = ldapsrv_AddRequest(call);
1511 case LDAP_TAG_DelRequest:
1512 status = ldapsrv_DelRequest(call);
1514 case LDAP_TAG_ModifyDNRequest:
1515 status = ldapsrv_ModifyDNRequest(call);
1517 case LDAP_TAG_CompareRequest:
1518 return ldapsrv_CompareRequest(call);
1519 case LDAP_TAG_AbandonRequest:
1520 return ldapsrv_AbandonRequest(call);
1521 case LDAP_TAG_ExtendedRequest:
1522 status = ldapsrv_ExtendedRequest(call);
1525 return ldapsrv_unwilling(call, LDAP_PROTOCOL_ERROR);
1528 if (NT_STATUS_IS_OK(status)) {
1529 ldapsrv_notification_retry_setup(call->conn->service, true);