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"
37 static int map_ldb_error(TALLOC_CTX *mem_ctx, int ldb_err,
38 const char *add_err_string, const char **errstring)
42 /* Certain LDB modules need to return very special WERROR codes. Proof
43 * for them here and if they exist skip the rest of the mapping. */
44 if (add_err_string != NULL) {
46 strtol(add_err_string, &endptr, 16);
47 if (endptr != add_err_string) {
48 *errstring = add_err_string;
53 /* Otherwise we calculate here a generic, but appropriate WERROR. */
59 case LDB_ERR_OPERATIONS_ERROR:
60 err = WERR_DS_OPERATIONS_ERROR;
62 case LDB_ERR_PROTOCOL_ERROR:
63 err = WERR_DS_PROTOCOL_ERROR;
65 case LDB_ERR_TIME_LIMIT_EXCEEDED:
66 err = WERR_DS_TIMELIMIT_EXCEEDED;
68 case LDB_ERR_SIZE_LIMIT_EXCEEDED:
69 err = WERR_DS_SIZELIMIT_EXCEEDED;
71 case LDB_ERR_COMPARE_FALSE:
72 err = WERR_DS_COMPARE_FALSE;
74 case LDB_ERR_COMPARE_TRUE:
75 err = WERR_DS_COMPARE_TRUE;
77 case LDB_ERR_AUTH_METHOD_NOT_SUPPORTED:
78 err = WERR_DS_AUTH_METHOD_NOT_SUPPORTED;
80 case LDB_ERR_STRONG_AUTH_REQUIRED:
81 err = WERR_DS_STRONG_AUTH_REQUIRED;
83 case LDB_ERR_REFERRAL:
84 err = WERR_DS_REFERRAL;
86 case LDB_ERR_ADMIN_LIMIT_EXCEEDED:
87 err = WERR_DS_ADMIN_LIMIT_EXCEEDED;
89 case LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION:
90 err = WERR_DS_UNAVAILABLE_CRIT_EXTENSION;
92 case LDB_ERR_CONFIDENTIALITY_REQUIRED:
93 err = WERR_DS_CONFIDENTIALITY_REQUIRED;
95 case LDB_ERR_SASL_BIND_IN_PROGRESS:
98 case LDB_ERR_NO_SUCH_ATTRIBUTE:
99 err = WERR_DS_NO_ATTRIBUTE_OR_VALUE;
101 case LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE:
102 err = WERR_DS_ATTRIBUTE_TYPE_UNDEFINED;
104 case LDB_ERR_INAPPROPRIATE_MATCHING:
105 err = WERR_DS_INAPPROPRIATE_MATCHING;
107 case LDB_ERR_CONSTRAINT_VIOLATION:
108 err = WERR_DS_CONSTRAINT_VIOLATION;
110 case LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS:
111 err = WERR_DS_ATTRIBUTE_OR_VALUE_EXISTS;
113 case LDB_ERR_INVALID_ATTRIBUTE_SYNTAX:
114 err = WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
116 case LDB_ERR_NO_SUCH_OBJECT:
117 err = WERR_DS_NO_SUCH_OBJECT;
119 case LDB_ERR_ALIAS_PROBLEM:
120 err = WERR_DS_ALIAS_PROBLEM;
122 case LDB_ERR_INVALID_DN_SYNTAX:
123 err = WERR_DS_INVALID_DN_SYNTAX;
125 case LDB_ERR_ALIAS_DEREFERENCING_PROBLEM:
126 err = WERR_DS_ALIAS_DEREF_PROBLEM;
128 case LDB_ERR_INAPPROPRIATE_AUTHENTICATION:
129 err = WERR_DS_INAPPROPRIATE_AUTH;
131 case LDB_ERR_INVALID_CREDENTIALS:
132 err = WERR_ACCESS_DENIED;
134 case LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS:
135 err = WERR_DS_INSUFF_ACCESS_RIGHTS;
140 case LDB_ERR_UNAVAILABLE:
141 err = WERR_DS_UNAVAILABLE;
143 case LDB_ERR_UNWILLING_TO_PERFORM:
144 err = WERR_DS_UNWILLING_TO_PERFORM;
146 case LDB_ERR_LOOP_DETECT:
147 err = WERR_DS_LOOP_DETECT;
149 case LDB_ERR_NAMING_VIOLATION:
150 err = WERR_DS_NAMING_VIOLATION;
152 case LDB_ERR_OBJECT_CLASS_VIOLATION:
153 err = WERR_DS_OBJ_CLASS_VIOLATION;
155 case LDB_ERR_NOT_ALLOWED_ON_NON_LEAF:
156 err = WERR_DS_CANT_ON_NON_LEAF;
158 case LDB_ERR_NOT_ALLOWED_ON_RDN:
159 err = WERR_DS_CANT_ON_RDN;
161 case LDB_ERR_ENTRY_ALREADY_EXISTS:
162 err = WERR_DS_OBJ_STRING_NAME_EXISTS;
164 case LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED:
165 err = WERR_DS_CANT_MOD_OBJ_CLASS;
167 case LDB_ERR_AFFECTS_MULTIPLE_DSAS:
168 err = WERR_DS_AFFECTS_MULTIPLE_DSAS;
171 err = WERR_DS_GENERIC_ERROR;
175 *errstring = talloc_asprintf(mem_ctx, "%08X: %s", W_ERROR_V(err),
176 add_err_string != NULL ? add_err_string : ldb_strerror(ldb_err));
178 /* result is 1:1 for now */
183 connect to the sam database
185 int ldapsrv_backend_Init(struct ldapsrv_connection *conn,
188 int ret = samdb_connect_url(conn,
189 conn->connection->event.ctx,
192 conn->global_catalog ? LDB_FLG_RDONLY : 0,
194 conn->connection->remote_address,
197 if (ret != LDB_SUCCESS) {
201 if (conn->server_credentials) {
202 char **sasl_mechs = NULL;
203 const struct gensec_security_ops * const *backends = gensec_security_all();
204 const struct gensec_security_ops **ops
205 = gensec_use_kerberos_mechs(conn, backends, conn->server_credentials);
206 unsigned int i, j = 0;
207 for (i = 0; ops && ops[i]; i++) {
208 if (!lpcfg_parm_bool(conn->lp_ctx, NULL, "gensec", ops[i]->name, ops[i]->enabled))
211 if (ops[i]->sasl_name && ops[i]->server_start) {
212 char *sasl_name = talloc_strdup(conn, ops[i]->sasl_name);
215 return LDB_ERR_OPERATIONS_ERROR;
217 sasl_mechs = talloc_realloc(conn, sasl_mechs, char *, j + 2);
219 return LDB_ERR_OPERATIONS_ERROR;
221 sasl_mechs[j] = sasl_name;
222 talloc_steal(sasl_mechs, sasl_name);
223 sasl_mechs[j+1] = NULL;
227 talloc_unlink(conn, ops);
229 /* ldb can have a different lifetime to conn, so we
230 need to ensure that sasl_mechs lives as long as the
232 talloc_steal(conn->ldb, sasl_mechs);
234 ldb_set_opaque(conn->ldb, "supportedSASLMechanisms", sasl_mechs);
240 struct ldapsrv_reply *ldapsrv_init_reply(struct ldapsrv_call *call, uint8_t type)
242 struct ldapsrv_reply *reply;
244 reply = talloc_zero(call, struct ldapsrv_reply);
248 reply->msg = talloc_zero(reply, struct ldap_message);
249 if (reply->msg == NULL) {
254 reply->msg->messageid = call->request->messageid;
255 reply->msg->type = type;
256 reply->msg->controls = NULL;
262 * Encode a reply to an LDAP client as ASN.1, free the original memory
264 static NTSTATUS ldapsrv_encode(TALLOC_CTX *mem_ctx,
265 struct ldapsrv_reply *reply)
267 bool bret = ldap_encode(reply->msg,
268 samba_ldap_control_handlers(),
271 TALLOC_FREE(reply->msg);
273 DEBUG(0,("Failed to encode ldap reply of type %d: "
274 "ldap_encode() failed\n",
276 return NT_STATUS_NO_MEMORY;
279 talloc_set_name_const(reply->blob.data,
280 "Outgoing, encoded single LDAP reply");
286 * Queue a reply (encoding it also), even if it would exceed the
287 * limit. This allows the error packet with LDAP_SIZE_LIMIT_EXCEEDED
290 static NTSTATUS ldapsrv_queue_reply_forced(struct ldapsrv_call *call,
291 struct ldapsrv_reply *reply)
293 NTSTATUS status = ldapsrv_encode(call, reply);
295 if (NT_STATUS_IS_OK(status)) {
296 DLIST_ADD_END(call->replies, reply);
302 * Queue a reply (encoding it also) but check we do not send more than
303 * LDAP_SERVER_MAX_REPLY_SIZE of responses as a way to limit the
304 * amount of data a client can make us allocate.
306 NTSTATUS ldapsrv_queue_reply(struct ldapsrv_call *call, struct ldapsrv_reply *reply)
308 NTSTATUS status = ldapsrv_encode(call, reply);
310 if (!NT_STATUS_IS_OK(status)) {
314 if (call->reply_size > call->reply_size + reply->blob.length
315 || call->reply_size + reply->blob.length > LDAP_SERVER_MAX_REPLY_SIZE) {
316 DBG_WARNING("Refusing to queue LDAP search response size "
317 "of more than %zu bytes\n",
318 LDAP_SERVER_MAX_REPLY_SIZE);
319 TALLOC_FREE(reply->blob.data);
320 return NT_STATUS_FILE_TOO_LARGE;
323 call->reply_size += reply->blob.length;
325 DLIST_ADD_END(call->replies, reply);
330 static NTSTATUS ldapsrv_unwilling(struct ldapsrv_call *call, int error)
332 struct ldapsrv_reply *reply;
333 struct ldap_ExtendedResponse *r;
335 DEBUG(10,("Unwilling type[%d] id[%d]\n", call->request->type, call->request->messageid));
337 reply = ldapsrv_init_reply(call, LDAP_TAG_ExtendedResponse);
339 return NT_STATUS_NO_MEMORY;
342 r = &reply->msg->r.ExtendedResponse;
343 r->response.resultcode = error;
344 r->response.dn = NULL;
345 r->response.errormessage = NULL;
346 r->response.referral = NULL;
350 ldapsrv_queue_reply(call, reply);
354 static int ldapsrv_add_with_controls(struct ldapsrv_call *call,
355 const struct ldb_message *message,
356 struct ldb_control **controls,
357 struct ldb_result *res)
359 struct ldb_context *ldb = call->conn->ldb;
360 struct ldb_request *req;
363 ret = ldb_msg_sanity_check(ldb, message);
364 if (ret != LDB_SUCCESS) {
368 ret = ldb_build_add_req(&req, ldb, ldb,
372 ldb_modify_default_callback,
375 if (ret != LDB_SUCCESS) return ret;
377 if (call->conn->global_catalog) {
378 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port");
380 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);
382 ret = ldb_transaction_start(ldb);
383 if (ret != LDB_SUCCESS) {
387 if (!call->conn->is_privileged) {
388 ldb_req_mark_untrusted(req);
391 LDB_REQ_SET_LOCATION(req);
393 ret = ldb_request(ldb, req);
394 if (ret == LDB_SUCCESS) {
395 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
398 if (ret == LDB_SUCCESS) {
399 ret = ldb_transaction_commit(ldb);
402 ldb_transaction_cancel(ldb);
409 /* create and execute a modify request */
410 static int ldapsrv_mod_with_controls(struct ldapsrv_call *call,
411 const struct ldb_message *message,
412 struct ldb_control **controls,
413 struct ldb_result *res)
415 struct ldb_context *ldb = call->conn->ldb;
416 struct ldb_request *req;
419 ret = ldb_msg_sanity_check(ldb, message);
420 if (ret != LDB_SUCCESS) {
424 ret = ldb_build_mod_req(&req, ldb, ldb,
428 ldb_modify_default_callback,
431 if (ret != LDB_SUCCESS) {
435 if (call->conn->global_catalog) {
436 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port");
438 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);
440 ret = ldb_transaction_start(ldb);
441 if (ret != LDB_SUCCESS) {
445 if (!call->conn->is_privileged) {
446 ldb_req_mark_untrusted(req);
449 LDB_REQ_SET_LOCATION(req);
451 ret = ldb_request(ldb, req);
452 if (ret == LDB_SUCCESS) {
453 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
456 if (ret == LDB_SUCCESS) {
457 ret = ldb_transaction_commit(ldb);
460 ldb_transaction_cancel(ldb);
467 /* create and execute a delete request */
468 static int ldapsrv_del_with_controls(struct ldapsrv_call *call,
470 struct ldb_control **controls,
471 struct ldb_result *res)
473 struct ldb_context *ldb = call->conn->ldb;
474 struct ldb_request *req;
477 ret = ldb_build_del_req(&req, ldb, ldb,
481 ldb_modify_default_callback,
484 if (ret != LDB_SUCCESS) return ret;
486 if (call->conn->global_catalog) {
487 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port");
489 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);
491 ret = ldb_transaction_start(ldb);
492 if (ret != LDB_SUCCESS) {
496 if (!call->conn->is_privileged) {
497 ldb_req_mark_untrusted(req);
500 LDB_REQ_SET_LOCATION(req);
502 ret = ldb_request(ldb, req);
503 if (ret == LDB_SUCCESS) {
504 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
507 if (ret == LDB_SUCCESS) {
508 ret = ldb_transaction_commit(ldb);
511 ldb_transaction_cancel(ldb);
518 static int ldapsrv_rename_with_controls(struct ldapsrv_call *call,
519 struct ldb_dn *olddn,
520 struct ldb_dn *newdn,
521 struct ldb_control **controls,
522 struct ldb_result *res)
524 struct ldb_context *ldb = call->conn->ldb;
525 struct ldb_request *req;
528 ret = ldb_build_rename_req(&req, ldb, ldb,
533 ldb_modify_default_callback,
536 if (ret != LDB_SUCCESS) return ret;
538 if (call->conn->global_catalog) {
539 return ldb_error(ldb, LDB_ERR_UNWILLING_TO_PERFORM, "modify forbidden on global catalog port");
541 ldb_request_add_control(req, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);
543 ret = ldb_transaction_start(ldb);
544 if (ret != LDB_SUCCESS) {
548 if (!call->conn->is_privileged) {
549 ldb_req_mark_untrusted(req);
552 LDB_REQ_SET_LOCATION(req);
554 ret = ldb_request(ldb, req);
555 if (ret == LDB_SUCCESS) {
556 ret = ldb_wait(req->handle, LDB_WAIT_ALL);
559 if (ret == LDB_SUCCESS) {
560 ret = ldb_transaction_commit(ldb);
563 ldb_transaction_cancel(ldb);
572 struct ldapsrv_context {
573 struct ldapsrv_call *call;
576 struct ldb_control **controls;
577 size_t count; /* For notificaiton only */
580 static int ldap_server_search_callback(struct ldb_request *req, struct ldb_reply *ares)
582 struct ldapsrv_context *ctx = talloc_get_type(req->context, struct ldapsrv_context);
583 struct ldapsrv_call *call = ctx->call;
584 struct ldb_context *ldb = call->conn->ldb;
586 struct ldapsrv_reply *ent_r = NULL;
587 struct ldap_SearchResEntry *ent;
592 return ldb_request_done(req, LDB_ERR_OPERATIONS_ERROR);
594 if (ares->error != LDB_SUCCESS) {
595 return ldb_request_done(req, ares->error);
598 switch (ares->type) {
599 case LDB_REPLY_ENTRY:
601 struct ldb_message *msg = ares->message;
602 ent_r = ldapsrv_init_reply(call, LDAP_TAG_SearchResultEntry);
610 * Put the LDAP search response data under ent_r->msg
611 * so we can free that later once encoded
613 talloc_steal(ent_r->msg, msg);
615 ent = &ent_r->msg->r.SearchResultEntry;
616 ent->dn = ldb_dn_get_extended_linearized(ent_r, msg->dn,
618 ent->num_attributes = 0;
619 ent->attributes = NULL;
620 if (msg->num_elements == 0) {
623 ent->num_attributes = msg->num_elements;
624 ent->attributes = talloc_array(ent_r, struct ldb_message_element, ent->num_attributes);
625 if (ent->attributes == NULL) {
629 for (j=0; j < ent->num_attributes; j++) {
630 ent->attributes[j].name = msg->elements[j].name;
631 ent->attributes[j].num_values = 0;
632 ent->attributes[j].values = NULL;
633 if (ctx->attributesonly && (msg->elements[j].num_values == 0)) {
636 ent->attributes[j].num_values = msg->elements[j].num_values;
637 ent->attributes[j].values = msg->elements[j].values;
640 status = ldapsrv_queue_reply(call, ent_r);
641 if (NT_STATUS_EQUAL(status, NT_STATUS_FILE_TOO_LARGE)) {
642 ret = ldb_request_done(req,
643 LDB_ERR_SIZE_LIMIT_EXCEEDED);
644 ldb_asprintf_errstring(ldb,
645 "LDAP search response size "
646 "limited to %zu bytes\n",
647 LDAP_SERVER_MAX_REPLY_SIZE);
648 } else if (!NT_STATUS_IS_OK(status)) {
649 ret = ldb_request_done(req,
656 case LDB_REPLY_REFERRAL:
658 struct ldap_SearchResRef *ent_ref;
661 * TODO: This should be handled by the notification
664 if (call->notification.busy) {
669 ent_r = ldapsrv_init_reply(call, LDAP_TAG_SearchResultReference);
675 * Put the LDAP referral data under ent_r->msg
676 * so we can free that later once encoded
678 talloc_steal(ent_r->msg, ares->referral);
680 ent_ref = &ent_r->msg->r.SearchResultReference;
681 ent_ref->referral = ares->referral;
683 status = ldapsrv_queue_reply(call, ent_r);
684 if (!NT_STATUS_IS_OK(status)) {
685 ret = LDB_ERR_OPERATIONS_ERROR;
694 * We don't queue the reply for this one, we let that
697 ctx->controls = talloc_move(ctx, &ares->controls);
700 return ldb_request_done(req, LDB_SUCCESS);
704 ret = LDB_ERR_OPERATIONS_ERROR;
712 static NTSTATUS ldapsrv_SearchRequest(struct ldapsrv_call *call)
714 struct ldap_SearchRequest *req = &call->request->r.SearchRequest;
715 struct ldap_Result *done;
716 struct ldapsrv_reply *done_r;
717 TALLOC_CTX *local_ctx;
718 struct ldapsrv_context *callback_ctx = NULL;
719 struct ldb_context *samdb = talloc_get_type(call->conn->ldb, struct ldb_context);
720 struct ldb_dn *basedn;
721 struct ldb_request *lreq;
722 struct ldb_control *search_control;
723 struct ldb_search_options_control *search_options;
724 struct ldb_control *extended_dn_control;
725 struct ldb_extended_dn_control *extended_dn_decoded = NULL;
726 struct ldb_control *notification_control = NULL;
727 enum ldb_scope scope = LDB_SCOPE_DEFAULT;
728 const char **attrs = NULL;
729 const char *scope_str, *errstr = NULL;
733 int extended_type = 1;
735 DEBUG(10, ("SearchRequest"));
736 DEBUGADD(10, (" basedn: %s", req->basedn));
737 DEBUGADD(10, (" filter: %s\n", ldb_filter_from_tree(call, req->tree)));
739 local_ctx = talloc_new(call);
740 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
742 basedn = ldb_dn_new(local_ctx, samdb, req->basedn);
743 NT_STATUS_HAVE_NO_MEMORY(basedn);
745 DEBUG(10, ("SearchRequest: basedn: [%s]\n", req->basedn));
746 DEBUG(10, ("SearchRequest: filter: [%s]\n", ldb_filter_from_tree(call, req->tree)));
748 switch (req->scope) {
749 case LDAP_SEARCH_SCOPE_BASE:
751 scope = LDB_SCOPE_BASE;
753 case LDAP_SEARCH_SCOPE_SINGLE:
755 scope = LDB_SCOPE_ONELEVEL;
757 case LDAP_SEARCH_SCOPE_SUB:
759 scope = LDB_SCOPE_SUBTREE;
762 result = LDAP_PROTOCOL_ERROR;
763 map_ldb_error(local_ctx, LDB_ERR_PROTOCOL_ERROR, NULL,
765 errstr = talloc_asprintf(local_ctx,
766 "%s. Invalid scope", errstr);
769 DEBUG(10,("SearchRequest: scope: [%s]\n", scope_str));
771 if (req->num_attributes >= 1) {
772 attrs = talloc_array(local_ctx, const char *, req->num_attributes+1);
773 NT_STATUS_HAVE_NO_MEMORY(attrs);
775 for (i=0; i < req->num_attributes; i++) {
776 DEBUG(10,("SearchRequest: attrs: [%s]\n",req->attributes[i]));
777 attrs[i] = req->attributes[i];
782 DEBUG(5,("ldb_request %s dn=%s filter=%s\n",
783 scope_str, req->basedn, ldb_filter_from_tree(call, req->tree)));
785 callback_ctx = talloc_zero(local_ctx, struct ldapsrv_context);
786 NT_STATUS_HAVE_NO_MEMORY(callback_ctx);
787 callback_ctx->call = call;
788 callback_ctx->extended_type = extended_type;
789 callback_ctx->attributesonly = req->attributesonly;
791 ldb_ret = ldb_build_search_req_ex(&lreq, samdb, local_ctx,
794 call->request->controls,
796 ldap_server_search_callback,
799 if (ldb_ret != LDB_SUCCESS) {
803 if (call->conn->global_catalog) {
804 search_control = ldb_request_get_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID);
806 search_options = NULL;
807 if (search_control) {
808 search_options = talloc_get_type(search_control->data, struct ldb_search_options_control);
809 search_options->search_options |= LDB_SEARCH_OPTION_PHANTOM_ROOT;
811 search_options = talloc(lreq, struct ldb_search_options_control);
812 NT_STATUS_HAVE_NO_MEMORY(search_options);
813 search_options->search_options = LDB_SEARCH_OPTION_PHANTOM_ROOT;
814 ldb_request_add_control(lreq, LDB_CONTROL_SEARCH_OPTIONS_OID, false, search_options);
817 ldb_request_add_control(lreq, DSDB_CONTROL_NO_GLOBAL_CATALOG, false, NULL);
820 extended_dn_control = ldb_request_get_control(lreq, LDB_CONTROL_EXTENDED_DN_OID);
822 if (extended_dn_control) {
823 if (extended_dn_control->data) {
824 extended_dn_decoded = talloc_get_type(extended_dn_control->data, struct ldb_extended_dn_control);
825 extended_type = extended_dn_decoded->type;
829 callback_ctx->extended_type = extended_type;
832 notification_control = ldb_request_get_control(lreq, LDB_CONTROL_NOTIFICATION_OID);
833 if (notification_control != NULL) {
834 const struct ldapsrv_call *pc = NULL;
837 for (pc = call->conn->pending_calls; pc != NULL; pc = pc->next) {
841 if (count >= call->conn->limits.max_notifications) {
842 DEBUG(10,("SearchRequest: error MaxNotificationPerConn\n"));
843 result = map_ldb_error(local_ctx,
844 LDB_ERR_ADMIN_LIMIT_EXCEEDED,
845 "MaxNotificationPerConn reached",
851 * For now we need to do periodic retries on our own.
852 * As the dsdb_notification module will return after each run.
854 call->notification.busy = true;
858 const char *scheme = NULL;
859 switch (call->conn->referral_scheme) {
860 case LDAP_REFERRAL_SCHEME_LDAPS:
866 ldb_ret = ldb_set_opaque(
868 LDAP_REFERRAL_SCHEME_OPAQUE,
869 discard_const_p(char *, scheme));
870 if (ldb_ret != LDB_SUCCESS) {
875 ldb_set_timeout(samdb, lreq, req->timelimit);
877 if (!call->conn->is_privileged) {
878 ldb_req_mark_untrusted(lreq);
881 LDB_REQ_SET_LOCATION(lreq);
883 ldb_ret = ldb_request(samdb, lreq);
885 if (ldb_ret != LDB_SUCCESS) {
889 ldb_ret = ldb_wait(lreq->handle, LDB_WAIT_ALL);
891 if (ldb_ret == LDB_SUCCESS) {
892 if (call->notification.busy) {
893 /* Move/Add it to the end */
894 DLIST_DEMOTE(call->conn->pending_calls, call);
895 call->notification.generation =
896 call->conn->service->notification.generation;
898 if (callback_ctx->count != 0) {
899 call->notification.generation += 1;
900 ldapsrv_notification_retry_setup(call->conn->service,
904 talloc_free(local_ctx);
910 DLIST_REMOVE(call->conn->pending_calls, call);
911 call->notification.busy = false;
913 done_r = ldapsrv_init_reply(call, LDAP_TAG_SearchResultDone);
914 NT_STATUS_HAVE_NO_MEMORY(done_r);
916 done = &done_r->msg->r.SearchResultDone;
918 done->referral = NULL;
921 } else if (ldb_ret == LDB_SUCCESS) {
922 if (callback_ctx->controls) {
923 done_r->msg->controls = callback_ctx->controls;
924 talloc_steal(done_r->msg, callback_ctx->controls);
926 result = LDB_SUCCESS;
928 DEBUG(10,("SearchRequest: error\n"));
929 result = map_ldb_error(local_ctx, ldb_ret, ldb_errstring(samdb),
933 done->resultcode = result;
934 done->errormessage = (errstr?talloc_strdup(done_r, errstr):NULL);
936 talloc_free(local_ctx);
938 return ldapsrv_queue_reply_forced(call, done_r);
941 static NTSTATUS ldapsrv_ModifyRequest(struct ldapsrv_call *call)
943 struct ldap_ModifyRequest *req = &call->request->r.ModifyRequest;
944 struct ldap_Result *modify_result;
945 struct ldapsrv_reply *modify_reply;
946 TALLOC_CTX *local_ctx;
947 struct ldb_context *samdb = call->conn->ldb;
948 struct ldb_message *msg = NULL;
950 const char *errstr = NULL;
951 int result = LDAP_SUCCESS;
954 struct ldb_result *res = NULL;
956 DEBUG(10, ("ModifyRequest"));
957 DEBUGADD(10, (" dn: %s\n", req->dn));
959 local_ctx = talloc_named(call, 0, "ModifyRequest local memory context");
960 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
962 dn = ldb_dn_new(local_ctx, samdb, req->dn);
963 NT_STATUS_HAVE_NO_MEMORY(dn);
965 DEBUG(10, ("ModifyRequest: dn: [%s]\n", req->dn));
967 msg = ldb_msg_new(local_ctx);
968 NT_STATUS_HAVE_NO_MEMORY(msg);
972 if (req->num_mods > 0) {
973 msg->num_elements = req->num_mods;
974 msg->elements = talloc_array(msg, struct ldb_message_element, req->num_mods);
975 NT_STATUS_HAVE_NO_MEMORY(msg->elements);
977 for (i=0; i < msg->num_elements; i++) {
978 msg->elements[i].name = discard_const_p(char, req->mods[i].attrib.name);
979 msg->elements[i].num_values = 0;
980 msg->elements[i].values = NULL;
982 switch (req->mods[i].type) {
984 result = LDAP_PROTOCOL_ERROR;
985 map_ldb_error(local_ctx,
986 LDB_ERR_PROTOCOL_ERROR, NULL, &errstr);
987 errstr = talloc_asprintf(local_ctx,
988 "%s. Invalid LDAP_MODIFY_* type", errstr);
990 case LDAP_MODIFY_ADD:
991 msg->elements[i].flags = LDB_FLAG_MOD_ADD;
993 case LDAP_MODIFY_DELETE:
994 msg->elements[i].flags = LDB_FLAG_MOD_DELETE;
996 case LDAP_MODIFY_REPLACE:
997 msg->elements[i].flags = LDB_FLAG_MOD_REPLACE;
1001 msg->elements[i].num_values = req->mods[i].attrib.num_values;
1002 if (msg->elements[i].num_values > 0) {
1003 msg->elements[i].values = talloc_array(msg->elements, struct ldb_val,
1004 msg->elements[i].num_values);
1005 NT_STATUS_HAVE_NO_MEMORY(msg->elements[i].values);
1007 for (j=0; j < msg->elements[i].num_values; j++) {
1008 msg->elements[i].values[j].length = req->mods[i].attrib.values[j].length;
1009 msg->elements[i].values[j].data = req->mods[i].attrib.values[j].data;
1016 modify_reply = ldapsrv_init_reply(call, LDAP_TAG_ModifyResponse);
1017 NT_STATUS_HAVE_NO_MEMORY(modify_reply);
1019 if (result == LDAP_SUCCESS) {
1020 res = talloc_zero(local_ctx, struct ldb_result);
1021 NT_STATUS_HAVE_NO_MEMORY(res);
1022 ldb_ret = ldapsrv_mod_with_controls(call, msg, call->request->controls, res);
1023 result = map_ldb_error(local_ctx, ldb_ret, ldb_errstring(samdb),
1027 modify_result = &modify_reply->msg->r.ModifyResponse;
1028 modify_result->dn = NULL;
1029 if ((res != NULL) && (res->refs != NULL)) {
1030 modify_result->resultcode = map_ldb_error(local_ctx,
1033 modify_result->errormessage = (errstr?talloc_strdup(modify_reply, errstr):NULL);
1034 modify_result->referral = talloc_strdup(call, *res->refs);
1036 modify_result->resultcode = result;
1037 modify_result->errormessage = (errstr?talloc_strdup(modify_reply, errstr):NULL);
1038 modify_result->referral = NULL;
1040 talloc_free(local_ctx);
1042 return ldapsrv_queue_reply(call, modify_reply);
1046 static NTSTATUS ldapsrv_AddRequest(struct ldapsrv_call *call)
1048 struct ldap_AddRequest *req = &call->request->r.AddRequest;
1049 struct ldap_Result *add_result;
1050 struct ldapsrv_reply *add_reply;
1051 TALLOC_CTX *local_ctx;
1052 struct ldb_context *samdb = call->conn->ldb;
1053 struct ldb_message *msg = NULL;
1055 const char *errstr = NULL;
1056 int result = LDAP_SUCCESS;
1059 struct ldb_result *res = NULL;
1061 DEBUG(10, ("AddRequest"));
1062 DEBUGADD(10, (" dn: %s\n", req->dn));
1064 local_ctx = talloc_named(call, 0, "AddRequest local memory context");
1065 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
1067 dn = ldb_dn_new(local_ctx, samdb, req->dn);
1068 NT_STATUS_HAVE_NO_MEMORY(dn);
1070 DEBUG(10, ("AddRequest: dn: [%s]\n", req->dn));
1072 msg = talloc(local_ctx, struct ldb_message);
1073 NT_STATUS_HAVE_NO_MEMORY(msg);
1076 msg->num_elements = 0;
1077 msg->elements = NULL;
1079 if (req->num_attributes > 0) {
1080 msg->num_elements = req->num_attributes;
1081 msg->elements = talloc_array(msg, struct ldb_message_element, msg->num_elements);
1082 NT_STATUS_HAVE_NO_MEMORY(msg->elements);
1084 for (i=0; i < msg->num_elements; i++) {
1085 msg->elements[i].name = discard_const_p(char, req->attributes[i].name);
1086 msg->elements[i].flags = 0;
1087 msg->elements[i].num_values = 0;
1088 msg->elements[i].values = NULL;
1090 if (req->attributes[i].num_values > 0) {
1091 msg->elements[i].num_values = req->attributes[i].num_values;
1092 msg->elements[i].values = talloc_array(msg->elements, struct ldb_val,
1093 msg->elements[i].num_values);
1094 NT_STATUS_HAVE_NO_MEMORY(msg->elements[i].values);
1096 for (j=0; j < msg->elements[i].num_values; j++) {
1097 msg->elements[i].values[j].length = req->attributes[i].values[j].length;
1098 msg->elements[i].values[j].data = req->attributes[i].values[j].data;
1104 add_reply = ldapsrv_init_reply(call, LDAP_TAG_AddResponse);
1105 NT_STATUS_HAVE_NO_MEMORY(add_reply);
1107 if (result == LDAP_SUCCESS) {
1108 res = talloc_zero(local_ctx, struct ldb_result);
1109 NT_STATUS_HAVE_NO_MEMORY(res);
1110 ldb_ret = ldapsrv_add_with_controls(call, msg, call->request->controls, res);
1111 result = map_ldb_error(local_ctx, ldb_ret, ldb_errstring(samdb),
1115 add_result = &add_reply->msg->r.AddResponse;
1116 add_result->dn = NULL;
1117 if ((res != NULL) && (res->refs != NULL)) {
1118 add_result->resultcode = map_ldb_error(local_ctx,
1119 LDB_ERR_REFERRAL, NULL,
1121 add_result->errormessage = (errstr?talloc_strdup(add_reply,errstr):NULL);
1122 add_result->referral = talloc_strdup(call, *res->refs);
1124 add_result->resultcode = result;
1125 add_result->errormessage = (errstr?talloc_strdup(add_reply,errstr):NULL);
1126 add_result->referral = NULL;
1128 talloc_free(local_ctx);
1130 return ldapsrv_queue_reply(call, add_reply);
1134 static NTSTATUS ldapsrv_DelRequest(struct ldapsrv_call *call)
1136 struct ldap_DelRequest *req = &call->request->r.DelRequest;
1137 struct ldap_Result *del_result;
1138 struct ldapsrv_reply *del_reply;
1139 TALLOC_CTX *local_ctx;
1140 struct ldb_context *samdb = call->conn->ldb;
1142 const char *errstr = NULL;
1143 int result = LDAP_SUCCESS;
1145 struct ldb_result *res = NULL;
1147 DEBUG(10, ("DelRequest"));
1148 DEBUGADD(10, (" dn: %s\n", req->dn));
1150 local_ctx = talloc_named(call, 0, "DelRequest local memory context");
1151 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
1153 dn = ldb_dn_new(local_ctx, samdb, req->dn);
1154 NT_STATUS_HAVE_NO_MEMORY(dn);
1156 DEBUG(10, ("DelRequest: dn: [%s]\n", req->dn));
1158 del_reply = ldapsrv_init_reply(call, LDAP_TAG_DelResponse);
1159 NT_STATUS_HAVE_NO_MEMORY(del_reply);
1161 if (result == LDAP_SUCCESS) {
1162 res = talloc_zero(local_ctx, struct ldb_result);
1163 NT_STATUS_HAVE_NO_MEMORY(res);
1164 ldb_ret = ldapsrv_del_with_controls(call, dn, call->request->controls, res);
1165 result = map_ldb_error(local_ctx, ldb_ret, ldb_errstring(samdb),
1169 del_result = &del_reply->msg->r.DelResponse;
1170 del_result->dn = NULL;
1171 if ((res != NULL) && (res->refs != NULL)) {
1172 del_result->resultcode = map_ldb_error(local_ctx,
1173 LDB_ERR_REFERRAL, NULL,
1175 del_result->errormessage = (errstr?talloc_strdup(del_reply,errstr):NULL);
1176 del_result->referral = talloc_strdup(call, *res->refs);
1178 del_result->resultcode = result;
1179 del_result->errormessage = (errstr?talloc_strdup(del_reply,errstr):NULL);
1180 del_result->referral = NULL;
1183 talloc_free(local_ctx);
1185 return ldapsrv_queue_reply(call, del_reply);
1188 static NTSTATUS ldapsrv_ModifyDNRequest(struct ldapsrv_call *call)
1190 struct ldap_ModifyDNRequest *req = &call->request->r.ModifyDNRequest;
1191 struct ldap_Result *modifydn;
1192 struct ldapsrv_reply *modifydn_r;
1193 TALLOC_CTX *local_ctx;
1194 struct ldb_context *samdb = call->conn->ldb;
1195 struct ldb_dn *olddn, *newdn=NULL, *newrdn;
1196 struct ldb_dn *parentdn = NULL;
1197 const char *errstr = NULL;
1198 int result = LDAP_SUCCESS;
1200 struct ldb_result *res = NULL;
1202 DEBUG(10, ("ModifyDNRequest"));
1203 DEBUGADD(10, (" dn: %s", req->dn));
1204 DEBUGADD(10, (" newrdn: %s\n", req->newrdn));
1206 local_ctx = talloc_named(call, 0, "ModifyDNRequest local memory context");
1207 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
1209 olddn = ldb_dn_new(local_ctx, samdb, req->dn);
1210 NT_STATUS_HAVE_NO_MEMORY(olddn);
1212 newrdn = ldb_dn_new(local_ctx, samdb, req->newrdn);
1213 NT_STATUS_HAVE_NO_MEMORY(newrdn);
1215 DEBUG(10, ("ModifyDNRequest: olddn: [%s]\n", req->dn));
1216 DEBUG(10, ("ModifyDNRequest: newrdn: [%s]\n", req->newrdn));
1218 if (ldb_dn_get_comp_num(newrdn) == 0) {
1219 result = LDAP_PROTOCOL_ERROR;
1220 map_ldb_error(local_ctx, LDB_ERR_PROTOCOL_ERROR, NULL,
1225 if (ldb_dn_get_comp_num(newrdn) > 1) {
1226 result = LDAP_NAMING_VIOLATION;
1227 map_ldb_error(local_ctx, LDB_ERR_NAMING_VIOLATION, NULL,
1232 /* we can't handle the rename if we should not remove the old dn */
1233 if (!req->deleteolddn) {
1234 result = LDAP_UNWILLING_TO_PERFORM;
1235 map_ldb_error(local_ctx, LDB_ERR_UNWILLING_TO_PERFORM, NULL,
1237 errstr = talloc_asprintf(local_ctx,
1238 "%s. Old RDN must be deleted", errstr);
1242 if (req->newsuperior) {
1243 DEBUG(10, ("ModifyDNRequest: newsuperior: [%s]\n", req->newsuperior));
1244 parentdn = ldb_dn_new(local_ctx, samdb, req->newsuperior);
1248 parentdn = ldb_dn_get_parent(local_ctx, olddn);
1251 result = LDAP_NO_SUCH_OBJECT;
1252 map_ldb_error(local_ctx, LDB_ERR_NO_SUCH_OBJECT, NULL, &errstr);
1256 if ( ! ldb_dn_add_child(parentdn, newrdn)) {
1257 result = LDAP_OTHER;
1258 map_ldb_error(local_ctx, LDB_ERR_OTHER, NULL, &errstr);
1264 modifydn_r = ldapsrv_init_reply(call, LDAP_TAG_ModifyDNResponse);
1265 NT_STATUS_HAVE_NO_MEMORY(modifydn_r);
1267 if (result == LDAP_SUCCESS) {
1268 res = talloc_zero(local_ctx, struct ldb_result);
1269 NT_STATUS_HAVE_NO_MEMORY(res);
1270 ldb_ret = ldapsrv_rename_with_controls(call, olddn, newdn, call->request->controls, res);
1271 result = map_ldb_error(local_ctx, ldb_ret, ldb_errstring(samdb),
1275 modifydn = &modifydn_r->msg->r.ModifyDNResponse;
1276 modifydn->dn = NULL;
1277 if ((res != NULL) && (res->refs != NULL)) {
1278 modifydn->resultcode = map_ldb_error(local_ctx,
1279 LDB_ERR_REFERRAL, NULL,
1281 modifydn->errormessage = (errstr?talloc_strdup(modifydn_r,errstr):NULL);
1282 modifydn->referral = talloc_strdup(call, *res->refs);
1284 modifydn->resultcode = result;
1285 modifydn->errormessage = (errstr?talloc_strdup(modifydn_r,errstr):NULL);
1286 modifydn->referral = NULL;
1289 talloc_free(local_ctx);
1291 return ldapsrv_queue_reply(call, modifydn_r);
1294 static NTSTATUS ldapsrv_CompareRequest(struct ldapsrv_call *call)
1296 struct ldap_CompareRequest *req = &call->request->r.CompareRequest;
1297 struct ldap_Result *compare;
1298 struct ldapsrv_reply *compare_r;
1299 TALLOC_CTX *local_ctx;
1300 struct ldb_context *samdb = call->conn->ldb;
1301 struct ldb_result *res = NULL;
1303 const char *attrs[1];
1304 const char *errstr = NULL;
1305 const char *filter = NULL;
1306 int result = LDAP_SUCCESS;
1309 DEBUG(10, ("CompareRequest"));
1310 DEBUGADD(10, (" dn: %s\n", req->dn));
1312 local_ctx = talloc_named(call, 0, "CompareRequest local_memory_context");
1313 NT_STATUS_HAVE_NO_MEMORY(local_ctx);
1315 dn = ldb_dn_new(local_ctx, samdb, req->dn);
1316 NT_STATUS_HAVE_NO_MEMORY(dn);
1318 DEBUG(10, ("CompareRequest: dn: [%s]\n", req->dn));
1319 filter = talloc_asprintf(local_ctx, "(%s=%*s)", req->attribute,
1320 (int)req->value.length, req->value.data);
1321 NT_STATUS_HAVE_NO_MEMORY(filter);
1323 DEBUGADD(10, ("CompareRequest: attribute: [%s]\n", filter));
1327 compare_r = ldapsrv_init_reply(call, LDAP_TAG_CompareResponse);
1328 NT_STATUS_HAVE_NO_MEMORY(compare_r);
1330 if (result == LDAP_SUCCESS) {
1331 ldb_ret = ldb_search(samdb, local_ctx, &res,
1332 dn, LDB_SCOPE_BASE, attrs, "%s", filter);
1333 if (ldb_ret != LDB_SUCCESS) {
1334 result = map_ldb_error(local_ctx, ldb_ret,
1335 ldb_errstring(samdb), &errstr);
1336 DEBUG(10,("CompareRequest: error: %s\n", errstr));
1337 } else if (res->count == 0) {
1338 DEBUG(10,("CompareRequest: doesn't matched\n"));
1339 result = LDAP_COMPARE_FALSE;
1341 } else if (res->count == 1) {
1342 DEBUG(10,("CompareRequest: matched\n"));
1343 result = LDAP_COMPARE_TRUE;
1345 } else if (res->count > 1) {
1346 result = LDAP_OTHER;
1347 map_ldb_error(local_ctx, LDB_ERR_OTHER, NULL, &errstr);
1348 errstr = talloc_asprintf(local_ctx,
1349 "%s. Too many objects match!", errstr);
1350 DEBUG(10,("CompareRequest: %d results: %s\n", res->count, errstr));
1354 compare = &compare_r->msg->r.CompareResponse;
1356 compare->resultcode = result;
1357 compare->errormessage = (errstr?talloc_strdup(compare_r,errstr):NULL);
1358 compare->referral = NULL;
1360 talloc_free(local_ctx);
1362 return ldapsrv_queue_reply(call, compare_r);
1365 static NTSTATUS ldapsrv_AbandonRequest(struct ldapsrv_call *call)
1367 struct ldap_AbandonRequest *req = &call->request->r.AbandonRequest;
1368 struct ldapsrv_call *c = NULL;
1369 struct ldapsrv_call *n = NULL;
1371 DEBUG(10, ("AbandonRequest\n"));
1373 for (c = call->conn->pending_calls; c != NULL; c = n) {
1376 if (c->request->messageid != req->messageid) {
1380 DLIST_REMOVE(call->conn->pending_calls, c);
1384 return NT_STATUS_OK;
1387 NTSTATUS ldapsrv_do_call(struct ldapsrv_call *call)
1390 struct ldap_message *msg = call->request;
1393 /* Check for undecoded critical extensions */
1394 for (i=0; msg->controls && msg->controls[i]; i++) {
1395 if (!msg->controls_decoded[i] &&
1396 msg->controls[i]->critical) {
1397 DEBUG(3, ("ldapsrv_do_call: Critical extension %s is not known to this server\n",
1398 msg->controls[i]->oid));
1399 return ldapsrv_unwilling(call, LDAP_UNAVAILABLE_CRITICAL_EXTENSION);
1403 if (call->conn->authz_logged == false) {
1407 * We do not want to log anonymous access if the query
1408 * is just for the rootDSE, or it is a startTLS or a
1411 * A rootDSE search could also be done over
1412 * CLDAP anonymously for example, so these don't
1414 * Essentially we want to know about
1415 * access beyond that normally done prior to a
1419 switch(call->request->type) {
1420 case LDAP_TAG_BindRequest:
1421 case LDAP_TAG_UnbindRequest:
1422 case LDAP_TAG_AbandonRequest:
1425 case LDAP_TAG_ExtendedResponse: {
1426 struct ldap_ExtendedRequest *req = &call->request->r.ExtendedRequest;
1427 if (strcmp(req->oid, LDB_EXTENDED_START_TLS_OID) == 0) {
1432 case LDAP_TAG_SearchRequest: {
1433 struct ldap_SearchRequest *req = &call->request->r.SearchRequest;
1434 if (req->scope == LDAP_SEARCH_SCOPE_BASE) {
1435 if (req->basedn[0] == '\0') {
1446 const char *transport_protection = AUTHZ_TRANSPORT_PROTECTION_NONE;
1447 if (call->conn->sockets.active == call->conn->sockets.tls) {
1448 transport_protection = AUTHZ_TRANSPORT_PROTECTION_TLS;
1451 log_successful_authz_event(call->conn->connection->msg_ctx,
1452 call->conn->connection->lp_ctx,
1453 call->conn->connection->remote_address,
1454 call->conn->connection->local_address,
1457 transport_protection,
1458 call->conn->session_info);
1460 call->conn->authz_logged = true;
1464 switch(call->request->type) {
1465 case LDAP_TAG_BindRequest:
1466 return ldapsrv_BindRequest(call);
1467 case LDAP_TAG_UnbindRequest:
1468 return ldapsrv_UnbindRequest(call);
1469 case LDAP_TAG_SearchRequest:
1470 return ldapsrv_SearchRequest(call);
1471 case LDAP_TAG_ModifyRequest:
1472 status = ldapsrv_ModifyRequest(call);
1474 case LDAP_TAG_AddRequest:
1475 status = ldapsrv_AddRequest(call);
1477 case LDAP_TAG_DelRequest:
1478 status = ldapsrv_DelRequest(call);
1480 case LDAP_TAG_ModifyDNRequest:
1481 status = ldapsrv_ModifyDNRequest(call);
1483 case LDAP_TAG_CompareRequest:
1484 return ldapsrv_CompareRequest(call);
1485 case LDAP_TAG_AbandonRequest:
1486 return ldapsrv_AbandonRequest(call);
1487 case LDAP_TAG_ExtendedRequest:
1488 status = ldapsrv_ExtendedRequest(call);
1491 return ldapsrv_unwilling(call, LDAP_PROTOCOL_ERROR);
1494 if (NT_STATUS_IS_OK(status)) {
1495 ldapsrv_notification_retry_setup(call->conn->service, true);