2 ldb database library - ldif handlers for Samba
4 Copyright (C) Andrew Tridgell 2005
5 Copyright (C) Andrew Bartlett 2006-2007
6 Copyright (C) Matthias Dieter Wallnöfer 2009
7 ** NOTE! The following LGPL license applies to the ldb
8 ** library. This does NOT imply that all of Samba is released
11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Lesser General Public
13 License as published by the Free Software Foundation; either
14 version 3 of the License, or (at your option) any later version.
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Lesser General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public
22 License along with this library; if not, see <http://www.gnu.org/licenses/>.
26 #include "lib/ldb/include/ldb.h"
27 #include "lib/ldb/include/ldb_module.h"
28 #include "ldb_handlers.h"
29 #include "dsdb/samdb/samdb.h"
30 #include "librpc/gen_ndr/ndr_security.h"
31 #include "librpc/gen_ndr/ndr_misc.h"
32 #include "librpc/gen_ndr/ndr_drsblobs.h"
33 #include "libcli/security/security.h"
34 #include "param/param.h"
37 convert a ldif formatted objectSid to a NDR formatted blob
39 static int ldif_read_objectSid(struct ldb_context *ldb, void *mem_ctx,
40 const struct ldb_val *in, struct ldb_val *out)
42 enum ndr_err_code ndr_err;
44 sid = dom_sid_parse_length(mem_ctx, in);
48 ndr_err = ndr_push_struct_blob(out, mem_ctx, NULL, sid,
49 (ndr_push_flags_fn_t)ndr_push_dom_sid);
51 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
58 convert a NDR formatted blob to a ldif formatted objectSid
60 static int ldif_write_objectSid(struct ldb_context *ldb, void *mem_ctx,
61 const struct ldb_val *in, struct ldb_val *out)
64 enum ndr_err_code ndr_err;
66 sid = talloc(mem_ctx, struct dom_sid);
70 ndr_err = ndr_pull_struct_blob_all(in, sid, NULL, sid,
71 (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
72 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
76 *out = data_blob_string_const(dom_sid_string(mem_ctx, sid));
78 if (out->data == NULL) {
84 static bool ldif_comparision_objectSid_isString(const struct ldb_val *v)
90 if (strncmp("S-", (const char *)v->data, 2) != 0) return false;
96 compare two objectSids
98 static int ldif_comparison_objectSid(struct ldb_context *ldb, void *mem_ctx,
99 const struct ldb_val *v1, const struct ldb_val *v2)
101 if (ldif_comparision_objectSid_isString(v1) && ldif_comparision_objectSid_isString(v2)) {
102 return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
103 } else if (ldif_comparision_objectSid_isString(v1)
104 && !ldif_comparision_objectSid_isString(v2)) {
107 if (ldif_read_objectSid(ldb, mem_ctx, v1, &v) != 0) {
108 /* Perhaps not a string after all */
109 return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
111 ret = ldb_comparison_binary(ldb, mem_ctx, &v, v2);
114 } else if (!ldif_comparision_objectSid_isString(v1)
115 && ldif_comparision_objectSid_isString(v2)) {
118 if (ldif_read_objectSid(ldb, mem_ctx, v2, &v) != 0) {
119 /* Perhaps not a string after all */
120 return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
122 ret = ldb_comparison_binary(ldb, mem_ctx, v1, &v);
126 return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
130 canonicalise a objectSid
132 static int ldif_canonicalise_objectSid(struct ldb_context *ldb, void *mem_ctx,
133 const struct ldb_val *in, struct ldb_val *out)
135 if (ldif_comparision_objectSid_isString(in)) {
136 if (ldif_read_objectSid(ldb, mem_ctx, in, out) != 0) {
137 /* Perhaps not a string after all */
138 return ldb_handler_copy(ldb, mem_ctx, in, out);
142 return ldb_handler_copy(ldb, mem_ctx, in, out);
145 static int extended_dn_read_SID(struct ldb_context *ldb, void *mem_ctx,
146 const struct ldb_val *in, struct ldb_val *out)
149 enum ndr_err_code ndr_err;
150 if (ldif_comparision_objectSid_isString(in)) {
151 if (ldif_read_objectSid(ldb, mem_ctx, in, out) == 0) {
156 /* Perhaps not a string after all */
157 *out = data_blob_talloc(mem_ctx, NULL, in->length/2+1);
163 (*out).length = strhex_to_str((char *)out->data, out->length,
164 (const char *)in->data, in->length);
166 /* Check it looks like a SID */
167 ndr_err = ndr_pull_struct_blob_all(out, mem_ctx, NULL, &sid,
168 (ndr_pull_flags_fn_t)ndr_pull_dom_sid);
169 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
176 convert a ldif formatted objectGUID to a NDR formatted blob
178 static int ldif_read_objectGUID(struct ldb_context *ldb, void *mem_ctx,
179 const struct ldb_val *in, struct ldb_val *out)
183 enum ndr_err_code ndr_err;
185 status = GUID_from_data_blob(in, &guid);
186 if (!NT_STATUS_IS_OK(status)) {
190 ndr_err = ndr_push_struct_blob(out, mem_ctx, NULL, &guid,
191 (ndr_push_flags_fn_t)ndr_push_GUID);
192 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
199 convert a NDR formatted blob to a ldif formatted objectGUID
201 static int ldif_write_objectGUID(struct ldb_context *ldb, void *mem_ctx,
202 const struct ldb_val *in, struct ldb_val *out)
205 enum ndr_err_code ndr_err;
206 ndr_err = ndr_pull_struct_blob_all(in, mem_ctx, NULL, &guid,
207 (ndr_pull_flags_fn_t)ndr_pull_GUID);
208 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
211 out->data = (uint8_t *)GUID_string(mem_ctx, &guid);
212 if (out->data == NULL) {
215 out->length = strlen((const char *)out->data);
219 static bool ldif_comparision_objectGUID_isString(const struct ldb_val *v)
221 if (v->length != 36 && v->length != 38) return false;
223 /* Might be a GUID string, can't be a binary GUID (fixed 16 bytes) */
227 static int extended_dn_read_GUID(struct ldb_context *ldb, void *mem_ctx,
228 const struct ldb_val *in, struct ldb_val *out)
231 enum ndr_err_code ndr_err;
232 if (in->length == 36 && ldif_read_objectGUID(ldb, mem_ctx, in, out) == 0) {
236 /* Try as 'hex' form */
237 if (in->length != 32) {
241 *out = data_blob_talloc(mem_ctx, NULL, in->length/2+1);
247 (*out).length = strhex_to_str((char *)out->data, out->length,
248 (const char *)in->data, in->length);
250 /* Check it looks like a GUID */
251 ndr_err = ndr_pull_struct_blob_all(out, mem_ctx, NULL, &guid,
252 (ndr_pull_flags_fn_t)ndr_pull_GUID);
253 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
260 compare two objectGUIDs
262 static int ldif_comparison_objectGUID(struct ldb_context *ldb, void *mem_ctx,
263 const struct ldb_val *v1, const struct ldb_val *v2)
265 if (ldif_comparision_objectGUID_isString(v1) && ldif_comparision_objectGUID_isString(v2)) {
266 return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
267 } else if (ldif_comparision_objectGUID_isString(v1)
268 && !ldif_comparision_objectGUID_isString(v2)) {
271 if (ldif_read_objectGUID(ldb, mem_ctx, v1, &v) != 0) {
272 /* Perhaps it wasn't a valid string after all */
273 return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
275 ret = ldb_comparison_binary(ldb, mem_ctx, &v, v2);
278 } else if (!ldif_comparision_objectGUID_isString(v1)
279 && ldif_comparision_objectGUID_isString(v2)) {
282 if (ldif_read_objectGUID(ldb, mem_ctx, v2, &v) != 0) {
283 /* Perhaps it wasn't a valid string after all */
284 return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
286 ret = ldb_comparison_binary(ldb, mem_ctx, v1, &v);
290 return ldb_comparison_binary(ldb, mem_ctx, v1, v2);
294 canonicalise a objectGUID
296 static int ldif_canonicalise_objectGUID(struct ldb_context *ldb, void *mem_ctx,
297 const struct ldb_val *in, struct ldb_val *out)
299 if (ldif_comparision_objectGUID_isString(in)) {
300 if (ldif_read_objectGUID(ldb, mem_ctx, in, out) != 0) {
301 /* Perhaps it wasn't a valid string after all */
302 return ldb_handler_copy(ldb, mem_ctx, in, out);
306 return ldb_handler_copy(ldb, mem_ctx, in, out);
311 convert a ldif (SDDL) formatted ntSecurityDescriptor to a NDR formatted blob
313 static int ldif_read_ntSecurityDescriptor(struct ldb_context *ldb, void *mem_ctx,
314 const struct ldb_val *in, struct ldb_val *out)
316 struct security_descriptor *sd;
318 enum ndr_err_code ndr_err;
320 sd = talloc(mem_ctx, struct security_descriptor);
325 ndr_err = ndr_pull_struct_blob(in, sd, NULL, sd,
326 (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
327 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
328 /* If this does not parse, then it is probably SDDL, and we should try it that way */
330 const struct dom_sid *sid = samdb_domain_sid(ldb);
332 sd = sddl_decode(mem_ctx, (const char *)in->data, sid);
338 ndr_err = ndr_push_struct_blob(out, mem_ctx, NULL, sd,
339 (ndr_push_flags_fn_t)ndr_push_security_descriptor);
341 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
349 convert a NDR formatted blob to a ldif formatted ntSecurityDescriptor (SDDL format)
351 static int ldif_write_ntSecurityDescriptor(struct ldb_context *ldb, void *mem_ctx,
352 const struct ldb_val *in, struct ldb_val *out)
354 struct security_descriptor *sd;
355 enum ndr_err_code ndr_err;
357 sd = talloc(mem_ctx, struct security_descriptor);
361 /* We can't use ndr_pull_struct_blob_all because this contains relative pointers */
362 ndr_err = ndr_pull_struct_blob(in, sd, NULL, sd,
363 (ndr_pull_flags_fn_t)ndr_pull_security_descriptor);
364 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
368 out->data = (uint8_t *)sddl_encode(mem_ctx, sd, NULL);
370 if (out->data == NULL) {
373 out->length = strlen((const char *)out->data);
378 canonicalise an objectCategory. We use the short form as the cannoical form:
379 cn=Person,cn=Schema,cn=Configuration,<basedn> becomes 'person'
382 static int ldif_canonicalise_objectCategory(struct ldb_context *ldb, void *mem_ctx,
383 const struct ldb_val *in, struct ldb_val *out)
385 struct ldb_dn *dn1 = NULL;
386 const struct dsdb_schema *schema = dsdb_get_schema(ldb);
387 const struct dsdb_class *sclass;
388 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
390 return LDB_ERR_OPERATIONS_ERROR;
394 *out = data_blob_talloc(mem_ctx, in->data, in->length);
395 if (in->data && !out->data) {
396 return LDB_ERR_OPERATIONS_ERROR;
400 dn1 = ldb_dn_from_ldb_val(tmp_ctx, ldb, in);
401 if ( ! ldb_dn_validate(dn1)) {
402 const char *lDAPDisplayName = talloc_strndup(tmp_ctx, (char *)in->data, in->length);
403 sclass = dsdb_class_by_lDAPDisplayName(schema, lDAPDisplayName);
405 struct ldb_dn *dn = ldb_dn_new(mem_ctx, ldb,
406 sclass->defaultObjectCategory);
407 *out = data_blob_string_const(ldb_dn_alloc_casefold(mem_ctx, dn));
408 talloc_free(tmp_ctx);
411 return LDB_ERR_OPERATIONS_ERROR;
415 *out = data_blob_talloc(mem_ctx, in->data, in->length);
416 talloc_free(tmp_ctx);
418 if (in->data && !out->data) {
419 return LDB_ERR_OPERATIONS_ERROR;
424 *out = data_blob_string_const(ldb_dn_alloc_casefold(mem_ctx, dn1));
425 talloc_free(tmp_ctx);
428 return LDB_ERR_OPERATIONS_ERROR;
433 static int ldif_comparison_objectCategory(struct ldb_context *ldb, void *mem_ctx,
434 const struct ldb_val *v1,
435 const struct ldb_val *v2)
439 struct ldb_val v1_canon, v2_canon;
440 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
442 /* I could try and bail if tmp_ctx was NULL, but what return
445 * It seems easier to continue on the NULL context
447 ret1 = ldif_canonicalise_objectCategory(ldb, tmp_ctx, v1, &v1_canon);
448 ret2 = ldif_canonicalise_objectCategory(ldb, tmp_ctx, v2, &v2_canon);
450 if (ret1 == LDB_SUCCESS && ret2 == LDB_SUCCESS) {
451 ret = data_blob_cmp(&v1_canon, &v2_canon);
453 ret = data_blob_cmp(v1, v2);
455 talloc_free(tmp_ctx);
460 convert a ldif formatted prefixMap to a NDR formatted blob
462 static int ldif_read_prefixMap(struct ldb_context *ldb, void *mem_ctx,
463 const struct ldb_val *in, struct ldb_val *out)
465 struct prefixMapBlob *blob;
466 enum ndr_err_code ndr_err;
467 char *string, *line, *p, *oid;
469 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
471 if (tmp_ctx == NULL) {
475 blob = talloc_zero(tmp_ctx, struct prefixMapBlob);
481 blob->version = PREFIX_MAP_VERSION_DSDB;
483 string = talloc_strndup(mem_ctx, (const char *)in->data, in->length);
484 if (string == NULL) {
490 while (line && line[0]) {
495 p=strchr(line, '\n');
500 /* allow a traling seperator */
505 blob->ctr.dsdb.mappings = talloc_realloc(blob,
506 blob->ctr.dsdb.mappings,
507 struct drsuapi_DsReplicaOIDMapping,
508 blob->ctr.dsdb.num_mappings+1);
509 if (!blob->ctr.dsdb.mappings) {
510 talloc_free(tmp_ctx);
514 blob->ctr.dsdb.mappings[blob->ctr.dsdb.num_mappings].id_prefix = strtoul(line, &oid, 10);
517 talloc_free(tmp_ctx);
521 /* we know there must be at least ":" */
524 blob->ctr.dsdb.mappings[blob->ctr.dsdb.num_mappings].oid.oid
525 = talloc_strdup(blob->ctr.dsdb.mappings, oid);
527 blob->ctr.dsdb.num_mappings++;
529 /* Now look past the terminator we added above */
537 ndr_err = ndr_push_struct_blob(out, mem_ctx,
538 lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
540 (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
541 talloc_free(tmp_ctx);
542 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
549 convert a NDR formatted blob to a ldif formatted prefixMap
551 static int ldif_write_prefixMap(struct ldb_context *ldb, void *mem_ctx,
552 const struct ldb_val *in, struct ldb_val *out)
554 struct prefixMapBlob *blob;
555 enum ndr_err_code ndr_err;
559 blob = talloc(mem_ctx, struct prefixMapBlob);
563 ndr_err = ndr_pull_struct_blob_all(in, blob,
564 lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
566 (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
567 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
571 if (blob->version != PREFIX_MAP_VERSION_DSDB) {
574 string = talloc_strdup(mem_ctx, "");
575 if (string == NULL) {
579 for (i=0; i < blob->ctr.dsdb.num_mappings; i++) {
581 string = talloc_asprintf_append(string, ";");
583 string = talloc_asprintf_append(string, "%u:%s",
584 blob->ctr.dsdb.mappings[i].id_prefix,
585 blob->ctr.dsdb.mappings[i].oid.oid);
586 if (string == NULL) {
592 *out = data_blob_string_const(string);
596 static bool ldif_comparision_prefixMap_isString(const struct ldb_val *v)
602 if (IVAL(v->data, 0) == PREFIX_MAP_VERSION_DSDB) {
610 canonicalise a prefixMap
612 static int ldif_canonicalise_prefixMap(struct ldb_context *ldb, void *mem_ctx,
613 const struct ldb_val *in, struct ldb_val *out)
615 if (ldif_comparision_prefixMap_isString(in)) {
616 return ldif_read_prefixMap(ldb, mem_ctx, in, out);
618 return ldb_handler_copy(ldb, mem_ctx, in, out);
621 static int ldif_comparison_prefixMap(struct ldb_context *ldb, void *mem_ctx,
622 const struct ldb_val *v1,
623 const struct ldb_val *v2)
627 struct ldb_val v1_canon, v2_canon;
628 TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
630 /* I could try and bail if tmp_ctx was NULL, but what return
633 * It seems easier to continue on the NULL context
635 ret1 = ldif_canonicalise_prefixMap(ldb, tmp_ctx, v1, &v1_canon);
636 ret2 = ldif_canonicalise_prefixMap(ldb, tmp_ctx, v2, &v2_canon);
638 if (ret1 == LDB_SUCCESS && ret2 == LDB_SUCCESS) {
639 ret = data_blob_cmp(&v1_canon, &v2_canon);
641 ret = data_blob_cmp(v1, v2);
643 talloc_free(tmp_ctx);
647 /* Canonicalisation of two 32-bit integers */
648 static int ldif_canonicalise_int32(struct ldb_context *ldb, void *mem_ctx,
649 const struct ldb_val *in, struct ldb_val *out)
652 /* We've to use "strtoll" here to have the intended overflows.
653 * Otherwise we may get "LONG_MAX" and the conversion is wrong. */
654 int32_t i = (int32_t) strtoll((char *)in->data, &end, 0);
658 out->data = (uint8_t *) talloc_asprintf(mem_ctx, "%d", i);
659 if (out->data == NULL) {
662 out->length = strlen((char *)out->data);
666 /* Comparison of two 32-bit integers */
667 static int ldif_comparison_int32(struct ldb_context *ldb, void *mem_ctx,
668 const struct ldb_val *v1, const struct ldb_val *v2)
670 /* We've to use "strtoll" here to have the intended overflows.
671 * Otherwise we may get "LONG_MAX" and the conversion is wrong. */
672 return (int32_t) strtoll((char *)v1->data, NULL, 0)
673 - (int32_t) strtoll((char *)v2->data, NULL, 0);
676 static int extended_dn_write_hex(struct ldb_context *ldb, void *mem_ctx,
677 const struct ldb_val *in, struct ldb_val *out)
679 *out = data_blob_string_const(data_blob_hex_string(mem_ctx, in));
686 static const struct ldb_schema_syntax samba_syntaxes[] = {
688 .name = LDB_SYNTAX_SAMBA_SID,
689 .ldif_read_fn = ldif_read_objectSid,
690 .ldif_write_fn = ldif_write_objectSid,
691 .canonicalise_fn = ldif_canonicalise_objectSid,
692 .comparison_fn = ldif_comparison_objectSid
694 .name = LDB_SYNTAX_SAMBA_SECURITY_DESCRIPTOR,
695 .ldif_read_fn = ldif_read_ntSecurityDescriptor,
696 .ldif_write_fn = ldif_write_ntSecurityDescriptor,
697 .canonicalise_fn = ldb_handler_copy,
698 .comparison_fn = ldb_comparison_binary
700 .name = LDB_SYNTAX_SAMBA_GUID,
701 .ldif_read_fn = ldif_read_objectGUID,
702 .ldif_write_fn = ldif_write_objectGUID,
703 .canonicalise_fn = ldif_canonicalise_objectGUID,
704 .comparison_fn = ldif_comparison_objectGUID
706 .name = LDB_SYNTAX_SAMBA_OBJECT_CATEGORY,
707 .ldif_read_fn = ldb_handler_copy,
708 .ldif_write_fn = ldb_handler_copy,
709 .canonicalise_fn = ldif_canonicalise_objectCategory,
710 .comparison_fn = ldif_comparison_objectCategory
712 .name = LDB_SYNTAX_SAMBA_PREFIX_MAP,
713 .ldif_read_fn = ldif_read_prefixMap,
714 .ldif_write_fn = ldif_write_prefixMap,
715 .canonicalise_fn = ldif_canonicalise_prefixMap,
716 .comparison_fn = ldif_comparison_prefixMap
718 .name = LDB_SYNTAX_SAMBA_INT32,
719 .ldif_read_fn = ldb_handler_copy,
720 .ldif_write_fn = ldb_handler_copy,
721 .canonicalise_fn = ldif_canonicalise_int32,
722 .comparison_fn = ldif_comparison_int32
726 static const struct ldb_dn_extended_syntax samba_dn_syntax[] = {
729 .read_fn = extended_dn_read_SID,
730 .write_clear_fn = ldif_write_objectSid,
731 .write_hex_fn = extended_dn_write_hex
734 .read_fn = extended_dn_read_GUID,
735 .write_clear_fn = ldif_write_objectGUID,
736 .write_hex_fn = extended_dn_write_hex
739 .read_fn = ldb_handler_copy,
740 .write_clear_fn = ldb_handler_copy,
741 .write_hex_fn = ldb_handler_copy
745 /* TODO: Should be dynamic at some point */
746 static const struct {
749 } samba_attributes[] = {
750 { "objectSid", LDB_SYNTAX_SAMBA_SID },
751 { "securityIdentifier", LDB_SYNTAX_SAMBA_SID },
752 { "ntSecurityDescriptor", LDB_SYNTAX_SAMBA_SECURITY_DESCRIPTOR },
753 { "objectGUID", LDB_SYNTAX_SAMBA_GUID },
754 { "invocationId", LDB_SYNTAX_SAMBA_GUID },
755 { "schemaIDGUID", LDB_SYNTAX_SAMBA_GUID },
756 { "attributeSecurityGUID", LDB_SYNTAX_SAMBA_GUID },
757 { "parentGUID", LDB_SYNTAX_SAMBA_GUID },
758 { "siteGUID", LDB_SYNTAX_SAMBA_GUID },
759 { "pKTGUID", LDB_SYNTAX_SAMBA_GUID },
760 { "fRSVersionGUID", LDB_SYNTAX_SAMBA_GUID },
761 { "fRSReplicaSetGUID", LDB_SYNTAX_SAMBA_GUID },
762 { "netbootGUID", LDB_SYNTAX_SAMBA_GUID },
763 { "objectCategory", LDB_SYNTAX_SAMBA_OBJECT_CATEGORY },
764 { "prefixMap", LDB_SYNTAX_SAMBA_PREFIX_MAP }
767 const struct ldb_schema_syntax *ldb_samba_syntax_by_name(struct ldb_context *ldb, const char *name)
770 const struct ldb_schema_syntax *s = NULL;
772 for (j=0; j < ARRAY_SIZE(samba_syntaxes); j++) {
773 if (strcmp(name, samba_syntaxes[j].name) == 0) {
774 s = &samba_syntaxes[j];
781 const struct ldb_schema_syntax *ldb_samba_syntax_by_lDAPDisplayName(struct ldb_context *ldb, const char *name)
784 const struct ldb_schema_syntax *s = NULL;
786 for (j=0; j < ARRAY_SIZE(samba_attributes); j++) {
787 if (strcmp(samba_attributes[j].name, name) == 0) {
788 s = ldb_samba_syntax_by_name(ldb, samba_attributes[j].syntax);
797 register the samba ldif handlers
799 int ldb_register_samba_handlers(struct ldb_context *ldb)
803 for (i=0; i < ARRAY_SIZE(samba_attributes); i++) {
805 const struct ldb_schema_syntax *s = NULL;
807 s = ldb_samba_syntax_by_name(ldb, samba_attributes[i].syntax);
810 s = ldb_standard_syntax_by_name(ldb, samba_attributes[i].syntax);
817 ret = ldb_schema_attribute_add_with_syntax(ldb, samba_attributes[i].name, LDB_ATTR_FLAG_FIXED, s);
818 if (ret != LDB_SUCCESS) {
823 for (i=0; i < ARRAY_SIZE(samba_dn_syntax); i++) {
825 ret = ldb_dn_extended_add_syntax(ldb, LDB_ATTR_FLAG_FIXED, &samba_dn_syntax[i]);
826 if (ret != LDB_SUCCESS) {