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"
36 static int map_ldb_error(TALLOC_CTX
*mem_ctx
, int ldb_err
,
37 const char *add_err_string
, const char **errstring
)
41 /* Certain LDB modules need to return very special WERROR codes. Proof
42 * for them here and if they exist skip the rest of the mapping. */
43 if (add_err_string
!= NULL
) {
45 strtol(add_err_string
, &endptr
, 16);
46 if (endptr
!= add_err_string
) {
47 *errstring
= add_err_string
;
52 /* Otherwise we calculate here a generic, but appropriate WERROR. */
58 case LDB_ERR_OPERATIONS_ERROR
:
59 err
= WERR_DS_OPERATIONS_ERROR
;
61 case LDB_ERR_PROTOCOL_ERROR
:
62 err
= WERR_DS_PROTOCOL_ERROR
;
64 case LDB_ERR_TIME_LIMIT_EXCEEDED
:
65 err
= WERR_DS_TIMELIMIT_EXCEEDED
;
67 case LDB_ERR_SIZE_LIMIT_EXCEEDED
:
68 err
= WERR_DS_SIZELIMIT_EXCEEDED
;
70 case LDB_ERR_COMPARE_FALSE
:
71 err
= WERR_DS_COMPARE_FALSE
;
73 case LDB_ERR_COMPARE_TRUE
:
74 err
= WERR_DS_COMPARE_TRUE
;
76 case LDB_ERR_AUTH_METHOD_NOT_SUPPORTED
:
77 err
= WERR_DS_AUTH_METHOD_NOT_SUPPORTED
;
79 case LDB_ERR_STRONG_AUTH_REQUIRED
:
80 err
= WERR_DS_STRONG_AUTH_REQUIRED
;
82 case LDB_ERR_REFERRAL
:
83 err
= WERR_DS_REFERRAL
;
85 case LDB_ERR_ADMIN_LIMIT_EXCEEDED
:
86 err
= WERR_DS_ADMIN_LIMIT_EXCEEDED
;
88 case LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION
:
89 err
= WERR_DS_UNAVAILABLE_CRIT_EXTENSION
;
91 case LDB_ERR_CONFIDENTIALITY_REQUIRED
:
92 err
= WERR_DS_CONFIDENTIALITY_REQUIRED
;
94 case LDB_ERR_SASL_BIND_IN_PROGRESS
:
97 case LDB_ERR_NO_SUCH_ATTRIBUTE
:
98 err
= WERR_DS_NO_ATTRIBUTE_OR_VALUE
;
100 case LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE
:
101 err
= WERR_DS_ATTRIBUTE_TYPE_UNDEFINED
;
103 case LDB_ERR_INAPPROPRIATE_MATCHING
:
104 err
= WERR_DS_INAPPROPRIATE_MATCHING
;
106 case LDB_ERR_CONSTRAINT_VIOLATION
:
107 err
= WERR_DS_CONSTRAINT_VIOLATION
;
109 case LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS
:
110 err
= WERR_DS_ATTRIBUTE_OR_VALUE_EXISTS
;
112 case LDB_ERR_INVALID_ATTRIBUTE_SYNTAX
:
113 err
= WERR_DS_INVALID_ATTRIBUTE_SYNTAX
;
115 case LDB_ERR_NO_SUCH_OBJECT
:
116 err
= WERR_DS_NO_SUCH_OBJECT
;
118 case LDB_ERR_ALIAS_PROBLEM
:
119 err
= WERR_DS_ALIAS_PROBLEM
;
121 case LDB_ERR_INVALID_DN_SYNTAX
:
122 err
= WERR_DS_INVALID_DN_SYNTAX
;
124 case LDB_ERR_ALIAS_DEREFERENCING_PROBLEM
:
125 err
= WERR_DS_ALIAS_DEREF_PROBLEM
;
127 case LDB_ERR_INAPPROPRIATE_AUTHENTICATION
:
128 err
= WERR_DS_INAPPROPRIATE_AUTH
;
130 case LDB_ERR_INVALID_CREDENTIALS
:
131 err
= WERR_ACCESS_DENIED
;
133 case LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS
:
134 err
= WERR_DS_INSUFF_ACCESS_RIGHTS
;
139 case LDB_ERR_UNAVAILABLE
:
140 err
= WERR_DS_UNAVAILABLE
;
142 case LDB_ERR_UNWILLING_TO_PERFORM
:
143 err
= WERR_DS_UNWILLING_TO_PERFORM
;
145 case LDB_ERR_LOOP_DETECT
:
146 err
= WERR_DS_LOOP_DETECT
;
148 case LDB_ERR_NAMING_VIOLATION
:
149 err
= WERR_DS_NAMING_VIOLATION
;
151 case LDB_ERR_OBJECT_CLASS_VIOLATION
:
152 err
= WERR_DS_OBJ_CLASS_VIOLATION
;
154 case LDB_ERR_NOT_ALLOWED_ON_NON_LEAF
:
155 err
= WERR_DS_CANT_ON_NON_LEAF
;
157 case LDB_ERR_NOT_ALLOWED_ON_RDN
:
158 err
= WERR_DS_CANT_ON_RDN
;
160 case LDB_ERR_ENTRY_ALREADY_EXISTS
:
161 err
= WERR_DS_OBJ_STRING_NAME_EXISTS
;
163 case LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED
:
164 err
= WERR_DS_CANT_MOD_OBJ_CLASS
;
166 case LDB_ERR_AFFECTS_MULTIPLE_DSAS
:
167 err
= WERR_DS_AFFECTS_MULTIPLE_DSAS
;
170 err
= WERR_DS_GENERIC_ERROR
;
174 *errstring
= talloc_asprintf(mem_ctx
, "%08X: %s", W_ERROR_V(err
),
175 add_err_string
!= NULL
? add_err_string
: ldb_strerror(ldb_err
));
177 /* result is 1:1 for now */
182 connect to the sam database
184 int ldapsrv_backend_Init(struct ldapsrv_connection
*conn
,
187 int ret
= samdb_connect_url(conn
,
188 conn
->connection
->event
.ctx
,
191 conn
->global_catalog
? LDB_FLG_RDONLY
: 0,
193 conn
->connection
->remote_address
,
196 if (ret
!= LDB_SUCCESS
) {
200 if (conn
->server_credentials
) {
201 char **sasl_mechs
= NULL
;
202 const struct gensec_security_ops
* const *backends
= gensec_security_all();
203 const struct gensec_security_ops
**ops
204 = gensec_use_kerberos_mechs(conn
, backends
, conn
->server_credentials
);
205 unsigned int i
, j
= 0;
206 for (i
= 0; ops
&& ops
[i
]; i
++) {
207 if (!lpcfg_parm_bool(conn
->lp_ctx
, NULL
, "gensec", ops
[i
]->name
, ops
[i
]->enabled
))
210 if (ops
[i
]->sasl_name
&& ops
[i
]->server_start
) {
211 char *sasl_name
= talloc_strdup(conn
, ops
[i
]->sasl_name
);
214 return LDB_ERR_OPERATIONS_ERROR
;
216 sasl_mechs
= talloc_realloc(conn
, sasl_mechs
, char *, j
+ 2);
218 return LDB_ERR_OPERATIONS_ERROR
;
220 sasl_mechs
[j
] = sasl_name
;
221 talloc_steal(sasl_mechs
, sasl_name
);
222 sasl_mechs
[j
+1] = NULL
;
226 talloc_unlink(conn
, ops
);
228 /* ldb can have a different lifetime to conn, so we
229 need to ensure that sasl_mechs lives as long as the
231 talloc_steal(conn
->ldb
, sasl_mechs
);
233 ldb_set_opaque(conn
->ldb
, "supportedSASLMechanisms", sasl_mechs
);
239 struct ldapsrv_reply
*ldapsrv_init_reply(struct ldapsrv_call
*call
, uint8_t type
)
241 struct ldapsrv_reply
*reply
;
243 reply
= talloc_zero(call
, struct ldapsrv_reply
);
247 reply
->msg
= talloc_zero(reply
, struct ldap_message
);
248 if (reply
->msg
== NULL
) {
253 reply
->msg
->messageid
= call
->request
->messageid
;
254 reply
->msg
->type
= type
;
255 reply
->msg
->controls
= NULL
;
260 void ldapsrv_queue_reply(struct ldapsrv_call
*call
, struct ldapsrv_reply
*reply
)
262 DLIST_ADD_END(call
->replies
, reply
);
265 static NTSTATUS
ldapsrv_unwilling(struct ldapsrv_call
*call
, int error
)
267 struct ldapsrv_reply
*reply
;
268 struct ldap_ExtendedResponse
*r
;
270 DEBUG(10,("Unwilling type[%d] id[%d]\n", call
->request
->type
, call
->request
->messageid
));
272 reply
= ldapsrv_init_reply(call
, LDAP_TAG_ExtendedResponse
);
274 return NT_STATUS_NO_MEMORY
;
277 r
= &reply
->msg
->r
.ExtendedResponse
;
278 r
->response
.resultcode
= error
;
279 r
->response
.dn
= NULL
;
280 r
->response
.errormessage
= NULL
;
281 r
->response
.referral
= NULL
;
285 ldapsrv_queue_reply(call
, reply
);
289 static int ldapsrv_add_with_controls(struct ldapsrv_call
*call
,
290 const struct ldb_message
*message
,
291 struct ldb_control
**controls
,
292 struct ldb_result
*res
)
294 struct ldb_context
*ldb
= call
->conn
->ldb
;
295 struct ldb_request
*req
;
298 ret
= ldb_msg_sanity_check(ldb
, message
);
299 if (ret
!= LDB_SUCCESS
) {
303 ret
= ldb_build_add_req(&req
, ldb
, ldb
,
307 ldb_modify_default_callback
,
310 if (ret
!= LDB_SUCCESS
) return ret
;
312 if (call
->conn
->global_catalog
) {
313 return ldb_error(ldb
, LDB_ERR_UNWILLING_TO_PERFORM
, "modify forbidden on global catalog port");
315 ldb_request_add_control(req
, DSDB_CONTROL_NO_GLOBAL_CATALOG
, false, NULL
);
317 ret
= ldb_transaction_start(ldb
);
318 if (ret
!= LDB_SUCCESS
) {
322 if (!call
->conn
->is_privileged
) {
323 ldb_req_mark_untrusted(req
);
326 LDB_REQ_SET_LOCATION(req
);
328 ret
= ldb_request(ldb
, req
);
329 if (ret
== LDB_SUCCESS
) {
330 ret
= ldb_wait(req
->handle
, LDB_WAIT_ALL
);
333 if (ret
== LDB_SUCCESS
) {
334 ret
= ldb_transaction_commit(ldb
);
337 ldb_transaction_cancel(ldb
);
344 /* create and execute a modify request */
345 static int ldapsrv_mod_with_controls(struct ldapsrv_call
*call
,
346 const struct ldb_message
*message
,
347 struct ldb_control
**controls
,
348 struct ldb_result
*res
)
350 struct ldb_context
*ldb
= call
->conn
->ldb
;
351 struct ldb_request
*req
;
354 ret
= ldb_msg_sanity_check(ldb
, message
);
355 if (ret
!= LDB_SUCCESS
) {
359 ret
= ldb_build_mod_req(&req
, ldb
, ldb
,
363 ldb_modify_default_callback
,
366 if (ret
!= LDB_SUCCESS
) {
370 if (call
->conn
->global_catalog
) {
371 return ldb_error(ldb
, LDB_ERR_UNWILLING_TO_PERFORM
, "modify forbidden on global catalog port");
373 ldb_request_add_control(req
, DSDB_CONTROL_NO_GLOBAL_CATALOG
, false, NULL
);
375 ret
= ldb_transaction_start(ldb
);
376 if (ret
!= LDB_SUCCESS
) {
380 if (!call
->conn
->is_privileged
) {
381 ldb_req_mark_untrusted(req
);
384 LDB_REQ_SET_LOCATION(req
);
386 ret
= ldb_request(ldb
, req
);
387 if (ret
== LDB_SUCCESS
) {
388 ret
= ldb_wait(req
->handle
, LDB_WAIT_ALL
);
391 if (ret
== LDB_SUCCESS
) {
392 ret
= ldb_transaction_commit(ldb
);
395 ldb_transaction_cancel(ldb
);
402 /* create and execute a delete request */
403 static int ldapsrv_del_with_controls(struct ldapsrv_call
*call
,
405 struct ldb_control
**controls
,
406 struct ldb_result
*res
)
408 struct ldb_context
*ldb
= call
->conn
->ldb
;
409 struct ldb_request
*req
;
412 ret
= ldb_build_del_req(&req
, ldb
, ldb
,
416 ldb_modify_default_callback
,
419 if (ret
!= LDB_SUCCESS
) return ret
;
421 if (call
->conn
->global_catalog
) {
422 return ldb_error(ldb
, LDB_ERR_UNWILLING_TO_PERFORM
, "modify forbidden on global catalog port");
424 ldb_request_add_control(req
, DSDB_CONTROL_NO_GLOBAL_CATALOG
, false, NULL
);
426 ret
= ldb_transaction_start(ldb
);
427 if (ret
!= LDB_SUCCESS
) {
431 if (!call
->conn
->is_privileged
) {
432 ldb_req_mark_untrusted(req
);
435 LDB_REQ_SET_LOCATION(req
);
437 ret
= ldb_request(ldb
, req
);
438 if (ret
== LDB_SUCCESS
) {
439 ret
= ldb_wait(req
->handle
, LDB_WAIT_ALL
);
442 if (ret
== LDB_SUCCESS
) {
443 ret
= ldb_transaction_commit(ldb
);
446 ldb_transaction_cancel(ldb
);
453 static int ldapsrv_rename_with_controls(struct ldapsrv_call
*call
,
454 struct ldb_dn
*olddn
,
455 struct ldb_dn
*newdn
,
456 struct ldb_control
**controls
,
457 struct ldb_result
*res
)
459 struct ldb_context
*ldb
= call
->conn
->ldb
;
460 struct ldb_request
*req
;
463 ret
= ldb_build_rename_req(&req
, ldb
, ldb
,
468 ldb_modify_default_callback
,
471 if (ret
!= LDB_SUCCESS
) return ret
;
473 if (call
->conn
->global_catalog
) {
474 return ldb_error(ldb
, LDB_ERR_UNWILLING_TO_PERFORM
, "modify forbidden on global catalog port");
476 ldb_request_add_control(req
, DSDB_CONTROL_NO_GLOBAL_CATALOG
, false, NULL
);
478 ret
= ldb_transaction_start(ldb
);
479 if (ret
!= LDB_SUCCESS
) {
483 if (!call
->conn
->is_privileged
) {
484 ldb_req_mark_untrusted(req
);
487 LDB_REQ_SET_LOCATION(req
);
489 ret
= ldb_request(ldb
, req
);
490 if (ret
== LDB_SUCCESS
) {
491 ret
= ldb_wait(req
->handle
, LDB_WAIT_ALL
);
494 if (ret
== LDB_SUCCESS
) {
495 ret
= ldb_transaction_commit(ldb
);
498 ldb_transaction_cancel(ldb
);
505 static NTSTATUS
ldapsrv_SearchRequest(struct ldapsrv_call
*call
)
507 struct ldap_SearchRequest
*req
= &call
->request
->r
.SearchRequest
;
508 struct ldap_SearchResEntry
*ent
;
509 struct ldap_Result
*done
;
510 struct ldapsrv_reply
*ent_r
, *done_r
;
511 TALLOC_CTX
*local_ctx
;
512 struct ldb_context
*samdb
= talloc_get_type(call
->conn
->ldb
, struct ldb_context
);
513 struct ldb_dn
*basedn
;
514 struct ldb_result
*res
= NULL
;
515 struct ldb_request
*lreq
;
516 struct ldb_control
*search_control
;
517 struct ldb_search_options_control
*search_options
;
518 struct ldb_control
*extended_dn_control
;
519 struct ldb_extended_dn_control
*extended_dn_decoded
= NULL
;
520 struct ldb_control
*notification_control
= NULL
;
521 enum ldb_scope scope
= LDB_SCOPE_DEFAULT
;
522 const char **attrs
= NULL
;
523 const char *scope_str
, *errstr
= NULL
;
524 int success_limit
= 1;
528 int extended_type
= 1;
530 DEBUG(10, ("SearchRequest"));
531 DEBUGADD(10, (" basedn: %s", req
->basedn
));
532 DEBUGADD(10, (" filter: %s\n", ldb_filter_from_tree(call
, req
->tree
)));
534 local_ctx
= talloc_new(call
);
535 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
537 basedn
= ldb_dn_new(local_ctx
, samdb
, req
->basedn
);
538 NT_STATUS_HAVE_NO_MEMORY(basedn
);
540 DEBUG(10, ("SearchRequest: basedn: [%s]\n", req
->basedn
));
541 DEBUG(10, ("SearchRequest: filter: [%s]\n", ldb_filter_from_tree(call
, req
->tree
)));
543 switch (req
->scope
) {
544 case LDAP_SEARCH_SCOPE_BASE
:
546 scope
= LDB_SCOPE_BASE
;
549 case LDAP_SEARCH_SCOPE_SINGLE
:
551 scope
= LDB_SCOPE_ONELEVEL
;
554 case LDAP_SEARCH_SCOPE_SUB
:
556 scope
= LDB_SCOPE_SUBTREE
;
560 result
= LDAP_PROTOCOL_ERROR
;
561 map_ldb_error(local_ctx
, LDB_ERR_PROTOCOL_ERROR
, NULL
,
563 errstr
= talloc_asprintf(local_ctx
,
564 "%s. Invalid scope", errstr
);
567 DEBUG(10,("SearchRequest: scope: [%s]\n", scope_str
));
569 if (req
->num_attributes
>= 1) {
570 attrs
= talloc_array(local_ctx
, const char *, req
->num_attributes
+1);
571 NT_STATUS_HAVE_NO_MEMORY(attrs
);
573 for (i
=0; i
< req
->num_attributes
; i
++) {
574 DEBUG(10,("SearchRequest: attrs: [%s]\n",req
->attributes
[i
]));
575 attrs
[i
] = req
->attributes
[i
];
580 DEBUG(5,("ldb_request %s dn=%s filter=%s\n",
581 scope_str
, req
->basedn
, ldb_filter_from_tree(call
, req
->tree
)));
583 res
= talloc_zero(local_ctx
, struct ldb_result
);
584 NT_STATUS_HAVE_NO_MEMORY(res
);
586 ldb_ret
= ldb_build_search_req_ex(&lreq
, samdb
, local_ctx
,
589 call
->request
->controls
,
590 res
, ldb_search_default_callback
,
593 if (ldb_ret
!= LDB_SUCCESS
) {
597 if (call
->conn
->global_catalog
) {
598 search_control
= ldb_request_get_control(lreq
, LDB_CONTROL_SEARCH_OPTIONS_OID
);
600 search_options
= NULL
;
601 if (search_control
) {
602 search_options
= talloc_get_type(search_control
->data
, struct ldb_search_options_control
);
603 search_options
->search_options
|= LDB_SEARCH_OPTION_PHANTOM_ROOT
;
605 search_options
= talloc(lreq
, struct ldb_search_options_control
);
606 NT_STATUS_HAVE_NO_MEMORY(search_options
);
607 search_options
->search_options
= LDB_SEARCH_OPTION_PHANTOM_ROOT
;
608 ldb_request_add_control(lreq
, LDB_CONTROL_SEARCH_OPTIONS_OID
, false, search_options
);
611 ldb_request_add_control(lreq
, DSDB_CONTROL_NO_GLOBAL_CATALOG
, false, NULL
);
614 extended_dn_control
= ldb_request_get_control(lreq
, LDB_CONTROL_EXTENDED_DN_OID
);
616 if (extended_dn_control
) {
617 if (extended_dn_control
->data
) {
618 extended_dn_decoded
= talloc_get_type(extended_dn_control
->data
, struct ldb_extended_dn_control
);
619 extended_type
= extended_dn_decoded
->type
;
625 notification_control
= ldb_request_get_control(lreq
, LDB_CONTROL_NOTIFICATION_OID
);
626 if (notification_control
!= NULL
) {
627 const struct ldapsrv_call
*pc
= NULL
;
630 for (pc
= call
->conn
->pending_calls
; pc
!= NULL
; pc
= pc
->next
) {
634 if (count
>= call
->conn
->limits
.max_notifications
) {
635 DEBUG(10,("SearchRequest: error MaxNotificationPerConn\n"));
636 result
= map_ldb_error(local_ctx
,
637 LDB_ERR_ADMIN_LIMIT_EXCEEDED
,
638 "MaxNotificationPerConn reached",
644 * For now we need to do periodic retries on our own.
645 * As the dsdb_notification module will return after each run.
647 call
->notification
.busy
= true;
650 ldb_set_timeout(samdb
, lreq
, req
->timelimit
);
652 if (!call
->conn
->is_privileged
) {
653 ldb_req_mark_untrusted(lreq
);
656 LDB_REQ_SET_LOCATION(lreq
);
658 ldb_ret
= ldb_request(samdb
, lreq
);
660 if (ldb_ret
!= LDB_SUCCESS
) {
664 ldb_ret
= ldb_wait(lreq
->handle
, LDB_WAIT_ALL
);
666 if (ldb_ret
== LDB_SUCCESS
) {
667 for (i
= 0; i
< res
->count
; i
++) {
668 ent_r
= ldapsrv_init_reply(call
, LDAP_TAG_SearchResultEntry
);
669 NT_STATUS_HAVE_NO_MEMORY(ent_r
);
671 /* Better to have the whole message kept here,
672 * than to find someone further up didn't put
673 * a value in the right spot in the talloc tree */
674 talloc_steal(ent_r
, res
->msgs
[i
]);
676 ent
= &ent_r
->msg
->r
.SearchResultEntry
;
677 ent
->dn
= ldb_dn_get_extended_linearized(ent_r
, res
->msgs
[i
]->dn
, extended_type
);
678 ent
->num_attributes
= 0;
679 ent
->attributes
= NULL
;
680 if (res
->msgs
[i
]->num_elements
== 0) {
683 ent
->num_attributes
= res
->msgs
[i
]->num_elements
;
684 ent
->attributes
= talloc_array(ent_r
, struct ldb_message_element
, ent
->num_attributes
);
685 NT_STATUS_HAVE_NO_MEMORY(ent
->attributes
);
686 for (j
=0; j
< ent
->num_attributes
; j
++) {
687 ent
->attributes
[j
].name
= res
->msgs
[i
]->elements
[j
].name
;
688 ent
->attributes
[j
].num_values
= 0;
689 ent
->attributes
[j
].values
= NULL
;
690 if (req
->attributesonly
&& (res
->msgs
[i
]->elements
[j
].num_values
== 0)) {
693 ent
->attributes
[j
].num_values
= res
->msgs
[i
]->elements
[j
].num_values
;
694 ent
->attributes
[j
].values
= res
->msgs
[i
]->elements
[j
].values
;
697 ldapsrv_queue_reply(call
, ent_r
);
700 if (call
->notification
.busy
) {
701 /* Move/Add it to the end */
702 DLIST_DEMOTE(call
->conn
->pending_calls
, call
);
703 call
->notification
.generation
=
704 call
->conn
->service
->notification
.generation
;
706 if (res
->count
!= 0) {
707 call
->notification
.generation
+= 1;
708 ldapsrv_notification_retry_setup(call
->conn
->service
,
712 talloc_free(local_ctx
);
716 /* Send back referrals if they do exist (search operations) */
717 if (res
->refs
!= NULL
) {
719 struct ldap_SearchResRef
*ent_ref
;
721 for (ref
= res
->refs
; *ref
!= NULL
; ++ref
) {
722 ent_r
= ldapsrv_init_reply(call
, LDAP_TAG_SearchResultReference
);
723 NT_STATUS_HAVE_NO_MEMORY(ent_r
);
725 /* Better to have the whole referrals kept here,
726 * than to find someone further up didn't put
727 * a value in the right spot in the talloc tree
729 talloc_steal(ent_r
, *ref
);
731 ent_ref
= &ent_r
->msg
->r
.SearchResultReference
;
732 ent_ref
->referral
= *ref
;
734 ldapsrv_queue_reply(call
, ent_r
);
740 DLIST_REMOVE(call
->conn
->pending_calls
, call
);
741 call
->notification
.busy
= false;
743 done_r
= ldapsrv_init_reply(call
, LDAP_TAG_SearchResultDone
);
744 NT_STATUS_HAVE_NO_MEMORY(done_r
);
746 done
= &done_r
->msg
->r
.SearchResultDone
;
748 done
->referral
= NULL
;
751 } else if (ldb_ret
== LDB_SUCCESS
) {
752 if (res
->count
>= success_limit
) {
753 DEBUG(10,("SearchRequest: results: [%d]\n", res
->count
));
754 result
= LDAP_SUCCESS
;
758 done_r
->msg
->controls
= res
->controls
;
759 talloc_steal(done_r
, res
->controls
);
762 DEBUG(10,("SearchRequest: error\n"));
763 result
= map_ldb_error(local_ctx
, ldb_ret
, ldb_errstring(samdb
),
767 done
->resultcode
= result
;
768 done
->errormessage
= (errstr
?talloc_strdup(done_r
, errstr
):NULL
);
770 talloc_free(local_ctx
);
772 ldapsrv_queue_reply(call
, done_r
);
776 static NTSTATUS
ldapsrv_ModifyRequest(struct ldapsrv_call
*call
)
778 struct ldap_ModifyRequest
*req
= &call
->request
->r
.ModifyRequest
;
779 struct ldap_Result
*modify_result
;
780 struct ldapsrv_reply
*modify_reply
;
781 TALLOC_CTX
*local_ctx
;
782 struct ldb_context
*samdb
= call
->conn
->ldb
;
783 struct ldb_message
*msg
= NULL
;
785 const char *errstr
= NULL
;
786 int result
= LDAP_SUCCESS
;
789 struct ldb_result
*res
= NULL
;
791 DEBUG(10, ("ModifyRequest"));
792 DEBUGADD(10, (" dn: %s\n", req
->dn
));
794 local_ctx
= talloc_named(call
, 0, "ModifyRequest local memory context");
795 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
797 dn
= ldb_dn_new(local_ctx
, samdb
, req
->dn
);
798 NT_STATUS_HAVE_NO_MEMORY(dn
);
800 DEBUG(10, ("ModifyRequest: dn: [%s]\n", req
->dn
));
802 msg
= talloc(local_ctx
, struct ldb_message
);
803 NT_STATUS_HAVE_NO_MEMORY(msg
);
806 msg
->num_elements
= 0;
807 msg
->elements
= NULL
;
809 if (req
->num_mods
> 0) {
810 msg
->num_elements
= req
->num_mods
;
811 msg
->elements
= talloc_array(msg
, struct ldb_message_element
, req
->num_mods
);
812 NT_STATUS_HAVE_NO_MEMORY(msg
->elements
);
814 for (i
=0; i
< msg
->num_elements
; i
++) {
815 msg
->elements
[i
].name
= discard_const_p(char, req
->mods
[i
].attrib
.name
);
816 msg
->elements
[i
].num_values
= 0;
817 msg
->elements
[i
].values
= NULL
;
819 switch (req
->mods
[i
].type
) {
821 result
= LDAP_PROTOCOL_ERROR
;
822 map_ldb_error(local_ctx
,
823 LDB_ERR_PROTOCOL_ERROR
, NULL
, &errstr
);
824 errstr
= talloc_asprintf(local_ctx
,
825 "%s. Invalid LDAP_MODIFY_* type", errstr
);
827 case LDAP_MODIFY_ADD
:
828 msg
->elements
[i
].flags
= LDB_FLAG_MOD_ADD
;
830 case LDAP_MODIFY_DELETE
:
831 msg
->elements
[i
].flags
= LDB_FLAG_MOD_DELETE
;
833 case LDAP_MODIFY_REPLACE
:
834 msg
->elements
[i
].flags
= LDB_FLAG_MOD_REPLACE
;
838 msg
->elements
[i
].num_values
= req
->mods
[i
].attrib
.num_values
;
839 if (msg
->elements
[i
].num_values
> 0) {
840 msg
->elements
[i
].values
= talloc_array(msg
->elements
, struct ldb_val
,
841 msg
->elements
[i
].num_values
);
842 NT_STATUS_HAVE_NO_MEMORY(msg
->elements
[i
].values
);
844 for (j
=0; j
< msg
->elements
[i
].num_values
; j
++) {
845 msg
->elements
[i
].values
[j
].length
= req
->mods
[i
].attrib
.values
[j
].length
;
846 msg
->elements
[i
].values
[j
].data
= req
->mods
[i
].attrib
.values
[j
].data
;
853 modify_reply
= ldapsrv_init_reply(call
, LDAP_TAG_ModifyResponse
);
854 NT_STATUS_HAVE_NO_MEMORY(modify_reply
);
856 if (result
== LDAP_SUCCESS
) {
857 res
= talloc_zero(local_ctx
, struct ldb_result
);
858 NT_STATUS_HAVE_NO_MEMORY(res
);
859 ldb_ret
= ldapsrv_mod_with_controls(call
, msg
, call
->request
->controls
, res
);
860 result
= map_ldb_error(local_ctx
, ldb_ret
, ldb_errstring(samdb
),
864 modify_result
= &modify_reply
->msg
->r
.ModifyResponse
;
865 modify_result
->dn
= NULL
;
866 if ((res
!= NULL
) && (res
->refs
!= NULL
)) {
867 modify_result
->resultcode
= map_ldb_error(local_ctx
,
870 modify_result
->errormessage
= (errstr
?talloc_strdup(modify_reply
, errstr
):NULL
);
871 modify_result
->referral
= talloc_strdup(call
, *res
->refs
);
873 modify_result
->resultcode
= result
;
874 modify_result
->errormessage
= (errstr
?talloc_strdup(modify_reply
, errstr
):NULL
);
875 modify_result
->referral
= NULL
;
877 talloc_free(local_ctx
);
879 ldapsrv_queue_reply(call
, modify_reply
);
884 static NTSTATUS
ldapsrv_AddRequest(struct ldapsrv_call
*call
)
886 struct ldap_AddRequest
*req
= &call
->request
->r
.AddRequest
;
887 struct ldap_Result
*add_result
;
888 struct ldapsrv_reply
*add_reply
;
889 TALLOC_CTX
*local_ctx
;
890 struct ldb_context
*samdb
= call
->conn
->ldb
;
891 struct ldb_message
*msg
= NULL
;
893 const char *errstr
= NULL
;
894 int result
= LDAP_SUCCESS
;
897 struct ldb_result
*res
= NULL
;
899 DEBUG(10, ("AddRequest"));
900 DEBUGADD(10, (" dn: %s\n", req
->dn
));
902 local_ctx
= talloc_named(call
, 0, "AddRequest local memory context");
903 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
905 dn
= ldb_dn_new(local_ctx
, samdb
, req
->dn
);
906 NT_STATUS_HAVE_NO_MEMORY(dn
);
908 DEBUG(10, ("AddRequest: dn: [%s]\n", req
->dn
));
910 msg
= talloc(local_ctx
, struct ldb_message
);
911 NT_STATUS_HAVE_NO_MEMORY(msg
);
914 msg
->num_elements
= 0;
915 msg
->elements
= NULL
;
917 if (req
->num_attributes
> 0) {
918 msg
->num_elements
= req
->num_attributes
;
919 msg
->elements
= talloc_array(msg
, struct ldb_message_element
, msg
->num_elements
);
920 NT_STATUS_HAVE_NO_MEMORY(msg
->elements
);
922 for (i
=0; i
< msg
->num_elements
; i
++) {
923 msg
->elements
[i
].name
= discard_const_p(char, req
->attributes
[i
].name
);
924 msg
->elements
[i
].flags
= 0;
925 msg
->elements
[i
].num_values
= 0;
926 msg
->elements
[i
].values
= NULL
;
928 if (req
->attributes
[i
].num_values
> 0) {
929 msg
->elements
[i
].num_values
= req
->attributes
[i
].num_values
;
930 msg
->elements
[i
].values
= talloc_array(msg
->elements
, struct ldb_val
,
931 msg
->elements
[i
].num_values
);
932 NT_STATUS_HAVE_NO_MEMORY(msg
->elements
[i
].values
);
934 for (j
=0; j
< msg
->elements
[i
].num_values
; j
++) {
935 msg
->elements
[i
].values
[j
].length
= req
->attributes
[i
].values
[j
].length
;
936 msg
->elements
[i
].values
[j
].data
= req
->attributes
[i
].values
[j
].data
;
942 add_reply
= ldapsrv_init_reply(call
, LDAP_TAG_AddResponse
);
943 NT_STATUS_HAVE_NO_MEMORY(add_reply
);
945 if (result
== LDAP_SUCCESS
) {
946 res
= talloc_zero(local_ctx
, struct ldb_result
);
947 NT_STATUS_HAVE_NO_MEMORY(res
);
948 ldb_ret
= ldapsrv_add_with_controls(call
, msg
, call
->request
->controls
, res
);
949 result
= map_ldb_error(local_ctx
, ldb_ret
, ldb_errstring(samdb
),
953 add_result
= &add_reply
->msg
->r
.AddResponse
;
954 add_result
->dn
= NULL
;
955 if ((res
!= NULL
) && (res
->refs
!= NULL
)) {
956 add_result
->resultcode
= map_ldb_error(local_ctx
,
957 LDB_ERR_REFERRAL
, NULL
,
959 add_result
->errormessage
= (errstr
?talloc_strdup(add_reply
,errstr
):NULL
);
960 add_result
->referral
= talloc_strdup(call
, *res
->refs
);
962 add_result
->resultcode
= result
;
963 add_result
->errormessage
= (errstr
?talloc_strdup(add_reply
,errstr
):NULL
);
964 add_result
->referral
= NULL
;
966 talloc_free(local_ctx
);
968 ldapsrv_queue_reply(call
, add_reply
);
973 static NTSTATUS
ldapsrv_DelRequest(struct ldapsrv_call
*call
)
975 struct ldap_DelRequest
*req
= &call
->request
->r
.DelRequest
;
976 struct ldap_Result
*del_result
;
977 struct ldapsrv_reply
*del_reply
;
978 TALLOC_CTX
*local_ctx
;
979 struct ldb_context
*samdb
= call
->conn
->ldb
;
981 const char *errstr
= NULL
;
982 int result
= LDAP_SUCCESS
;
984 struct ldb_result
*res
= NULL
;
986 DEBUG(10, ("DelRequest"));
987 DEBUGADD(10, (" dn: %s\n", req
->dn
));
989 local_ctx
= talloc_named(call
, 0, "DelRequest local memory context");
990 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
992 dn
= ldb_dn_new(local_ctx
, samdb
, req
->dn
);
993 NT_STATUS_HAVE_NO_MEMORY(dn
);
995 DEBUG(10, ("DelRequest: dn: [%s]\n", req
->dn
));
997 del_reply
= ldapsrv_init_reply(call
, LDAP_TAG_DelResponse
);
998 NT_STATUS_HAVE_NO_MEMORY(del_reply
);
1000 if (result
== LDAP_SUCCESS
) {
1001 res
= talloc_zero(local_ctx
, struct ldb_result
);
1002 NT_STATUS_HAVE_NO_MEMORY(res
);
1003 ldb_ret
= ldapsrv_del_with_controls(call
, dn
, call
->request
->controls
, res
);
1004 result
= map_ldb_error(local_ctx
, ldb_ret
, ldb_errstring(samdb
),
1008 del_result
= &del_reply
->msg
->r
.DelResponse
;
1009 del_result
->dn
= NULL
;
1010 if ((res
!= NULL
) && (res
->refs
!= NULL
)) {
1011 del_result
->resultcode
= map_ldb_error(local_ctx
,
1012 LDB_ERR_REFERRAL
, NULL
,
1014 del_result
->errormessage
= (errstr
?talloc_strdup(del_reply
,errstr
):NULL
);
1015 del_result
->referral
= talloc_strdup(call
, *res
->refs
);
1017 del_result
->resultcode
= result
;
1018 del_result
->errormessage
= (errstr
?talloc_strdup(del_reply
,errstr
):NULL
);
1019 del_result
->referral
= NULL
;
1022 talloc_free(local_ctx
);
1024 ldapsrv_queue_reply(call
, del_reply
);
1025 return NT_STATUS_OK
;
1028 static NTSTATUS
ldapsrv_ModifyDNRequest(struct ldapsrv_call
*call
)
1030 struct ldap_ModifyDNRequest
*req
= &call
->request
->r
.ModifyDNRequest
;
1031 struct ldap_Result
*modifydn
;
1032 struct ldapsrv_reply
*modifydn_r
;
1033 TALLOC_CTX
*local_ctx
;
1034 struct ldb_context
*samdb
= call
->conn
->ldb
;
1035 struct ldb_dn
*olddn
, *newdn
=NULL
, *newrdn
;
1036 struct ldb_dn
*parentdn
= NULL
;
1037 const char *errstr
= NULL
;
1038 int result
= LDAP_SUCCESS
;
1040 struct ldb_result
*res
= NULL
;
1042 DEBUG(10, ("ModifyDNRequest"));
1043 DEBUGADD(10, (" dn: %s", req
->dn
));
1044 DEBUGADD(10, (" newrdn: %s\n", req
->newrdn
));
1046 local_ctx
= talloc_named(call
, 0, "ModifyDNRequest local memory context");
1047 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
1049 olddn
= ldb_dn_new(local_ctx
, samdb
, req
->dn
);
1050 NT_STATUS_HAVE_NO_MEMORY(olddn
);
1052 newrdn
= ldb_dn_new(local_ctx
, samdb
, req
->newrdn
);
1053 NT_STATUS_HAVE_NO_MEMORY(newrdn
);
1055 DEBUG(10, ("ModifyDNRequest: olddn: [%s]\n", req
->dn
));
1056 DEBUG(10, ("ModifyDNRequest: newrdn: [%s]\n", req
->newrdn
));
1058 if (ldb_dn_get_comp_num(newrdn
) == 0) {
1059 result
= LDAP_PROTOCOL_ERROR
;
1060 map_ldb_error(local_ctx
, LDB_ERR_PROTOCOL_ERROR
, NULL
,
1065 if (ldb_dn_get_comp_num(newrdn
) > 1) {
1066 result
= LDAP_NAMING_VIOLATION
;
1067 map_ldb_error(local_ctx
, LDB_ERR_NAMING_VIOLATION
, NULL
,
1072 /* we can't handle the rename if we should not remove the old dn */
1073 if (!req
->deleteolddn
) {
1074 result
= LDAP_UNWILLING_TO_PERFORM
;
1075 map_ldb_error(local_ctx
, LDB_ERR_UNWILLING_TO_PERFORM
, NULL
,
1077 errstr
= talloc_asprintf(local_ctx
,
1078 "%s. Old RDN must be deleted", errstr
);
1082 if (req
->newsuperior
) {
1083 DEBUG(10, ("ModifyDNRequest: newsuperior: [%s]\n", req
->newsuperior
));
1084 parentdn
= ldb_dn_new(local_ctx
, samdb
, req
->newsuperior
);
1088 parentdn
= ldb_dn_get_parent(local_ctx
, olddn
);
1091 result
= LDAP_NO_SUCH_OBJECT
;
1092 map_ldb_error(local_ctx
, LDB_ERR_NO_SUCH_OBJECT
, NULL
, &errstr
);
1096 if ( ! ldb_dn_add_child(parentdn
, newrdn
)) {
1097 result
= LDAP_OTHER
;
1098 map_ldb_error(local_ctx
, LDB_ERR_OTHER
, NULL
, &errstr
);
1104 modifydn_r
= ldapsrv_init_reply(call
, LDAP_TAG_ModifyDNResponse
);
1105 NT_STATUS_HAVE_NO_MEMORY(modifydn_r
);
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_rename_with_controls(call
, olddn
, newdn
, call
->request
->controls
, res
);
1111 result
= map_ldb_error(local_ctx
, ldb_ret
, ldb_errstring(samdb
),
1115 modifydn
= &modifydn_r
->msg
->r
.ModifyDNResponse
;
1116 modifydn
->dn
= NULL
;
1117 if ((res
!= NULL
) && (res
->refs
!= NULL
)) {
1118 modifydn
->resultcode
= map_ldb_error(local_ctx
,
1119 LDB_ERR_REFERRAL
, NULL
,
1121 modifydn
->errormessage
= (errstr
?talloc_strdup(modifydn_r
,errstr
):NULL
);
1122 modifydn
->referral
= talloc_strdup(call
, *res
->refs
);
1124 modifydn
->resultcode
= result
;
1125 modifydn
->errormessage
= (errstr
?talloc_strdup(modifydn_r
,errstr
):NULL
);
1126 modifydn
->referral
= NULL
;
1129 talloc_free(local_ctx
);
1131 ldapsrv_queue_reply(call
, modifydn_r
);
1132 return NT_STATUS_OK
;
1135 static NTSTATUS
ldapsrv_CompareRequest(struct ldapsrv_call
*call
)
1137 struct ldap_CompareRequest
*req
= &call
->request
->r
.CompareRequest
;
1138 struct ldap_Result
*compare
;
1139 struct ldapsrv_reply
*compare_r
;
1140 TALLOC_CTX
*local_ctx
;
1141 struct ldb_context
*samdb
= call
->conn
->ldb
;
1142 struct ldb_result
*res
= NULL
;
1144 const char *attrs
[1];
1145 const char *errstr
= NULL
;
1146 const char *filter
= NULL
;
1147 int result
= LDAP_SUCCESS
;
1150 DEBUG(10, ("CompareRequest"));
1151 DEBUGADD(10, (" dn: %s\n", req
->dn
));
1153 local_ctx
= talloc_named(call
, 0, "CompareRequest local_memory_context");
1154 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
1156 dn
= ldb_dn_new(local_ctx
, samdb
, req
->dn
);
1157 NT_STATUS_HAVE_NO_MEMORY(dn
);
1159 DEBUG(10, ("CompareRequest: dn: [%s]\n", req
->dn
));
1160 filter
= talloc_asprintf(local_ctx
, "(%s=%*s)", req
->attribute
,
1161 (int)req
->value
.length
, req
->value
.data
);
1162 NT_STATUS_HAVE_NO_MEMORY(filter
);
1164 DEBUGADD(10, ("CompareRequest: attribute: [%s]\n", filter
));
1168 compare_r
= ldapsrv_init_reply(call
, LDAP_TAG_CompareResponse
);
1169 NT_STATUS_HAVE_NO_MEMORY(compare_r
);
1171 if (result
== LDAP_SUCCESS
) {
1172 ldb_ret
= ldb_search(samdb
, local_ctx
, &res
,
1173 dn
, LDB_SCOPE_BASE
, attrs
, "%s", filter
);
1174 if (ldb_ret
!= LDB_SUCCESS
) {
1175 result
= map_ldb_error(local_ctx
, ldb_ret
,
1176 ldb_errstring(samdb
), &errstr
);
1177 DEBUG(10,("CompareRequest: error: %s\n", errstr
));
1178 } else if (res
->count
== 0) {
1179 DEBUG(10,("CompareRequest: doesn't matched\n"));
1180 result
= LDAP_COMPARE_FALSE
;
1182 } else if (res
->count
== 1) {
1183 DEBUG(10,("CompareRequest: matched\n"));
1184 result
= LDAP_COMPARE_TRUE
;
1186 } else if (res
->count
> 1) {
1187 result
= LDAP_OTHER
;
1188 map_ldb_error(local_ctx
, LDB_ERR_OTHER
, NULL
, &errstr
);
1189 errstr
= talloc_asprintf(local_ctx
,
1190 "%s. Too many objects match!", errstr
);
1191 DEBUG(10,("CompareRequest: %d results: %s\n", res
->count
, errstr
));
1195 compare
= &compare_r
->msg
->r
.CompareResponse
;
1197 compare
->resultcode
= result
;
1198 compare
->errormessage
= (errstr
?talloc_strdup(compare_r
,errstr
):NULL
);
1199 compare
->referral
= NULL
;
1201 talloc_free(local_ctx
);
1203 ldapsrv_queue_reply(call
, compare_r
);
1204 return NT_STATUS_OK
;
1207 static NTSTATUS
ldapsrv_AbandonRequest(struct ldapsrv_call
*call
)
1209 struct ldap_AbandonRequest
*req
= &call
->request
->r
.AbandonRequest
;
1210 struct ldapsrv_call
*c
= NULL
;
1211 struct ldapsrv_call
*n
= NULL
;
1213 DEBUG(10, ("AbandonRequest\n"));
1215 for (c
= call
->conn
->pending_calls
; c
!= NULL
; c
= n
) {
1218 if (c
->request
->messageid
!= req
->messageid
) {
1222 DLIST_REMOVE(call
->conn
->pending_calls
, c
);
1226 return NT_STATUS_OK
;
1229 NTSTATUS
ldapsrv_do_call(struct ldapsrv_call
*call
)
1232 struct ldap_message
*msg
= call
->request
;
1235 /* Check for undecoded critical extensions */
1236 for (i
=0; msg
->controls
&& msg
->controls
[i
]; i
++) {
1237 if (!msg
->controls_decoded
[i
] &&
1238 msg
->controls
[i
]->critical
) {
1239 DEBUG(3, ("ldapsrv_do_call: Critical extension %s is not known to this server\n",
1240 msg
->controls
[i
]->oid
));
1241 return ldapsrv_unwilling(call
, LDAP_UNAVAILABLE_CRITICAL_EXTENSION
);
1245 if (call
->conn
->authz_logged
== false) {
1249 * We do not want to log anonymous access if the query
1250 * is just for the rootDSE, or it is a startTLS or a
1253 * A rootDSE search could also be done over
1254 * CLDAP anonymously for example, so these don't
1256 * Essentially we want to know about
1257 * access beyond that normally done prior to a
1261 switch(call
->request
->type
) {
1262 case LDAP_TAG_BindRequest
:
1263 case LDAP_TAG_UnbindRequest
:
1264 case LDAP_TAG_AbandonRequest
:
1267 case LDAP_TAG_ExtendedResponse
: {
1268 struct ldap_ExtendedRequest
*req
= &call
->request
->r
.ExtendedRequest
;
1269 if (strcmp(req
->oid
, LDB_EXTENDED_START_TLS_OID
) == 0) {
1274 case LDAP_TAG_SearchRequest
: {
1275 struct ldap_SearchRequest
*req
= &call
->request
->r
.SearchRequest
;
1276 if (req
->scope
== LDAP_SEARCH_SCOPE_BASE
) {
1277 if (req
->basedn
[0] == '\0') {
1288 const char *transport_protection
= AUTHZ_TRANSPORT_PROTECTION_NONE
;
1289 if (call
->conn
->sockets
.active
== call
->conn
->sockets
.tls
) {
1290 transport_protection
= AUTHZ_TRANSPORT_PROTECTION_TLS
;
1293 log_successful_authz_event(call
->conn
->connection
->msg_ctx
,
1294 call
->conn
->connection
->lp_ctx
,
1295 call
->conn
->connection
->remote_address
,
1296 call
->conn
->connection
->local_address
,
1299 transport_protection
,
1300 call
->conn
->session_info
);
1302 call
->conn
->authz_logged
= true;
1306 switch(call
->request
->type
) {
1307 case LDAP_TAG_BindRequest
:
1308 return ldapsrv_BindRequest(call
);
1309 case LDAP_TAG_UnbindRequest
:
1310 return ldapsrv_UnbindRequest(call
);
1311 case LDAP_TAG_SearchRequest
:
1312 return ldapsrv_SearchRequest(call
);
1313 case LDAP_TAG_ModifyRequest
:
1314 status
= ldapsrv_ModifyRequest(call
);
1316 case LDAP_TAG_AddRequest
:
1317 status
= ldapsrv_AddRequest(call
);
1319 case LDAP_TAG_DelRequest
:
1320 status
= ldapsrv_DelRequest(call
);
1322 case LDAP_TAG_ModifyDNRequest
:
1323 status
= ldapsrv_ModifyDNRequest(call
);
1325 case LDAP_TAG_CompareRequest
:
1326 return ldapsrv_CompareRequest(call
);
1327 case LDAP_TAG_AbandonRequest
:
1328 return ldapsrv_AbandonRequest(call
);
1329 case LDAP_TAG_ExtendedRequest
:
1330 status
= ldapsrv_ExtendedRequest(call
);
1333 return ldapsrv_unwilling(call
, LDAP_PROTOCOL_ERROR
);
1336 if (NT_STATUS_IS_OK(status
)) {
1337 ldapsrv_notification_retry_setup(call
->conn
->service
, true);