diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-12-17 02:19:56 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:29:23 -0500 |
commit | c5571c7c3964975d5c1f1c347b8629577d2e86c6 (patch) | |
tree | 82e9af9b07d55b8d09a9c520bbd90d045d121691 /source4 | |
parent | ff8ef6c280a7107ce521eee57df9218b4cac0465 (diff) | |
download | samba-c5571c7c3964975d5c1f1c347b8629577d2e86c6.tar.gz samba-c5571c7c3964975d5c1f1c347b8629577d2e86c6.tar.bz2 samba-c5571c7c3964975d5c1f1c347b8629577d2e86c6.zip |
r20221: - move the dsdb_schema, dsdb_attribute, dsdb_class structs into
a generic location
- this struct should be also used by the dsdb/samdb/ldb_modules/schema.c
module later
- add functions to map from LDAP OID values to uint32_t values
- add torture test for the OID => uint32 mapping code
metze
(This used to be commit 58ba6ec195ce3a5e2352866809f6cb57f8d8260a)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/dsdb/config.mk | 3 | ||||
-rw-r--r-- | source4/dsdb/samdb/samdb.h | 1 | ||||
-rw-r--r-- | source4/dsdb/schema/schema.h | 109 | ||||
-rw-r--r-- | source4/dsdb/schema/schema_init.c | 294 | ||||
-rw-r--r-- | source4/torture/ldap/schema.c | 267 |
5 files changed, 514 insertions, 160 deletions
diff --git a/source4/dsdb/config.mk b/source4/dsdb/config.mk index d31fe6d1df..c1beb4a67f 100644 --- a/source4/dsdb/config.mk +++ b/source4/dsdb/config.mk @@ -13,7 +13,8 @@ OBJ_FILES = \ samdb/samdb_privilege.o \ samdb/cracknames.o \ common/sidmap.o \ - common/flag_mapping.o + common/flag_mapping.o \ + schema/schema_init.o # # End SUBSYSTEM SAMDB ################################################ diff --git a/source4/dsdb/samdb/samdb.h b/source4/dsdb/samdb/samdb.h index 36bff2f7ff..f4c2b0382b 100644 --- a/source4/dsdb/samdb/samdb.h +++ b/source4/dsdb/samdb/samdb.h @@ -29,6 +29,7 @@ struct drsuapi_DsNameInfo1; #include "librpc/gen_ndr/security.h" #include "lib/ldb/include/ldb.h" #include "librpc/gen_ndr/samr.h" +#include "dsdb/schema/schema.h" #include "dsdb/samdb/samdb_proto.h" #endif /* __SAMDB_H__ */ diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h new file mode 100644 index 0000000000..e872a6088e --- /dev/null +++ b/source4/dsdb/schema/schema.h @@ -0,0 +1,109 @@ +/* + Unix SMB/CIFS mplementation. + DSDB schema header + + Copyright (C) Stefan Metzmacher 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef _DSDB_SCHEMA_H +#define _DSDB_SCHEMA_H + +struct dsdb_attribute { + struct dsdb_attribute *prev, *next; + + const char *cn; + const char *lDAPDisplayName; + const char *attributeID_oid; + uint32_t attributeID_id; + struct GUID schemaIDGUID; + uint32_t mAPIID; + + struct GUID attributeSecurityGUID; + + uint32_t searchFlags; + uint32_t systemFlags; + BOOL isMemberOfPartialAttributeSet; + uint32_t linkID; + + const char *attributeSyntax_oid; + uint32_t attributeSyntax_id; + uint32_t oMSyntax; + struct ldb_val oMObjectClass; + + BOOL isSingleValued; + uint32_t rangeLower; + uint32_t rangeUpper; + BOOL extendedCharsAllowed; + + uint32_t schemaFlagsEx; + struct ldb_val msDs_Schema_Extensions; + + BOOL showInAdvancedViewOnly; + const char *adminDisplayName; + const char *adminDescription; + const char *classDisplayName; + BOOL isEphemeral; + BOOL isDefunct; + BOOL systemOnly; +}; + +struct dsdb_class { + struct dsdb_class *prev, *next; + + const char *cn; + const char *lDAPDisplayName; + const char *governsID_oid; + uint32_t governsID_id; + struct GUID schemaIDGUID; + + uint32_t objectClassCategory; + const char *rDNAttID; + const char *defaultObjectCategory; + + const char *subClassOf; + + const char *systemAuxiliaryClass; + const char **systemPossSuperiors; + const char **systemMustContain; + const char **systemMayContain; + + const char *auxiliaryClass; + const char **possSuperiors; + const char **mustContain; + const char **mayContain; + + const char *defaultSecurityDescriptor; + + uint32_t schemaFlagsEx; + struct ldb_val msDs_Schema_Extensions; + + BOOL showInAdvancedViewOnly; + const char *adminDisplayName; + const char *adminDescription; + const char *classDisplayName; + BOOL defaultHidingValue; + BOOL isDefunct; + BOOL systemOnly; +}; + +struct dsdb_schema { + struct dsdb_attribute *attributes; + struct dsdb_class *classes; +}; + +#endif /* _DSDB_SCHEMA_H */ diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c new file mode 100644 index 0000000000..ab7d5b1706 --- /dev/null +++ b/source4/dsdb/schema/schema_init.c @@ -0,0 +1,294 @@ +/* + Unix SMB/CIFS mplementation. + DSDB schema header + + Copyright (C) Stefan Metzmacher 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "includes.h" +#include "dsdb/samdb/samdb.h" +#include "lib/util/dlinklist.h" + +#define _PREFIX(uint32, oid) {uint32,oid,sizeof(oid)} +static const struct { + uint32_t uint32; + const char *oid; + size_t oid_len; +} prefix_mappings[] = { + _PREFIX(0x00000000, "2.5.4."), + _PREFIX(0x00010000, "2.5.6."), + _PREFIX(0x00020000, "1.2.840.113556.1.2."), + _PREFIX(0x00030000, "1.2.840.113556.1.3."), + _PREFIX(0x00080000, "2.5.5."), + _PREFIX(0x00090000, "1.2.840.113556.1.4."), + _PREFIX(0x000A0000, "1.2.840.113556.1.5."), + _PREFIX(0x00140000, "2.16.840.1.113730.3."), + _PREFIX(0x00150000, "0.9.2342.19200300.100.1."), + _PREFIX(0x00160000, "2.16.840.1.113730.3.1."), + _PREFIX(0x00170000, "1.2.840.113556.1.5.7000."), + _PREFIX(0x001A0000, "2.5.20."), + _PREFIX(0x001C0000, "2.16.840.1.113730.3.2."), + _PREFIX(0x001D0000, "1.3.6.1.4.1.250.1."), + _PREFIX(0x001F0000, "0.9.2342.19200300.100.4."), +}; + +WERROR dsdb_map_oid2int(const char *in, uint32_t *out) +{ + uint32_t i; + + for (i=0; i < ARRAY_SIZE(prefix_mappings); i++) { + const char *val_str; + char *end_str; + unsigned val; + + if (strncmp(prefix_mappings[i].oid, in, prefix_mappings[i].oid_len - 1) != 0) { + continue; + } + + val_str = in + prefix_mappings[i].oid_len - 1; + end_str = NULL; + errno = 0; + + if (val_str[0] == '\0') { + return WERR_INVALID_PARAM; + } + + val = strtoul(val_str, &end_str, 10); + if (end_str[0] != '\0') { + return WERR_INVALID_PARAM; + } else if (val > 0xFFFF) { + return WERR_INVALID_PARAM; + } + + *out = prefix_mappings[i].uint32 | val; + return WERR_OK; + } + + return WERR_DS_NO_MSDS_INTID; +} + +WERROR dsdb_map_int2oid(uint32_t in, TALLOC_CTX *mem_ctx, const char **out) +{ + uint32_t i; + + for (i=0; i < ARRAY_SIZE(prefix_mappings); i++) { + const char *val; + if (prefix_mappings[i].uint32 != (in & 0xFFFF0000)) { + continue; + } + + val = talloc_asprintf(mem_ctx, "%s%u", + prefix_mappings[i].oid, + in & 0xFFFF); + W_ERROR_HAVE_NO_MEMORY(val); + + *out = val; + return WERR_OK; + } + + return WERR_DS_NO_MSDS_INTID; +} + +bool dsdb_map_test(void) +{ + bool ret = true; + WERROR status; + const char *oid; + uint32_t id; + + oid = "1.2.840.113556.1.4.1716"; + status = dsdb_map_oid2int(oid, &id); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("%s => %s\n", oid, win_errstr(status))); + ret = false; + } else { + DEBUG(0,("%s => 0x%08X\n", oid, id)); + } + + status = dsdb_map_int2oid(id, NULL, &oid); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("0x%08X => %s\n", id, win_errstr(status))); + ret = false; + } else { + DEBUG(0,("0x%08X => %s\n", id, oid)); + } + + oid = "1.2.840.113556.1.4.1716."; + status = dsdb_map_oid2int(oid, &id); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("%s => %s\n", oid, win_errstr(status))); + ret = false; + } else { + DEBUG(0,("%s => 0x%08X\n", oid, id)); + } + + oid = "5435.1.2.840.113556.1.4.1716."; + status = dsdb_map_oid2int(oid, &id); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("%s => %s\n", oid, win_errstr(status))); + ret = false; + } else { + DEBUG(0,("%s => 0x%08X\n", oid, id)); + } + + id = 0xEF001234; + status = dsdb_map_int2oid(id, NULL, &oid); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("0x%08X => %s\n", id, win_errstr(status))); + ret = false; + } else { + DEBUG(0,("0x%08X => %s\n", id, oid)); + } + + return ret; +} + +#define GET_STRING(p, elem, strict) do { \ + (p)->elem = samdb_result_string(msg, #elem, NULL);\ + if (strict && (p)->elem == NULL) { \ + d_printf("%s: %s == NULL\n", __location__, #elem); \ + return WERR_INVALID_PARAM; \ + } \ + (void)talloc_steal(p, (p)->elem); \ +} while (0) + +#define GET_BOOL(p, elem, strict) do { \ + const char *str; \ + str = samdb_result_string(msg, #elem, NULL);\ + if (str == NULL) { \ + if (strict) { \ + d_printf("%s: %s == NULL\n", __location__, #elem); \ + return WERR_INVALID_PARAM; \ + } else { \ + (p)->elem = False; \ + } \ + } else if (strcasecmp("TRUE", str) == 0) { \ + (p)->elem = True; \ + } else if (strcasecmp("FALSE", str) == 0) { \ + (p)->elem = False; \ + } else { \ + d_printf("%s: %s == %s\n", __location__, #elem, str); \ + return WERR_INVALID_PARAM; \ + } \ +} while (0) + +#define GET_UINT32(p, elem) do { \ + (p)->elem = samdb_result_uint(msg, #elem, 0);\ +} while (0) + +#define GET_GUID(p, elem) do { \ + (p)->elem = samdb_result_guid(msg, #elem);\ +} while (0) + +#define GET_BLOB(p, elem) do { \ + const struct ldb_val *_val;\ + _val = ldb_msg_find_ldb_val(msg, #elem);\ + if (_val) {\ + (p)->elem = *_val;\ + (void)talloc_steal(p, (p)->elem.data);\ + } else {\ + ZERO_STRUCT((p)->elem);\ + }\ +} while (0) + +WERROR dsdb_attribute_from_ldb(struct ldb_message *msg, TALLOC_CTX *mem_ctx, struct dsdb_attribute *attr) +{ + WERROR status; + + GET_STRING(attr, cn, True); + GET_STRING(attr, lDAPDisplayName, True); + GET_STRING(attr, attributeID_oid, True); + status = dsdb_map_oid2int(attr->attributeID_oid, &attr->attributeID_id); + W_ERROR_NOT_OK_RETURN(status); + GET_GUID(attr, schemaIDGUID); + GET_UINT32(attr, mAPIID); + + GET_GUID(attr, attributeSecurityGUID); + + GET_UINT32(attr, searchFlags); + GET_UINT32(attr, systemFlags); + GET_BOOL(attr, isMemberOfPartialAttributeSet, False); + GET_UINT32(attr, linkID); + + GET_STRING(attr, attributeSyntax_oid, True); + status = dsdb_map_oid2int(attr->attributeSyntax_oid, &attr->attributeSyntax_id); + W_ERROR_NOT_OK_RETURN(status); + GET_UINT32(attr, oMSyntax); + GET_BLOB(attr, oMObjectClass); + + GET_BOOL(attr, isSingleValued, True); + GET_UINT32(attr, rangeLower); + GET_UINT32(attr, rangeUpper); + GET_BOOL(attr, extendedCharsAllowed, False); + + GET_UINT32(attr, schemaFlagsEx); + GET_BLOB(attr, msDs_Schema_Extensions); + + GET_BOOL(attr, showInAdvancedViewOnly, False); + GET_STRING(attr, adminDisplayName, True); + GET_STRING(attr, adminDescription, True); + GET_STRING(attr, classDisplayName, True); + GET_BOOL(attr, isEphemeral, False); + GET_BOOL(attr, isDefunct, False); + GET_BOOL(attr, systemOnly, False); + + return WERR_OK; +} + +WERROR dsdb_class_from_ldb(struct ldb_message *msg, TALLOC_CTX *mem_ctx, struct dsdb_class *obj) +{ + WERROR status; + + GET_STRING(obj, cn, True); + GET_STRING(obj, lDAPDisplayName, True); + GET_STRING(obj, governsID_oid, True); + status = dsdb_map_oid2int(obj->governsID_oid, &obj->governsID_id); + W_ERROR_NOT_OK_RETURN(status); + GET_GUID(obj, schemaIDGUID); + + GET_UINT32(obj, objectClassCategory); + GET_STRING(obj, rDNAttID, True); + GET_STRING(obj, defaultObjectCategory, True); + + GET_STRING(obj, subClassOf, True); + + GET_STRING(obj, systemAuxiliaryClass, False); + obj->systemPossSuperiors= NULL; + obj->systemMustContain = NULL; + obj->systemMayContain = NULL; + + GET_STRING(obj, auxiliaryClass, False); + obj->possSuperiors = NULL; + obj->mustContain = NULL; + obj->mayContain = NULL; + + GET_STRING(obj, defaultSecurityDescriptor, False); + + GET_UINT32(obj, schemaFlagsEx); + GET_BLOB(obj, msDs_Schema_Extensions); + + GET_BOOL(obj, showInAdvancedViewOnly, False); + GET_STRING(obj, adminDisplayName, True); + GET_STRING(obj, adminDescription, True); + GET_STRING(obj, classDisplayName, True); + GET_BOOL(obj, defaultHidingValue, True); + GET_BOOL(obj, isDefunct, False); + GET_BOOL(obj, systemOnly, False); + + return WERR_OK; +} diff --git a/source4/torture/ldap/schema.c b/source4/torture/ldap/schema.c index 2ab0c5e116..60b27f6c72 100644 --- a/source4/torture/ldap/schema.c +++ b/source4/torture/ldap/schema.c @@ -32,69 +32,6 @@ #include "torture/torture.h" #include "torture/ldap/proto.h" -struct dsdb_attribute { - struct dsdb_attribute *prev, *next; - - const char *lDAPDisplayName; - const char *attributeID; - uint32_t attID; - struct GUID schemaIDGUID; - - uint32_t searchFlags; - BOOL systemOnly; - uint32_t systemFlags; - BOOL isMemberOfPartialAttributeSet; - - const char *attributeSyntax; - uint32_t oMSyntax; - - BOOL isSingleValued; - uint32_t rangeLower; - uint32_t rangeUpper; - - BOOL showInAdvancedViewOnly; - const char *adminDisplayName; - const char *adminDescription; -}; - -struct dsdb_objectClass { - struct dsdb_objectClass *prev, *next; - - const char *subClassOf; - - const char *governsID; - const char *rDNAttID; - - BOOL showInAdvancedViewOnly; - const char *adminDisplayName; - const char *adminDescription; - - uint32_t objectClassCategory; - const char *lDAPDisplayName; - - struct GUID schemaIDGUID; - - BOOL systemOnly; - - const char **systemPossSuperiors; - const char **systemMayContain; - - const char **possSuperiors; - const char **mayContain; - - const char *defaultSecurityDescriptor; - - uint32_t systemFlags; - BOOL defaultHidingValue; - - const char *defaultObjectCategory; -}; - -struct dsdb_schema { - struct dsdb_attribute *attributes; - struct dsdb_objectClass *objectClasses; -}; - struct test_rootDSE { const char *defaultdn; const char *rootdn; @@ -262,114 +199,46 @@ again: return True; } -#define GET_STRING(p, elem, strict) do { \ - (p)->elem = samdb_result_string(msg, #elem, NULL);\ - if (strict && (p)->elem == NULL) { \ - d_printf("%s: %s == NULL\n", __location__, #elem); \ - goto failed; \ - } \ - (void)talloc_steal(p, (p)->elem); \ -} while (0) - -#define GET_BOOL(p, elem, strict) do { \ - const char *str; \ - str = samdb_result_string(msg, #elem, NULL);\ - if (str == NULL) { \ - if (strict) { \ - d_printf("%s: %s == NULL\n", __location__, #elem); \ - goto failed; \ - } else { \ - (p)->elem = False; \ - } \ - } else if (strcasecmp("TRUE", str) == 0) { \ - (p)->elem = True; \ - } else if (strcasecmp("FALSE", str) == 0) { \ - (p)->elem = False; \ - } else { \ - d_printf("%s: %s == %s\n", __location__, #elem, str); \ - goto failed; \ - } \ -} while (0) - -#define GET_UINT32(p, elem) do { \ - (p)->elem = samdb_result_uint(msg, #elem, 0);\ -} while (0) - -#define GET_GUID(p, elem) do { \ - (p)->elem = samdb_result_guid(msg, #elem);\ -} while (0) - static int test_add_attribute(void *ptr, struct ldb_context *ldb, struct ldb_message *msg) { struct dsdb_schema *schema = talloc_get_type(ptr, struct dsdb_schema); - struct dsdb_attribute *attr; + struct dsdb_attribute *attr = NULL; + WERROR status; attr = talloc_zero(schema, struct dsdb_attribute); + if (!attr) { + goto failed; + } - GET_STRING(attr, lDAPDisplayName, True); - GET_STRING(attr, attributeID, True); - attr->attID = UINT32_MAX; - GET_GUID(attr, schemaIDGUID); - - GET_UINT32(attr, searchFlags); - GET_BOOL(attr, systemOnly, False); - GET_UINT32(attr, systemFlags); - GET_BOOL(attr, isMemberOfPartialAttributeSet, False); - - GET_STRING(attr, attributeSyntax, True); - GET_UINT32(attr, oMSyntax); - - GET_BOOL(attr, isSingleValued, True); - GET_UINT32(attr, rangeLower); - GET_UINT32(attr, rangeUpper); - - GET_BOOL(attr, showInAdvancedViewOnly, False); - GET_STRING(attr, adminDisplayName, True); - GET_STRING(attr, adminDescription, True); + status = dsdb_attribute_from_ldb(msg, attr, attr); + if (!W_ERROR_IS_OK(status)) { + goto failed; + } DLIST_ADD_END(schema->attributes, attr, struct dsdb_attribute *); return LDB_SUCCESS; failed: + talloc_free(attr); return LDB_ERR_OTHER; } static int test_add_class(void *ptr, struct ldb_context *ldb, struct ldb_message *msg) { struct dsdb_schema *schema = talloc_get_type(ptr, struct dsdb_schema); - struct dsdb_objectClass *obj; - - obj = talloc_zero(schema, struct dsdb_objectClass); - - GET_STRING(obj, subClassOf, True); - - GET_STRING(obj, governsID, True); - GET_STRING(obj, rDNAttID, True); + struct dsdb_class *obj; + WERROR status; - GET_BOOL(obj, showInAdvancedViewOnly, False); - GET_STRING(obj, adminDisplayName, True); - GET_STRING(obj, adminDescription, True); - - GET_UINT32(obj, objectClassCategory); - GET_STRING(obj, lDAPDisplayName, True); - - GET_GUID(obj, schemaIDGUID); - - GET_BOOL(obj, systemOnly, False); - - obj->systemPossSuperiors= NULL; - obj->systemMayContain = NULL; - - obj->possSuperiors = NULL; - obj->mayContain = NULL; - - GET_STRING(obj, defaultSecurityDescriptor, False); - - GET_UINT32(obj, systemFlags); - GET_BOOL(obj, defaultHidingValue, True); + obj = talloc_zero(schema, struct dsdb_class); + if (!obj) { + goto failed; + } - GET_STRING(obj, defaultObjectCategory, True); + status = dsdb_class_from_ldb(msg, obj, obj); + if (!W_ERROR_IS_OK(status)) { + goto failed; + } - DLIST_ADD_END(schema->objectClasses, obj, struct dsdb_objectClass *); + DLIST_ADD_END(schema->classes, obj, struct dsdb_class *); return LDB_SUCCESS; failed: return LDB_ERR_OTHER; @@ -472,9 +341,9 @@ static BOOL test_dump_sorted_syntax(struct ldb_context *ldb, struct test_rootDSE for (i=0; i < ARRAY_SIZE(syntaxes); i++) { for (a=schema->attributes; a; a = a->next) { - if (strcmp(syntaxes[i], a->attributeSyntax) != 0) continue; + if (strcmp(syntaxes[i], a->attributeSyntax_oid) != 0) continue; d_printf("attr[%4u]: %s %u '%s'\n", a_i++, - a->attributeSyntax, a->oMSyntax, + a->attributeSyntax_oid, a->oMSyntax, a->lDAPDisplayName); } } @@ -482,22 +351,101 @@ static BOOL test_dump_sorted_syntax(struct ldb_context *ldb, struct test_rootDSE return True; } + +static BOOL test_dsdb_map(struct torture_context *torture) +{ + BOOL ret = true; + WERROR status; + const char *oid; + uint32_t id; + + oid = "1.2.840.113556.1.4.1716"; + status = dsdb_map_oid2int(oid, &id); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("%s => %s\n", oid, win_errstr(status))); + ret = False; + } else { + DEBUG(0,("%s => 0x%08X\n", oid, id)); + } + + status = dsdb_map_int2oid(id, torture, &oid); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("0x%08X => %s\n", id, win_errstr(status))); + ret = False; + } else { + DEBUG(0,("0x%08X => %s\n", id, oid)); + } + + oid = "1.2.840.113556.1.4.65535"; + status = dsdb_map_oid2int(oid, &id); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("%s => %s\n", oid, win_errstr(status))); + ret = False; + } else { + DEBUG(0,("%s => 0x%08X\n", oid, id)); + } + + status = dsdb_map_int2oid(id, torture, &oid); + if (!W_ERROR_IS_OK(status)) { + DEBUG(0,("0x%08X => %s\n", id, win_errstr(status))); + ret = False; + } else { + DEBUG(0,("0x%08X => %s\n", id, oid)); + } + + oid = "1.2.840.113556.1.4.1716."; + status = dsdb_map_oid2int(oid, &id); + if (!W_ERROR_EQUAL(status, WERR_INVALID_PARAM)) { + DEBUG(0,("%s => %s\n", oid, win_errstr(status))); + ret = False; + } else { + DEBUG(0,("%s => %s (ok!)\n", oid, win_errstr(status))); + } + + oid = "1.2.840.113556.1.4.1716.65536"; + status = dsdb_map_oid2int(oid, &id); + if (!W_ERROR_EQUAL(status, WERR_INVALID_PARAM)) { + DEBUG(0,("%s => %s\n", oid, win_errstr(status))); + ret = False; + } else { + DEBUG(0,("%s => %s (ok!)\n", oid, win_errstr(status))); + } + + oid = "5435.1.2.840.113556.1.4.1716."; + status = dsdb_map_oid2int(oid, &id); + if (!W_ERROR_EQUAL(status, WERR_DS_NO_MSDS_INTID)) { + DEBUG(0,("%s => %s\n", oid, win_errstr(status))); + ret = False; + } else { + DEBUG(0,("%s => %s (ok!)\n", oid, win_errstr(status))); + } + + id = 0xEF001234; + status = dsdb_map_int2oid(id, torture, &oid); + if (!W_ERROR_EQUAL(status, WERR_DS_NO_MSDS_INTID)) { + DEBUG(0,("0x%08X => %s\n", id, win_errstr(status))); + ret = False; + } else { + DEBUG(0,("0x%08X => %s (ok!)\n", id, win_errstr(status))); + } + + return ret; +} + BOOL torture_ldap_schema(struct torture_context *torture) { struct ldb_context *ldb; - TALLOC_CTX *mem_ctx; BOOL ret = True; const char *host = torture_setting_string(torture, "host", NULL); char *url; struct test_rootDSE rootDSE; struct dsdb_schema *schema = NULL; - mem_ctx = talloc_init("torture_ldap_basic"); ZERO_STRUCT(rootDSE); - url = talloc_asprintf(mem_ctx, "ldap://%s/", host); + url = talloc_asprintf(torture, "ldap://%s/", host); - ldb = ldb_wrap_connect(mem_ctx, url, + ldb = ldb_wrap_connect(torture, url, NULL, cmdline_credentials, 0, NULL); @@ -513,7 +461,8 @@ BOOL torture_ldap_schema(struct torture_context *torture) ret &= test_dump_contructed(ldb, &rootDSE, schema); ret &= test_dump_sorted_syntax(ldb, &rootDSE, schema); + ret &= test_dsdb_map(torture); + failed: - talloc_free(mem_ctx); return ret; } |