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 "param/param.h"
28 #include "smbd/service_stream.h"
29 #include "dsdb/samdb/samdb.h"
30 #include <ldb_errors.h>
31 #include <ldb_module.h>
34 static int map_ldb_error(TALLOC_CTX
*mem_ctx
, int ldb_err
,
35 const char *add_err_string
, const char **errstring
)
39 /* Certain LDB modules need to return very special WERROR codes. Proof
40 * for them here and if they exist skip the rest of the mapping. */
41 if (add_err_string
!= NULL
) {
43 strtol(add_err_string
, &endptr
, 16);
44 if (endptr
!= add_err_string
) {
45 *errstring
= add_err_string
;
50 /* Otherwise we calculate here a generic, but appropriate WERROR. */
56 case LDB_ERR_OPERATIONS_ERROR
:
57 err
= WERR_DS_OPERATIONS_ERROR
;
59 case LDB_ERR_PROTOCOL_ERROR
:
60 err
= WERR_DS_PROTOCOL_ERROR
;
62 case LDB_ERR_TIME_LIMIT_EXCEEDED
:
63 err
= WERR_DS_TIMELIMIT_EXCEEDED
;
65 case LDB_ERR_SIZE_LIMIT_EXCEEDED
:
66 err
= WERR_DS_SIZELIMIT_EXCEEDED
;
68 case LDB_ERR_COMPARE_FALSE
:
69 err
= WERR_DS_COMPARE_FALSE
;
71 case LDB_ERR_COMPARE_TRUE
:
72 err
= WERR_DS_COMPARE_TRUE
;
74 case LDB_ERR_AUTH_METHOD_NOT_SUPPORTED
:
75 err
= WERR_DS_AUTH_METHOD_NOT_SUPPORTED
;
77 case LDB_ERR_STRONG_AUTH_REQUIRED
:
78 err
= WERR_DS_STRONG_AUTH_REQUIRED
;
80 case LDB_ERR_REFERRAL
:
81 err
= WERR_DS_REFERRAL
;
83 case LDB_ERR_ADMIN_LIMIT_EXCEEDED
:
84 err
= WERR_DS_ADMIN_LIMIT_EXCEEDED
;
86 case LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION
:
87 err
= WERR_DS_UNAVAILABLE_CRIT_EXTENSION
;
89 case LDB_ERR_CONFIDENTIALITY_REQUIRED
:
90 err
= WERR_DS_CONFIDENTIALITY_REQUIRED
;
92 case LDB_ERR_SASL_BIND_IN_PROGRESS
:
95 case LDB_ERR_NO_SUCH_ATTRIBUTE
:
96 err
= WERR_DS_NO_ATTRIBUTE_OR_VALUE
;
98 case LDB_ERR_UNDEFINED_ATTRIBUTE_TYPE
:
99 err
= WERR_DS_ATTRIBUTE_TYPE_UNDEFINED
;
101 case LDB_ERR_INAPPROPRIATE_MATCHING
:
102 err
= WERR_DS_INAPPROPRIATE_MATCHING
;
104 case LDB_ERR_CONSTRAINT_VIOLATION
:
105 err
= WERR_DS_CONSTRAINT_VIOLATION
;
107 case LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS
:
108 err
= WERR_DS_ATTRIBUTE_OR_VALUE_EXISTS
;
110 case LDB_ERR_INVALID_ATTRIBUTE_SYNTAX
:
111 err
= WERR_DS_INVALID_ATTRIBUTE_SYNTAX
;
113 case LDB_ERR_NO_SUCH_OBJECT
:
114 err
= WERR_DS_NO_SUCH_OBJECT
;
116 case LDB_ERR_ALIAS_PROBLEM
:
117 err
= WERR_DS_ALIAS_PROBLEM
;
119 case LDB_ERR_INVALID_DN_SYNTAX
:
120 err
= WERR_DS_INVALID_DN_SYNTAX
;
122 case LDB_ERR_ALIAS_DEREFERENCING_PROBLEM
:
123 err
= WERR_DS_ALIAS_DEREF_PROBLEM
;
125 case LDB_ERR_INAPPROPRIATE_AUTHENTICATION
:
126 err
= WERR_DS_INAPPROPRIATE_AUTH
;
128 case LDB_ERR_INVALID_CREDENTIALS
:
129 err
= WERR_ACCESS_DENIED
;
131 case LDB_ERR_INSUFFICIENT_ACCESS_RIGHTS
:
132 err
= WERR_DS_INSUFF_ACCESS_RIGHTS
;
137 case LDB_ERR_UNAVAILABLE
:
138 err
= WERR_DS_UNAVAILABLE
;
140 case LDB_ERR_UNWILLING_TO_PERFORM
:
141 err
= WERR_DS_UNWILLING_TO_PERFORM
;
143 case LDB_ERR_LOOP_DETECT
:
144 err
= WERR_DS_LOOP_DETECT
;
146 case LDB_ERR_NAMING_VIOLATION
:
147 err
= WERR_DS_NAMING_VIOLATION
;
149 case LDB_ERR_OBJECT_CLASS_VIOLATION
:
150 err
= WERR_DS_OBJ_CLASS_VIOLATION
;
152 case LDB_ERR_NOT_ALLOWED_ON_NON_LEAF
:
153 err
= WERR_DS_CANT_ON_NON_LEAF
;
155 case LDB_ERR_NOT_ALLOWED_ON_RDN
:
156 err
= WERR_DS_CANT_ON_RDN
;
158 case LDB_ERR_ENTRY_ALREADY_EXISTS
:
159 err
= WERR_DS_OBJ_STRING_NAME_EXISTS
;
161 case LDB_ERR_OBJECT_CLASS_MODS_PROHIBITED
:
162 err
= WERR_DS_CANT_MOD_OBJ_CLASS
;
164 case LDB_ERR_AFFECTS_MULTIPLE_DSAS
:
165 err
= WERR_DS_AFFECTS_MULTIPLE_DSAS
;
168 err
= WERR_DS_GENERIC_ERROR
;
172 *errstring
= talloc_asprintf(mem_ctx
, "%08X: %s", W_ERROR_V(err
),
173 add_err_string
!= NULL
? add_err_string
: ldb_strerror(ldb_err
));
175 /* result is 1:1 for now */
180 connect to the sam database
182 NTSTATUS
ldapsrv_backend_Init(struct ldapsrv_connection
*conn
)
184 conn
->ldb
= samdb_connect(conn
,
185 conn
->connection
->event
.ctx
,
188 conn
->global_catalog
? LDB_FLG_RDONLY
: 0);
189 if (conn
->ldb
== NULL
) {
190 return NT_STATUS_INTERNAL_DB_CORRUPTION
;
193 if (conn
->server_credentials
) {
194 char **sasl_mechs
= NULL
;
195 const struct gensec_security_ops
* const *backends
= gensec_security_all();
196 const struct gensec_security_ops
**ops
197 = gensec_use_kerberos_mechs(conn
, backends
, conn
->server_credentials
);
198 unsigned int i
, j
= 0;
199 for (i
= 0; ops
&& ops
[i
]; i
++) {
200 if (!lpcfg_parm_bool(conn
->lp_ctx
, NULL
, "gensec", ops
[i
]->name
, ops
[i
]->enabled
))
203 if (ops
[i
]->sasl_name
&& ops
[i
]->server_start
) {
204 char *sasl_name
= talloc_strdup(conn
, ops
[i
]->sasl_name
);
207 return NT_STATUS_NO_MEMORY
;
209 sasl_mechs
= talloc_realloc(conn
, sasl_mechs
, char *, j
+ 2);
211 return NT_STATUS_NO_MEMORY
;
213 sasl_mechs
[j
] = sasl_name
;
214 talloc_steal(sasl_mechs
, sasl_name
);
215 sasl_mechs
[j
+1] = NULL
;
219 talloc_unlink(conn
, ops
);
221 /* ldb can have a different lifetime to conn, so we
222 need to ensure that sasl_mechs lives as long as the
224 talloc_steal(conn
->ldb
, sasl_mechs
);
226 ldb_set_opaque(conn
->ldb
, "supportedSASLMechanisms", sasl_mechs
);
229 ldb_set_opaque(conn
->ldb
, "remoteAddress",
230 conn
->connection
->remote_address
);
235 struct ldapsrv_reply
*ldapsrv_init_reply(struct ldapsrv_call
*call
, uint8_t type
)
237 struct ldapsrv_reply
*reply
;
239 reply
= talloc(call
, struct ldapsrv_reply
);
243 reply
->msg
= talloc(reply
, struct ldap_message
);
244 if (reply
->msg
== NULL
) {
249 reply
->msg
->messageid
= call
->request
->messageid
;
250 reply
->msg
->type
= type
;
251 reply
->msg
->controls
= NULL
;
256 void ldapsrv_queue_reply(struct ldapsrv_call
*call
, struct ldapsrv_reply
*reply
)
258 DLIST_ADD_END(call
->replies
, reply
);
261 static NTSTATUS
ldapsrv_unwilling(struct ldapsrv_call
*call
, int error
)
263 struct ldapsrv_reply
*reply
;
264 struct ldap_ExtendedResponse
*r
;
266 DEBUG(10,("Unwilling type[%d] id[%d]\n", call
->request
->type
, call
->request
->messageid
));
268 reply
= ldapsrv_init_reply(call
, LDAP_TAG_ExtendedResponse
);
270 return NT_STATUS_NO_MEMORY
;
273 r
= &reply
->msg
->r
.ExtendedResponse
;
274 r
->response
.resultcode
= error
;
275 r
->response
.dn
= NULL
;
276 r
->response
.errormessage
= NULL
;
277 r
->response
.referral
= NULL
;
281 ldapsrv_queue_reply(call
, reply
);
285 static int ldapsrv_add_with_controls(struct ldapsrv_call
*call
,
286 const struct ldb_message
*message
,
287 struct ldb_control
**controls
,
288 struct ldb_result
*res
)
290 struct ldb_context
*ldb
= call
->conn
->ldb
;
291 struct ldb_request
*req
;
294 ret
= ldb_msg_sanity_check(ldb
, message
);
295 if (ret
!= LDB_SUCCESS
) {
299 ret
= ldb_build_add_req(&req
, ldb
, ldb
,
303 ldb_modify_default_callback
,
306 if (ret
!= LDB_SUCCESS
) return ret
;
308 if (call
->conn
->global_catalog
) {
309 return ldb_error(ldb
, LDB_ERR_UNWILLING_TO_PERFORM
, "modify forbidden on global catalog port");
311 ldb_request_add_control(req
, DSDB_CONTROL_NO_GLOBAL_CATALOG
, false, NULL
);
313 ret
= ldb_transaction_start(ldb
);
314 if (ret
!= LDB_SUCCESS
) {
318 if (!call
->conn
->is_privileged
) {
319 ldb_req_mark_untrusted(req
);
322 LDB_REQ_SET_LOCATION(req
);
324 ret
= ldb_request(ldb
, req
);
325 if (ret
== LDB_SUCCESS
) {
326 ret
= ldb_wait(req
->handle
, LDB_WAIT_ALL
);
329 if (ret
== LDB_SUCCESS
) {
330 ret
= ldb_transaction_commit(ldb
);
333 ldb_transaction_cancel(ldb
);
340 /* create and execute a modify request */
341 static int ldapsrv_mod_with_controls(struct ldapsrv_call
*call
,
342 const struct ldb_message
*message
,
343 struct ldb_control
**controls
,
344 struct ldb_result
*res
)
346 struct ldb_context
*ldb
= call
->conn
->ldb
;
347 struct ldb_request
*req
;
350 ret
= ldb_msg_sanity_check(ldb
, message
);
351 if (ret
!= LDB_SUCCESS
) {
355 ret
= ldb_build_mod_req(&req
, ldb
, ldb
,
359 ldb_modify_default_callback
,
362 if (ret
!= LDB_SUCCESS
) {
366 if (call
->conn
->global_catalog
) {
367 return ldb_error(ldb
, LDB_ERR_UNWILLING_TO_PERFORM
, "modify forbidden on global catalog port");
369 ldb_request_add_control(req
, DSDB_CONTROL_NO_GLOBAL_CATALOG
, false, NULL
);
371 ret
= ldb_transaction_start(ldb
);
372 if (ret
!= LDB_SUCCESS
) {
376 if (!call
->conn
->is_privileged
) {
377 ldb_req_mark_untrusted(req
);
380 LDB_REQ_SET_LOCATION(req
);
382 ret
= ldb_request(ldb
, req
);
383 if (ret
== LDB_SUCCESS
) {
384 ret
= ldb_wait(req
->handle
, LDB_WAIT_ALL
);
387 if (ret
== LDB_SUCCESS
) {
388 ret
= ldb_transaction_commit(ldb
);
391 ldb_transaction_cancel(ldb
);
398 /* create and execute a delete request */
399 static int ldapsrv_del_with_controls(struct ldapsrv_call
*call
,
401 struct ldb_control
**controls
,
402 struct ldb_result
*res
)
404 struct ldb_context
*ldb
= call
->conn
->ldb
;
405 struct ldb_request
*req
;
408 ret
= ldb_build_del_req(&req
, ldb
, ldb
,
412 ldb_modify_default_callback
,
415 if (ret
!= LDB_SUCCESS
) return ret
;
417 if (call
->conn
->global_catalog
) {
418 return ldb_error(ldb
, LDB_ERR_UNWILLING_TO_PERFORM
, "modify forbidden on global catalog port");
420 ldb_request_add_control(req
, DSDB_CONTROL_NO_GLOBAL_CATALOG
, false, NULL
);
422 ret
= ldb_transaction_start(ldb
);
423 if (ret
!= LDB_SUCCESS
) {
427 if (!call
->conn
->is_privileged
) {
428 ldb_req_mark_untrusted(req
);
431 LDB_REQ_SET_LOCATION(req
);
433 ret
= ldb_request(ldb
, req
);
434 if (ret
== LDB_SUCCESS
) {
435 ret
= ldb_wait(req
->handle
, LDB_WAIT_ALL
);
438 if (ret
== LDB_SUCCESS
) {
439 ret
= ldb_transaction_commit(ldb
);
442 ldb_transaction_cancel(ldb
);
449 static int ldapsrv_rename_with_controls(struct ldapsrv_call
*call
,
450 struct ldb_dn
*olddn
,
451 struct ldb_dn
*newdn
,
452 struct ldb_control
**controls
,
453 struct ldb_result
*res
)
455 struct ldb_context
*ldb
= call
->conn
->ldb
;
456 struct ldb_request
*req
;
459 ret
= ldb_build_rename_req(&req
, ldb
, ldb
,
464 ldb_modify_default_callback
,
467 if (ret
!= LDB_SUCCESS
) return ret
;
469 if (call
->conn
->global_catalog
) {
470 return ldb_error(ldb
, LDB_ERR_UNWILLING_TO_PERFORM
, "modify forbidden on global catalog port");
472 ldb_request_add_control(req
, DSDB_CONTROL_NO_GLOBAL_CATALOG
, false, NULL
);
474 ret
= ldb_transaction_start(ldb
);
475 if (ret
!= LDB_SUCCESS
) {
479 if (!call
->conn
->is_privileged
) {
480 ldb_req_mark_untrusted(req
);
483 LDB_REQ_SET_LOCATION(req
);
485 ret
= ldb_request(ldb
, req
);
486 if (ret
== LDB_SUCCESS
) {
487 ret
= ldb_wait(req
->handle
, LDB_WAIT_ALL
);
490 if (ret
== LDB_SUCCESS
) {
491 ret
= ldb_transaction_commit(ldb
);
494 ldb_transaction_cancel(ldb
);
501 static NTSTATUS
ldapsrv_SearchRequest(struct ldapsrv_call
*call
)
503 struct ldap_SearchRequest
*req
= &call
->request
->r
.SearchRequest
;
504 struct ldap_SearchResEntry
*ent
;
505 struct ldap_Result
*done
;
506 struct ldapsrv_reply
*ent_r
, *done_r
;
507 TALLOC_CTX
*local_ctx
;
508 struct ldb_context
*samdb
= talloc_get_type(call
->conn
->ldb
, struct ldb_context
);
509 struct ldb_dn
*basedn
;
510 struct ldb_result
*res
= NULL
;
511 struct ldb_request
*lreq
;
512 struct ldb_control
*search_control
;
513 struct ldb_search_options_control
*search_options
;
514 struct ldb_control
*extended_dn_control
;
515 struct ldb_extended_dn_control
*extended_dn_decoded
= NULL
;
516 struct ldb_control
*notification_control
= NULL
;
517 enum ldb_scope scope
= LDB_SCOPE_DEFAULT
;
518 const char **attrs
= NULL
;
519 const char *scope_str
, *errstr
= NULL
;
520 int success_limit
= 1;
524 int extended_type
= 1;
526 DEBUG(10, ("SearchRequest"));
527 DEBUGADD(10, (" basedn: %s", req
->basedn
));
528 DEBUGADD(10, (" filter: %s\n", ldb_filter_from_tree(call
, req
->tree
)));
530 local_ctx
= talloc_new(call
);
531 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
533 basedn
= ldb_dn_new(local_ctx
, samdb
, req
->basedn
);
534 NT_STATUS_HAVE_NO_MEMORY(basedn
);
536 DEBUG(10, ("SearchRequest: basedn: [%s]\n", req
->basedn
));
537 DEBUG(10, ("SearchRequest: filter: [%s]\n", ldb_filter_from_tree(call
, req
->tree
)));
539 switch (req
->scope
) {
540 case LDAP_SEARCH_SCOPE_BASE
:
542 scope
= LDB_SCOPE_BASE
;
545 case LDAP_SEARCH_SCOPE_SINGLE
:
547 scope
= LDB_SCOPE_ONELEVEL
;
550 case LDAP_SEARCH_SCOPE_SUB
:
552 scope
= LDB_SCOPE_SUBTREE
;
556 result
= LDAP_PROTOCOL_ERROR
;
557 map_ldb_error(local_ctx
, LDB_ERR_PROTOCOL_ERROR
, NULL
,
559 errstr
= talloc_asprintf(local_ctx
,
560 "%s. Invalid scope", errstr
);
563 DEBUG(10,("SearchRequest: scope: [%s]\n", scope_str
));
565 if (req
->num_attributes
>= 1) {
566 attrs
= talloc_array(local_ctx
, const char *, req
->num_attributes
+1);
567 NT_STATUS_HAVE_NO_MEMORY(attrs
);
569 for (i
=0; i
< req
->num_attributes
; i
++) {
570 DEBUG(10,("SearchRequest: attrs: [%s]\n",req
->attributes
[i
]));
571 attrs
[i
] = req
->attributes
[i
];
576 DEBUG(5,("ldb_request %s dn=%s filter=%s\n",
577 scope_str
, req
->basedn
, ldb_filter_from_tree(call
, req
->tree
)));
579 res
= talloc_zero(local_ctx
, struct ldb_result
);
580 NT_STATUS_HAVE_NO_MEMORY(res
);
582 ldb_ret
= ldb_build_search_req_ex(&lreq
, samdb
, local_ctx
,
585 call
->request
->controls
,
586 res
, ldb_search_default_callback
,
589 if (ldb_ret
!= LDB_SUCCESS
) {
593 if (call
->conn
->global_catalog
) {
594 search_control
= ldb_request_get_control(lreq
, LDB_CONTROL_SEARCH_OPTIONS_OID
);
596 search_options
= NULL
;
597 if (search_control
) {
598 search_options
= talloc_get_type(search_control
->data
, struct ldb_search_options_control
);
599 search_options
->search_options
|= LDB_SEARCH_OPTION_PHANTOM_ROOT
;
601 search_options
= talloc(lreq
, struct ldb_search_options_control
);
602 NT_STATUS_HAVE_NO_MEMORY(search_options
);
603 search_options
->search_options
= LDB_SEARCH_OPTION_PHANTOM_ROOT
;
604 ldb_request_add_control(lreq
, LDB_CONTROL_SEARCH_OPTIONS_OID
, false, search_options
);
607 ldb_request_add_control(lreq
, DSDB_CONTROL_NO_GLOBAL_CATALOG
, false, NULL
);
610 extended_dn_control
= ldb_request_get_control(lreq
, LDB_CONTROL_EXTENDED_DN_OID
);
612 if (extended_dn_control
) {
613 if (extended_dn_control
->data
) {
614 extended_dn_decoded
= talloc_get_type(extended_dn_control
->data
, struct ldb_extended_dn_control
);
615 extended_type
= extended_dn_decoded
->type
;
621 notification_control
= ldb_request_get_control(lreq
, LDB_CONTROL_NOTIFICATION_OID
);
622 if (notification_control
!= NULL
) {
623 const struct ldapsrv_call
*pc
= NULL
;
626 for (pc
= call
->conn
->pending_calls
; pc
!= NULL
; pc
= pc
->next
) {
630 if (count
>= call
->conn
->limits
.max_notifications
) {
631 DEBUG(10,("SearchRequest: error MaxNotificationPerConn\n"));
632 result
= map_ldb_error(local_ctx
,
633 LDB_ERR_ADMIN_LIMIT_EXCEEDED
,
634 "MaxNotificationPerConn reached",
640 * For now we need to do periodic retries on our own.
641 * As the dsdb_notification module will return after each run.
643 call
->notification
.busy
= true;
646 ldb_set_timeout(samdb
, lreq
, req
->timelimit
);
648 if (!call
->conn
->is_privileged
) {
649 ldb_req_mark_untrusted(lreq
);
652 LDB_REQ_SET_LOCATION(lreq
);
654 ldb_ret
= ldb_request(samdb
, lreq
);
656 if (ldb_ret
!= LDB_SUCCESS
) {
660 ldb_ret
= ldb_wait(lreq
->handle
, LDB_WAIT_ALL
);
662 if (ldb_ret
== LDB_SUCCESS
) {
663 for (i
= 0; i
< res
->count
; i
++) {
664 ent_r
= ldapsrv_init_reply(call
, LDAP_TAG_SearchResultEntry
);
665 NT_STATUS_HAVE_NO_MEMORY(ent_r
);
667 /* Better to have the whole message kept here,
668 * than to find someone further up didn't put
669 * a value in the right spot in the talloc tree */
670 talloc_steal(ent_r
, res
->msgs
[i
]);
672 ent
= &ent_r
->msg
->r
.SearchResultEntry
;
673 ent
->dn
= ldb_dn_get_extended_linearized(ent_r
, res
->msgs
[i
]->dn
, extended_type
);
674 ent
->num_attributes
= 0;
675 ent
->attributes
= NULL
;
676 if (res
->msgs
[i
]->num_elements
== 0) {
679 ent
->num_attributes
= res
->msgs
[i
]->num_elements
;
680 ent
->attributes
= talloc_array(ent_r
, struct ldb_message_element
, ent
->num_attributes
);
681 NT_STATUS_HAVE_NO_MEMORY(ent
->attributes
);
682 for (j
=0; j
< ent
->num_attributes
; j
++) {
683 ent
->attributes
[j
].name
= res
->msgs
[i
]->elements
[j
].name
;
684 ent
->attributes
[j
].num_values
= 0;
685 ent
->attributes
[j
].values
= NULL
;
686 if (req
->attributesonly
&& (res
->msgs
[i
]->elements
[j
].num_values
== 0)) {
689 ent
->attributes
[j
].num_values
= res
->msgs
[i
]->elements
[j
].num_values
;
690 ent
->attributes
[j
].values
= res
->msgs
[i
]->elements
[j
].values
;
693 ldapsrv_queue_reply(call
, ent_r
);
696 if (call
->notification
.busy
) {
697 /* Move/Add it to the end */
698 DLIST_DEMOTE(call
->conn
->pending_calls
, call
);
699 call
->notification
.generation
=
700 call
->conn
->service
->notification
.generation
;
702 if (res
->count
!= 0) {
703 call
->notification
.generation
+= 1;
704 ldapsrv_notification_retry_setup(call
->conn
->service
,
708 talloc_free(local_ctx
);
712 /* Send back referrals if they do exist (search operations) */
713 if (res
->refs
!= NULL
) {
715 struct ldap_SearchResRef
*ent_ref
;
717 for (ref
= res
->refs
; *ref
!= NULL
; ++ref
) {
718 ent_r
= ldapsrv_init_reply(call
, LDAP_TAG_SearchResultReference
);
719 NT_STATUS_HAVE_NO_MEMORY(ent_r
);
721 /* Better to have the whole referrals kept here,
722 * than to find someone further up didn't put
723 * a value in the right spot in the talloc tree
725 talloc_steal(ent_r
, *ref
);
727 ent_ref
= &ent_r
->msg
->r
.SearchResultReference
;
728 ent_ref
->referral
= *ref
;
730 ldapsrv_queue_reply(call
, ent_r
);
736 DLIST_REMOVE(call
->conn
->pending_calls
, call
);
737 call
->notification
.busy
= false;
739 done_r
= ldapsrv_init_reply(call
, LDAP_TAG_SearchResultDone
);
740 NT_STATUS_HAVE_NO_MEMORY(done_r
);
742 done
= &done_r
->msg
->r
.SearchResultDone
;
744 done
->referral
= NULL
;
747 } else if (ldb_ret
== LDB_SUCCESS
) {
748 if (res
->count
>= success_limit
) {
749 DEBUG(10,("SearchRequest: results: [%d]\n", res
->count
));
750 result
= LDAP_SUCCESS
;
754 done_r
->msg
->controls
= res
->controls
;
755 talloc_steal(done_r
, res
->controls
);
758 DEBUG(10,("SearchRequest: error\n"));
759 result
= map_ldb_error(local_ctx
, ldb_ret
, ldb_errstring(samdb
),
763 done
->resultcode
= result
;
764 done
->errormessage
= (errstr
?talloc_strdup(done_r
, errstr
):NULL
);
766 talloc_free(local_ctx
);
768 ldapsrv_queue_reply(call
, done_r
);
772 static NTSTATUS
ldapsrv_ModifyRequest(struct ldapsrv_call
*call
)
774 struct ldap_ModifyRequest
*req
= &call
->request
->r
.ModifyRequest
;
775 struct ldap_Result
*modify_result
;
776 struct ldapsrv_reply
*modify_reply
;
777 TALLOC_CTX
*local_ctx
;
778 struct ldb_context
*samdb
= call
->conn
->ldb
;
779 struct ldb_message
*msg
= NULL
;
781 const char *errstr
= NULL
;
782 int result
= LDAP_SUCCESS
;
785 struct ldb_result
*res
= NULL
;
787 DEBUG(10, ("ModifyRequest"));
788 DEBUGADD(10, (" dn: %s\n", req
->dn
));
790 local_ctx
= talloc_named(call
, 0, "ModifyRequest local memory context");
791 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
793 dn
= ldb_dn_new(local_ctx
, samdb
, req
->dn
);
794 NT_STATUS_HAVE_NO_MEMORY(dn
);
796 DEBUG(10, ("ModifyRequest: dn: [%s]\n", req
->dn
));
798 msg
= talloc(local_ctx
, struct ldb_message
);
799 NT_STATUS_HAVE_NO_MEMORY(msg
);
802 msg
->num_elements
= 0;
803 msg
->elements
= NULL
;
805 if (req
->num_mods
> 0) {
806 msg
->num_elements
= req
->num_mods
;
807 msg
->elements
= talloc_array(msg
, struct ldb_message_element
, req
->num_mods
);
808 NT_STATUS_HAVE_NO_MEMORY(msg
->elements
);
810 for (i
=0; i
< msg
->num_elements
; i
++) {
811 msg
->elements
[i
].name
= discard_const_p(char, req
->mods
[i
].attrib
.name
);
812 msg
->elements
[i
].num_values
= 0;
813 msg
->elements
[i
].values
= NULL
;
815 switch (req
->mods
[i
].type
) {
817 result
= LDAP_PROTOCOL_ERROR
;
818 map_ldb_error(local_ctx
,
819 LDB_ERR_PROTOCOL_ERROR
, NULL
, &errstr
);
820 errstr
= talloc_asprintf(local_ctx
,
821 "%s. Invalid LDAP_MODIFY_* type", errstr
);
823 case LDAP_MODIFY_ADD
:
824 msg
->elements
[i
].flags
= LDB_FLAG_MOD_ADD
;
826 case LDAP_MODIFY_DELETE
:
827 msg
->elements
[i
].flags
= LDB_FLAG_MOD_DELETE
;
829 case LDAP_MODIFY_REPLACE
:
830 msg
->elements
[i
].flags
= LDB_FLAG_MOD_REPLACE
;
834 msg
->elements
[i
].num_values
= req
->mods
[i
].attrib
.num_values
;
835 if (msg
->elements
[i
].num_values
> 0) {
836 msg
->elements
[i
].values
= talloc_array(msg
->elements
, struct ldb_val
,
837 msg
->elements
[i
].num_values
);
838 NT_STATUS_HAVE_NO_MEMORY(msg
->elements
[i
].values
);
840 for (j
=0; j
< msg
->elements
[i
].num_values
; j
++) {
841 msg
->elements
[i
].values
[j
].length
= req
->mods
[i
].attrib
.values
[j
].length
;
842 msg
->elements
[i
].values
[j
].data
= req
->mods
[i
].attrib
.values
[j
].data
;
849 modify_reply
= ldapsrv_init_reply(call
, LDAP_TAG_ModifyResponse
);
850 NT_STATUS_HAVE_NO_MEMORY(modify_reply
);
852 if (result
== LDAP_SUCCESS
) {
853 res
= talloc_zero(local_ctx
, struct ldb_result
);
854 NT_STATUS_HAVE_NO_MEMORY(res
);
855 ldb_ret
= ldapsrv_mod_with_controls(call
, msg
, call
->request
->controls
, res
);
856 result
= map_ldb_error(local_ctx
, ldb_ret
, ldb_errstring(samdb
),
860 modify_result
= &modify_reply
->msg
->r
.ModifyResponse
;
861 modify_result
->dn
= NULL
;
862 if ((res
!= NULL
) && (res
->refs
!= NULL
)) {
863 modify_result
->resultcode
= map_ldb_error(local_ctx
,
866 modify_result
->errormessage
= (errstr
?talloc_strdup(modify_reply
, errstr
):NULL
);
867 modify_result
->referral
= talloc_strdup(call
, *res
->refs
);
869 modify_result
->resultcode
= result
;
870 modify_result
->errormessage
= (errstr
?talloc_strdup(modify_reply
, errstr
):NULL
);
871 modify_result
->referral
= NULL
;
873 talloc_free(local_ctx
);
875 ldapsrv_queue_reply(call
, modify_reply
);
880 static NTSTATUS
ldapsrv_AddRequest(struct ldapsrv_call
*call
)
882 struct ldap_AddRequest
*req
= &call
->request
->r
.AddRequest
;
883 struct ldap_Result
*add_result
;
884 struct ldapsrv_reply
*add_reply
;
885 TALLOC_CTX
*local_ctx
;
886 struct ldb_context
*samdb
= call
->conn
->ldb
;
887 struct ldb_message
*msg
= NULL
;
889 const char *errstr
= NULL
;
890 int result
= LDAP_SUCCESS
;
893 struct ldb_result
*res
= NULL
;
895 DEBUG(10, ("AddRequest"));
896 DEBUGADD(10, (" dn: %s\n", req
->dn
));
898 local_ctx
= talloc_named(call
, 0, "AddRequest local memory context");
899 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
901 dn
= ldb_dn_new(local_ctx
, samdb
, req
->dn
);
902 NT_STATUS_HAVE_NO_MEMORY(dn
);
904 DEBUG(10, ("AddRequest: dn: [%s]\n", req
->dn
));
906 msg
= talloc(local_ctx
, struct ldb_message
);
907 NT_STATUS_HAVE_NO_MEMORY(msg
);
910 msg
->num_elements
= 0;
911 msg
->elements
= NULL
;
913 if (req
->num_attributes
> 0) {
914 msg
->num_elements
= req
->num_attributes
;
915 msg
->elements
= talloc_array(msg
, struct ldb_message_element
, msg
->num_elements
);
916 NT_STATUS_HAVE_NO_MEMORY(msg
->elements
);
918 for (i
=0; i
< msg
->num_elements
; i
++) {
919 msg
->elements
[i
].name
= discard_const_p(char, req
->attributes
[i
].name
);
920 msg
->elements
[i
].flags
= 0;
921 msg
->elements
[i
].num_values
= 0;
922 msg
->elements
[i
].values
= NULL
;
924 if (req
->attributes
[i
].num_values
> 0) {
925 msg
->elements
[i
].num_values
= req
->attributes
[i
].num_values
;
926 msg
->elements
[i
].values
= talloc_array(msg
->elements
, struct ldb_val
,
927 msg
->elements
[i
].num_values
);
928 NT_STATUS_HAVE_NO_MEMORY(msg
->elements
[i
].values
);
930 for (j
=0; j
< msg
->elements
[i
].num_values
; j
++) {
931 msg
->elements
[i
].values
[j
].length
= req
->attributes
[i
].values
[j
].length
;
932 msg
->elements
[i
].values
[j
].data
= req
->attributes
[i
].values
[j
].data
;
938 add_reply
= ldapsrv_init_reply(call
, LDAP_TAG_AddResponse
);
939 NT_STATUS_HAVE_NO_MEMORY(add_reply
);
941 if (result
== LDAP_SUCCESS
) {
942 res
= talloc_zero(local_ctx
, struct ldb_result
);
943 NT_STATUS_HAVE_NO_MEMORY(res
);
944 ldb_ret
= ldapsrv_add_with_controls(call
, msg
, call
->request
->controls
, res
);
945 result
= map_ldb_error(local_ctx
, ldb_ret
, ldb_errstring(samdb
),
949 add_result
= &add_reply
->msg
->r
.AddResponse
;
950 add_result
->dn
= NULL
;
951 if ((res
!= NULL
) && (res
->refs
!= NULL
)) {
952 add_result
->resultcode
= map_ldb_error(local_ctx
,
953 LDB_ERR_REFERRAL
, NULL
,
955 add_result
->errormessage
= (errstr
?talloc_strdup(add_reply
,errstr
):NULL
);
956 add_result
->referral
= talloc_strdup(call
, *res
->refs
);
958 add_result
->resultcode
= result
;
959 add_result
->errormessage
= (errstr
?talloc_strdup(add_reply
,errstr
):NULL
);
960 add_result
->referral
= NULL
;
962 talloc_free(local_ctx
);
964 ldapsrv_queue_reply(call
, add_reply
);
969 static NTSTATUS
ldapsrv_DelRequest(struct ldapsrv_call
*call
)
971 struct ldap_DelRequest
*req
= &call
->request
->r
.DelRequest
;
972 struct ldap_Result
*del_result
;
973 struct ldapsrv_reply
*del_reply
;
974 TALLOC_CTX
*local_ctx
;
975 struct ldb_context
*samdb
= call
->conn
->ldb
;
977 const char *errstr
= NULL
;
978 int result
= LDAP_SUCCESS
;
980 struct ldb_result
*res
= NULL
;
982 DEBUG(10, ("DelRequest"));
983 DEBUGADD(10, (" dn: %s\n", req
->dn
));
985 local_ctx
= talloc_named(call
, 0, "DelRequest local memory context");
986 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
988 dn
= ldb_dn_new(local_ctx
, samdb
, req
->dn
);
989 NT_STATUS_HAVE_NO_MEMORY(dn
);
991 DEBUG(10, ("DelRequest: dn: [%s]\n", req
->dn
));
993 del_reply
= ldapsrv_init_reply(call
, LDAP_TAG_DelResponse
);
994 NT_STATUS_HAVE_NO_MEMORY(del_reply
);
996 if (result
== LDAP_SUCCESS
) {
997 res
= talloc_zero(local_ctx
, struct ldb_result
);
998 NT_STATUS_HAVE_NO_MEMORY(res
);
999 ldb_ret
= ldapsrv_del_with_controls(call
, dn
, call
->request
->controls
, res
);
1000 result
= map_ldb_error(local_ctx
, ldb_ret
, ldb_errstring(samdb
),
1004 del_result
= &del_reply
->msg
->r
.DelResponse
;
1005 del_result
->dn
= NULL
;
1006 if ((res
!= NULL
) && (res
->refs
!= NULL
)) {
1007 del_result
->resultcode
= map_ldb_error(local_ctx
,
1008 LDB_ERR_REFERRAL
, NULL
,
1010 del_result
->errormessage
= (errstr
?talloc_strdup(del_reply
,errstr
):NULL
);
1011 del_result
->referral
= talloc_strdup(call
, *res
->refs
);
1013 del_result
->resultcode
= result
;
1014 del_result
->errormessage
= (errstr
?talloc_strdup(del_reply
,errstr
):NULL
);
1015 del_result
->referral
= NULL
;
1018 talloc_free(local_ctx
);
1020 ldapsrv_queue_reply(call
, del_reply
);
1021 return NT_STATUS_OK
;
1024 static NTSTATUS
ldapsrv_ModifyDNRequest(struct ldapsrv_call
*call
)
1026 struct ldap_ModifyDNRequest
*req
= &call
->request
->r
.ModifyDNRequest
;
1027 struct ldap_Result
*modifydn
;
1028 struct ldapsrv_reply
*modifydn_r
;
1029 TALLOC_CTX
*local_ctx
;
1030 struct ldb_context
*samdb
= call
->conn
->ldb
;
1031 struct ldb_dn
*olddn
, *newdn
=NULL
, *newrdn
;
1032 struct ldb_dn
*parentdn
= NULL
;
1033 const char *errstr
= NULL
;
1034 int result
= LDAP_SUCCESS
;
1036 struct ldb_result
*res
= NULL
;
1038 DEBUG(10, ("ModifyDNRequest"));
1039 DEBUGADD(10, (" dn: %s", req
->dn
));
1040 DEBUGADD(10, (" newrdn: %s\n", req
->newrdn
));
1042 local_ctx
= talloc_named(call
, 0, "ModifyDNRequest local memory context");
1043 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
1045 olddn
= ldb_dn_new(local_ctx
, samdb
, req
->dn
);
1046 NT_STATUS_HAVE_NO_MEMORY(olddn
);
1048 newrdn
= ldb_dn_new(local_ctx
, samdb
, req
->newrdn
);
1049 NT_STATUS_HAVE_NO_MEMORY(newrdn
);
1051 DEBUG(10, ("ModifyDNRequest: olddn: [%s]\n", req
->dn
));
1052 DEBUG(10, ("ModifyDNRequest: newrdn: [%s]\n", req
->newrdn
));
1054 if (ldb_dn_get_comp_num(newrdn
) == 0) {
1055 result
= LDAP_PROTOCOL_ERROR
;
1056 map_ldb_error(local_ctx
, LDB_ERR_PROTOCOL_ERROR
, NULL
,
1061 if (ldb_dn_get_comp_num(newrdn
) > 1) {
1062 result
= LDAP_NAMING_VIOLATION
;
1063 map_ldb_error(local_ctx
, LDB_ERR_NAMING_VIOLATION
, NULL
,
1068 /* we can't handle the rename if we should not remove the old dn */
1069 if (!req
->deleteolddn
) {
1070 result
= LDAP_UNWILLING_TO_PERFORM
;
1071 map_ldb_error(local_ctx
, LDB_ERR_UNWILLING_TO_PERFORM
, NULL
,
1073 errstr
= talloc_asprintf(local_ctx
,
1074 "%s. Old RDN must be deleted", errstr
);
1078 if (req
->newsuperior
) {
1079 DEBUG(10, ("ModifyDNRequest: newsuperior: [%s]\n", req
->newsuperior
));
1080 parentdn
= ldb_dn_new(local_ctx
, samdb
, req
->newsuperior
);
1084 parentdn
= ldb_dn_get_parent(local_ctx
, olddn
);
1087 result
= LDAP_NO_SUCH_OBJECT
;
1088 map_ldb_error(local_ctx
, LDB_ERR_NO_SUCH_OBJECT
, NULL
, &errstr
);
1092 if ( ! ldb_dn_add_child(parentdn
, newrdn
)) {
1093 result
= LDAP_OTHER
;
1094 map_ldb_error(local_ctx
, LDB_ERR_OTHER
, NULL
, &errstr
);
1100 modifydn_r
= ldapsrv_init_reply(call
, LDAP_TAG_ModifyDNResponse
);
1101 NT_STATUS_HAVE_NO_MEMORY(modifydn_r
);
1103 if (result
== LDAP_SUCCESS
) {
1104 res
= talloc_zero(local_ctx
, struct ldb_result
);
1105 NT_STATUS_HAVE_NO_MEMORY(res
);
1106 ldb_ret
= ldapsrv_rename_with_controls(call
, olddn
, newdn
, call
->request
->controls
, res
);
1107 result
= map_ldb_error(local_ctx
, ldb_ret
, ldb_errstring(samdb
),
1111 modifydn
= &modifydn_r
->msg
->r
.ModifyDNResponse
;
1112 modifydn
->dn
= NULL
;
1113 if ((res
!= NULL
) && (res
->refs
!= NULL
)) {
1114 modifydn
->resultcode
= map_ldb_error(local_ctx
,
1115 LDB_ERR_REFERRAL
, NULL
,
1117 modifydn
->errormessage
= (errstr
?talloc_strdup(modifydn_r
,errstr
):NULL
);
1118 modifydn
->referral
= talloc_strdup(call
, *res
->refs
);
1120 modifydn
->resultcode
= result
;
1121 modifydn
->errormessage
= (errstr
?talloc_strdup(modifydn_r
,errstr
):NULL
);
1122 modifydn
->referral
= NULL
;
1125 talloc_free(local_ctx
);
1127 ldapsrv_queue_reply(call
, modifydn_r
);
1128 return NT_STATUS_OK
;
1131 static NTSTATUS
ldapsrv_CompareRequest(struct ldapsrv_call
*call
)
1133 struct ldap_CompareRequest
*req
= &call
->request
->r
.CompareRequest
;
1134 struct ldap_Result
*compare
;
1135 struct ldapsrv_reply
*compare_r
;
1136 TALLOC_CTX
*local_ctx
;
1137 struct ldb_context
*samdb
= call
->conn
->ldb
;
1138 struct ldb_result
*res
= NULL
;
1140 const char *attrs
[1];
1141 const char *errstr
= NULL
;
1142 const char *filter
= NULL
;
1143 int result
= LDAP_SUCCESS
;
1146 DEBUG(10, ("CompareRequest"));
1147 DEBUGADD(10, (" dn: %s\n", req
->dn
));
1149 local_ctx
= talloc_named(call
, 0, "CompareRequest local_memory_context");
1150 NT_STATUS_HAVE_NO_MEMORY(local_ctx
);
1152 dn
= ldb_dn_new(local_ctx
, samdb
, req
->dn
);
1153 NT_STATUS_HAVE_NO_MEMORY(dn
);
1155 DEBUG(10, ("CompareRequest: dn: [%s]\n", req
->dn
));
1156 filter
= talloc_asprintf(local_ctx
, "(%s=%*s)", req
->attribute
,
1157 (int)req
->value
.length
, req
->value
.data
);
1158 NT_STATUS_HAVE_NO_MEMORY(filter
);
1160 DEBUGADD(10, ("CompareRequest: attribute: [%s]\n", filter
));
1164 compare_r
= ldapsrv_init_reply(call
, LDAP_TAG_CompareResponse
);
1165 NT_STATUS_HAVE_NO_MEMORY(compare_r
);
1167 if (result
== LDAP_SUCCESS
) {
1168 ldb_ret
= ldb_search(samdb
, local_ctx
, &res
,
1169 dn
, LDB_SCOPE_BASE
, attrs
, "%s", filter
);
1170 if (ldb_ret
!= LDB_SUCCESS
) {
1171 result
= map_ldb_error(local_ctx
, ldb_ret
,
1172 ldb_errstring(samdb
), &errstr
);
1173 DEBUG(10,("CompareRequest: error: %s\n", errstr
));
1174 } else if (res
->count
== 0) {
1175 DEBUG(10,("CompareRequest: doesn't matched\n"));
1176 result
= LDAP_COMPARE_FALSE
;
1178 } else if (res
->count
== 1) {
1179 DEBUG(10,("CompareRequest: matched\n"));
1180 result
= LDAP_COMPARE_TRUE
;
1182 } else if (res
->count
> 1) {
1183 result
= LDAP_OTHER
;
1184 map_ldb_error(local_ctx
, LDB_ERR_OTHER
, NULL
, &errstr
);
1185 errstr
= talloc_asprintf(local_ctx
,
1186 "%s. Too many objects match!", errstr
);
1187 DEBUG(10,("CompareRequest: %d results: %s\n", res
->count
, errstr
));
1191 compare
= &compare_r
->msg
->r
.CompareResponse
;
1193 compare
->resultcode
= result
;
1194 compare
->errormessage
= (errstr
?talloc_strdup(compare_r
,errstr
):NULL
);
1195 compare
->referral
= NULL
;
1197 talloc_free(local_ctx
);
1199 ldapsrv_queue_reply(call
, compare_r
);
1200 return NT_STATUS_OK
;
1203 static NTSTATUS
ldapsrv_AbandonRequest(struct ldapsrv_call
*call
)
1205 struct ldap_AbandonRequest
*req
= &call
->request
->r
.AbandonRequest
;
1206 struct ldapsrv_call
*c
= NULL
;
1207 struct ldapsrv_call
*n
= NULL
;
1209 DEBUG(10, ("AbandonRequest\n"));
1211 for (c
= call
->conn
->pending_calls
; c
!= NULL
; c
= n
) {
1214 if (c
->request
->messageid
!= req
->messageid
) {
1218 DLIST_REMOVE(call
->conn
->pending_calls
, c
);
1222 return NT_STATUS_OK
;
1225 NTSTATUS
ldapsrv_do_call(struct ldapsrv_call
*call
)
1228 struct ldap_message
*msg
= call
->request
;
1229 struct ldb_context
*samdb
= call
->conn
->ldb
;
1232 bool recheck_schema
= false;
1234 /* Check for undecoded critical extensions */
1235 for (i
=0; msg
->controls
&& msg
->controls
[i
]; i
++) {
1236 if (!msg
->controls_decoded
[i
] &&
1237 msg
->controls
[i
]->critical
) {
1238 DEBUG(3, ("ldapsrv_do_call: Critical extension %s is not known to this server\n",
1239 msg
->controls
[i
]->oid
));
1240 return ldapsrv_unwilling(call
, LDAP_UNAVAILABLE_CRITICAL_EXTENSION
);
1244 switch(call
->request
->type
) {
1245 case LDAP_TAG_BindRequest
:
1246 return ldapsrv_BindRequest(call
);
1247 case LDAP_TAG_UnbindRequest
:
1248 return ldapsrv_UnbindRequest(call
);
1249 case LDAP_TAG_SearchRequest
:
1250 return ldapsrv_SearchRequest(call
);
1251 case LDAP_TAG_ModifyRequest
:
1252 recheck_schema
= true;
1253 status
= ldapsrv_ModifyRequest(call
);
1255 case LDAP_TAG_AddRequest
:
1256 recheck_schema
= true;
1257 status
= ldapsrv_AddRequest(call
);
1259 case LDAP_TAG_DelRequest
:
1260 status
= ldapsrv_DelRequest(call
);
1262 case LDAP_TAG_ModifyDNRequest
:
1263 status
= ldapsrv_ModifyDNRequest(call
);
1265 case LDAP_TAG_CompareRequest
:
1266 return ldapsrv_CompareRequest(call
);
1267 case LDAP_TAG_AbandonRequest
:
1268 return ldapsrv_AbandonRequest(call
);
1269 case LDAP_TAG_ExtendedRequest
:
1270 status
= ldapsrv_ExtendedRequest(call
);
1273 return ldapsrv_unwilling(call
, LDAP_PROTOCOL_ERROR
);
1276 if (NT_STATUS_IS_OK(status
) && recheck_schema
) {
1277 lastts
= (time_t *)ldb_get_opaque(samdb
, DSDB_OPAQUE_LAST_SCHEMA_UPDATE_MSG_OPAQUE_NAME
);
1278 if (lastts
&& !*lastts
) {
1279 DEBUG(10, ("Schema update now was requested, "
1280 "fullfilling the request ts = %d\n",
1283 * Just requesting the schema will do the trick
1284 * as the delay for reload is experied, we will have a reload
1285 * from the schema as expected as we are not yet in a transaction!
1287 dsdb_get_schema(samdb
, NULL
);
1288 *lastts
= time(NULL
);
1289 ldb_set_opaque(samdb
, DSDB_OPAQUE_LAST_SCHEMA_UPDATE_MSG_OPAQUE_NAME
, lastts
);
1293 if (NT_STATUS_IS_OK(status
)) {
1294 ldapsrv_notification_retry_setup(call
->conn
->service
, true);