DSDB schema header
Copyright (C) Stefan Metzmacher <metze@samba.org> 2006
-
+ Copyright (C) Andrew Bartlett <abartlet@samba.org> 2007
+
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
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
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.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "librpc/gen_ndr/ndr_misc.h"
#include "librpc/gen_ndr/ndr_drsuapi.h"
#include "librpc/gen_ndr/ndr_drsblobs.h"
+#include "param/param.h"
WERROR dsdb_load_oid_mappings_drsuapi(struct dsdb_schema *schema, const struct drsuapi_DsReplicaOIDMapping_Ctr *ctr)
{
const struct ldb_val *schemaInfo)
{
WERROR status;
- NTSTATUS nt_status;
+ enum ndr_err_code ndr_err;
struct prefixMapBlob pfm;
char *schema_info;
- nt_status = ndr_pull_struct_blob(prefixMap, schema, &pfm,
- (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
- if (!NT_STATUS_IS_OK(nt_status)) {
+ TALLOC_CTX *mem_ctx = talloc_new(schema);
+ W_ERROR_HAVE_NO_MEMORY(mem_ctx);
+
+ ndr_err = ndr_pull_struct_blob(prefixMap, mem_ctx, lp_iconv_convenience(global_loadparm), &pfm,
+ (ndr_pull_flags_fn_t)ndr_pull_prefixMapBlob);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
+ talloc_free(mem_ctx);
return ntstatus_to_werror(nt_status);
}
if (pfm.version != PREFIX_MAP_VERSION_DSDB) {
+ talloc_free(mem_ctx);
return WERR_FOOBAR;
}
if (schemaInfo->length != 21 && schemaInfo->data[0] == 0xFF) {
+ talloc_free(mem_ctx);
return WERR_FOOBAR;
}
/* append the schema info as last element */
pfm.ctr.dsdb.num_mappings++;
- pfm.ctr.dsdb.mappings = talloc_realloc(schema, pfm.ctr.dsdb.mappings,
+ pfm.ctr.dsdb.mappings = talloc_realloc(mem_ctx, pfm.ctr.dsdb.mappings,
struct drsuapi_DsReplicaOIDMapping,
pfm.ctr.dsdb.num_mappings);
W_ERROR_HAVE_NO_MEMORY(pfm.ctr.dsdb.mappings);
/* call the drsuapi version */
status = dsdb_load_oid_mappings_drsuapi(schema, &pfm.ctr.dsdb);
- talloc_free(pfm.ctr.dsdb.mappings);
+ talloc_free(mem_ctx);
+
W_ERROR_NOT_OK_RETURN(status);
return WERR_OK;
struct ldb_val *schemaInfo)
{
WERROR status;
- NTSTATUS nt_status;
+ enum ndr_err_code ndr_err;
struct drsuapi_DsReplicaOIDMapping_Ctr *ctr;
struct prefixMapBlob pfm;
pfm.reserved = 0;
pfm.ctr.dsdb = *ctr;
- nt_status = ndr_push_struct_blob(prefixMap, mem_ctx, &pfm,
- (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
+ ndr_err = ndr_push_struct_blob(prefixMap, mem_ctx, lp_iconv_convenience(global_loadparm), &pfm,
+ (ndr_push_flags_fn_t)ndr_push_prefixMapBlob);
talloc_free(ctr);
- if (!NT_STATUS_IS_OK(nt_status)) {
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ NTSTATUS nt_status = ndr_map_error2ntstatus(ndr_err);
return ntstatus_to_werror(nt_status);
}
d_printf("%s: %s == NULL\n", __location__, attr); \
return WERR_INVALID_PARAM; \
} else { \
- (p)->elem = False; \
+ (p)->elem = false; \
} \
} else if (strcasecmp("TRUE", str) == 0) { \
- (p)->elem = True; \
+ (p)->elem = true; \
} else if (strcasecmp("FALSE", str) == 0) { \
- (p)->elem = False; \
+ (p)->elem = false; \
} else { \
d_printf("%s: %s == %s\n", __location__, attr, str); \
return WERR_INVALID_PARAM; \
{
WERROR status;
- GET_STRING_LDB(msg, "cn", mem_ctx, attr, cn, False);
- GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, True);
- GET_STRING_LDB(msg, "attributeID", mem_ctx, attr, attributeID_oid, True);
+ GET_STRING_LDB(msg, "cn", mem_ctx, attr, cn, false);
+ GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, true);
+ GET_STRING_LDB(msg, "attributeID", mem_ctx, attr, attributeID_oid, true);
if (schema->num_prefixes == 0) {
/* set an invalid value */
attr->attributeID_id = 0xFFFFFFFF;
GET_UINT32_LDB(msg, "searchFlags", attr, searchFlags);
GET_UINT32_LDB(msg, "systemFlags", attr, systemFlags);
- GET_BOOL_LDB(msg, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, False);
+ GET_BOOL_LDB(msg, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, false);
GET_UINT32_LDB(msg, "linkID", attr, linkID);
- GET_STRING_LDB(msg, "attributeSyntax", mem_ctx, attr, attributeSyntax_oid, True);
+ GET_STRING_LDB(msg, "attributeSyntax", mem_ctx, attr, attributeSyntax_oid, true);
if (schema->num_prefixes == 0) {
/* set an invalid value */
attr->attributeSyntax_id = 0xFFFFFFFF;
GET_UINT32_LDB(msg, "oMSyntax", attr, oMSyntax);
GET_BLOB_LDB(msg, "oMObjectClass", mem_ctx, attr, oMObjectClass);
- GET_BOOL_LDB(msg, "isSingleValued", attr, isSingleValued, True);
+ GET_BOOL_LDB(msg, "isSingleValued", attr, isSingleValued, true);
GET_UINT32_LDB(msg, "rangeLower", attr, rangeLower);
GET_UINT32_LDB(msg, "rangeUpper", attr, rangeUpper);
- GET_BOOL_LDB(msg, "extendedCharsAllowed", attr, extendedCharsAllowed, False);
+ GET_BOOL_LDB(msg, "extendedCharsAllowed", attr, extendedCharsAllowed, false);
GET_UINT32_LDB(msg, "schemaFlagsEx", attr, schemaFlagsEx);
GET_BLOB_LDB(msg, "msDs-Schema-Extensions", mem_ctx, attr, msDs_Schema_Extensions);
- GET_BOOL_LDB(msg, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, False);
- GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, attr, adminDisplayName, False);
- GET_STRING_LDB(msg, "adminDescription", mem_ctx, attr, adminDescription, False);
- GET_STRING_LDB(msg, "classDisplayName", mem_ctx, attr, classDisplayName, False);
- GET_BOOL_LDB(msg, "isEphemeral", attr, isEphemeral, False);
- GET_BOOL_LDB(msg, "isDefunct", attr, isDefunct, False);
- GET_BOOL_LDB(msg, "systemOnly", attr, systemOnly, False);
+ GET_BOOL_LDB(msg, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, false);
+ GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, attr, adminDisplayName, false);
+ GET_STRING_LDB(msg, "adminDescription", mem_ctx, attr, adminDescription, false);
+ GET_STRING_LDB(msg, "classDisplayName", mem_ctx, attr, classDisplayName, false);
+ GET_BOOL_LDB(msg, "isEphemeral", attr, isEphemeral, false);
+ GET_BOOL_LDB(msg, "isDefunct", attr, isDefunct, false);
+ GET_BOOL_LDB(msg, "systemOnly", attr, systemOnly, false);
attr->syntax = dsdb_syntax_for_attribute(attr);
if (!attr->syntax) {
{
WERROR status;
- GET_STRING_LDB(msg, "cn", mem_ctx, obj, cn, False);
- GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, True);
- GET_STRING_LDB(msg, "governsID", mem_ctx, obj, governsID_oid, True);
+ GET_STRING_LDB(msg, "cn", mem_ctx, obj, cn, false);
+ GET_STRING_LDB(msg, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, true);
+ GET_STRING_LDB(msg, "governsID", mem_ctx, obj, governsID_oid, true);
if (schema->num_prefixes == 0) {
/* set an invalid value */
obj->governsID_id = 0xFFFFFFFF;
GET_GUID_LDB(msg, "schemaIDGUID", obj, schemaIDGUID);
GET_UINT32_LDB(msg, "objectClassCategory", obj, objectClassCategory);
- GET_STRING_LDB(msg, "rDNAttID", mem_ctx, obj, rDNAttID, False);
- GET_STRING_LDB(msg, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, True);
+ GET_STRING_LDB(msg, "rDNAttID", mem_ctx, obj, rDNAttID, false);
+ GET_STRING_LDB(msg, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, true);
- GET_STRING_LDB(msg, "subClassOf", mem_ctx, obj, subClassOf, True);
+ GET_STRING_LDB(msg, "subClassOf", mem_ctx, obj, subClassOf, true);
obj->systemAuxiliaryClass = NULL;
- obj->systemPossSuperiors = NULL;
obj->auxiliaryClass = NULL;
- obj->possSuperiors = NULL;
- GET_STRING_LIST_LDB(msg, "systemMustContain", mem_ctx, obj, systemMustContain, False);
- GET_STRING_LIST_LDB(msg, "systemMayContain", mem_ctx, obj, systemMayContain, False);
- GET_STRING_LIST_LDB(msg, "mustContain", mem_ctx, obj, mustContain, False);
- GET_STRING_LIST_LDB(msg, "mayContain", mem_ctx, obj, mayContain, False);
+ GET_STRING_LIST_LDB(msg, "systemMustContain", mem_ctx, obj, systemMustContain, false);
+ GET_STRING_LIST_LDB(msg, "systemMayContain", mem_ctx, obj, systemMayContain, false);
+ GET_STRING_LIST_LDB(msg, "mustContain", mem_ctx, obj, mustContain, false);
+ GET_STRING_LIST_LDB(msg, "mayContain", mem_ctx, obj, mayContain, false);
+
+ GET_STRING_LIST_LDB(msg, "systemPossSuperiors", mem_ctx, obj, systemPossSuperiors, false);
+ GET_STRING_LIST_LDB(msg, "possSuperiors", mem_ctx, obj, possSuperiors, false);
+ GET_STRING_LIST_LDB(msg, "possibleInferiors", mem_ctx, obj, possibleInferiors, false);
- GET_STRING_LDB(msg, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, False);
+ GET_STRING_LDB(msg, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false);
GET_UINT32_LDB(msg, "schemaFlagsEx", obj, schemaFlagsEx);
GET_BLOB_LDB(msg, "msDs-Schema-Extensions", mem_ctx, obj, msDs_Schema_Extensions);
- GET_BOOL_LDB(msg, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, False);
- GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, obj, adminDisplayName, False);
- GET_STRING_LDB(msg, "adminDescription", mem_ctx, obj, adminDescription, False);
- GET_STRING_LDB(msg, "classDisplayName", mem_ctx, obj, classDisplayName, False);
- GET_BOOL_LDB(msg, "defaultHidingValue", obj, defaultHidingValue, False);
- GET_BOOL_LDB(msg, "isDefunct", obj, isDefunct, False);
- GET_BOOL_LDB(msg, "systemOnly", obj, systemOnly, False);
+ GET_BOOL_LDB(msg, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, false);
+ GET_STRING_LDB(msg, "adminDisplayName", mem_ctx, obj, adminDisplayName, false);
+ GET_STRING_LDB(msg, "adminDescription", mem_ctx, obj, adminDescription, false);
+ GET_STRING_LDB(msg, "classDisplayName", mem_ctx, obj, classDisplayName, false);
+ GET_BOOL_LDB(msg, "defaultHidingValue", obj, defaultHidingValue, false);
+ GET_BOOL_LDB(msg, "isDefunct", obj, isDefunct, false);
+ GET_BOOL_LDB(msg, "systemOnly", obj, systemOnly, false);
return WERR_OK;
}
} \
if (_a && _a->value_ctr.num_values >= 1) { \
ssize_t _ret; \
- _ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, \
+ _ret = convert_string_talloc(mem_ctx, lp_iconv_convenience(global_loadparm), CH_UTF16, CH_UNIX, \
_a->value_ctr.values[0].blob->data, \
_a->value_ctr.values[0].blob->length, \
(void **)discard_const(&(p)->elem)); \
if (_a && _a->value_ctr.num_values >= 1 \
&& _a->value_ctr.values[0].blob) { \
struct drsuapi_DsReplicaObjectIdentifier3 _id3; \
- NTSTATUS _nt_status; \
- _nt_status = ndr_pull_struct_blob_all(_a->value_ctr.values[0].blob, \
- mem_ctx, &_id3,\
+ enum ndr_err_code _ndr_err; \
+ _ndr_err = ndr_pull_struct_blob_all(_a->value_ctr.values[0].blob, \
+ mem_ctx, lp_iconv_convenience(global_loadparm), &_id3,\
(ndr_pull_flags_fn_t)ndr_pull_drsuapi_DsReplicaObjectIdentifier3);\
- if (!NT_STATUS_IS_OK(_nt_status)) { \
+ if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
+ NTSTATUS _nt_status = ndr_map_error2ntstatus(_ndr_err); \
return ntstatus_to_werror(_nt_status); \
} \
(p)->elem = _id3.dn; \
} \
if (strict && _a->value_ctr.num_values != 1) { \
d_printf("%s: %s num_values == %u\n", __location__, attr, \
- _a->value_ctr.num_values); \
+ (unsigned int)_a->value_ctr.num_values); \
return WERR_INVALID_PARAM; \
} \
if (strict && !_a->value_ctr.values[0].blob) { \
} \
if (strict && _a->value_ctr.values[0].blob->length != 4) { \
d_printf("%s: %s length == %u\n", __location__, attr, \
- _a->value_ctr.values[0].blob->length); \
+ (unsigned int)_a->value_ctr.values[0].blob->length); \
return WERR_INVALID_PARAM; \
} \
if (_a && _a->value_ctr.num_values >= 1 \
&& _a->value_ctr.values[0].blob \
&& _a->value_ctr.values[0].blob->length == 4) { \
- (p)->elem = (IVAL(_a->value_ctr.values[0].blob->data,0)?True:False);\
+ (p)->elem = (IVAL(_a->value_ctr.values[0].blob->data,0)?true:false);\
} else { \
- (p)->elem = False; \
+ (p)->elem = false; \
} \
} while (0)
if (_a && _a->value_ctr.num_values >= 1 \
&& _a->value_ctr.values[0].blob \
&& _a->value_ctr.values[0].blob->length == 16) { \
- NTSTATUS _nt_status; \
- _nt_status = ndr_pull_struct_blob_all(_a->value_ctr.values[0].blob, \
- mem_ctx, &(p)->elem, \
+ enum ndr_err_code _ndr_err; \
+ _ndr_err = ndr_pull_struct_blob_all(_a->value_ctr.values[0].blob, \
+ mem_ctx, lp_iconv_convenience(global_loadparm), &(p)->elem, \
(ndr_pull_flags_fn_t)ndr_pull_GUID); \
- if (!NT_STATUS_IS_OK(_nt_status)) { \
+ if (!NDR_ERR_CODE_IS_SUCCESS(_ndr_err)) { \
+ NTSTATUS _nt_status = ndr_map_error2ntstatus(_ndr_err); \
return ntstatus_to_werror(_nt_status); \
} \
} else { \
{
WERROR status;
- GET_STRING_DS(schema, r, "name", mem_ctx, attr, cn, True);
- GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, True);
+ GET_STRING_DS(schema, r, "name", mem_ctx, attr, cn, true);
+ GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, attr, lDAPDisplayName, true);
GET_UINT32_DS(schema, r, "attributeID", attr, attributeID_id);
status = dsdb_map_int2oid(schema, attr->attributeID_id, mem_ctx, &attr->attributeID_oid);
if (!W_ERROR_IS_OK(status)) {
GET_UINT32_DS(schema, r, "searchFlags", attr, searchFlags);
GET_UINT32_DS(schema, r, "systemFlags", attr, systemFlags);
- GET_BOOL_DS(schema, r, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, False);
+ GET_BOOL_DS(schema, r, "isMemberOfPartialAttributeSet", attr, isMemberOfPartialAttributeSet, false);
GET_UINT32_DS(schema, r, "linkID", attr, linkID);
GET_UINT32_DS(schema, r, "attributeSyntax", attr, attributeSyntax_id);
GET_UINT32_DS(schema, r, "oMSyntax", attr, oMSyntax);
GET_BLOB_DS(schema, r, "oMObjectClass", mem_ctx, attr, oMObjectClass);
- GET_BOOL_DS(schema, r, "isSingleValued", attr, isSingleValued, True);
+ GET_BOOL_DS(schema, r, "isSingleValued", attr, isSingleValued, true);
GET_UINT32_DS(schema, r, "rangeLower", attr, rangeLower);
GET_UINT32_DS(schema, r, "rangeUpper", attr, rangeUpper);
- GET_BOOL_DS(schema, r, "extendedCharsAllowed", attr, extendedCharsAllowed, False);
+ GET_BOOL_DS(schema, r, "extendedCharsAllowed", attr, extendedCharsAllowed, false);
GET_UINT32_DS(schema, r, "schemaFlagsEx", attr, schemaFlagsEx);
GET_BLOB_DS(schema, r, "msDs-Schema-Extensions", mem_ctx, attr, msDs_Schema_Extensions);
- GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, False);
- GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, attr, adminDisplayName, False);
- GET_STRING_DS(schema, r, "adminDescription", mem_ctx, attr, adminDescription, False);
- GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, attr, classDisplayName, False);
- GET_BOOL_DS(schema, r, "isEphemeral", attr, isEphemeral, False);
- GET_BOOL_DS(schema, r, "isDefunct", attr, isDefunct, False);
- GET_BOOL_DS(schema, r, "systemOnly", attr, systemOnly, False);
+ GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", attr, showInAdvancedViewOnly, false);
+ GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, attr, adminDisplayName, false);
+ GET_STRING_DS(schema, r, "adminDescription", mem_ctx, attr, adminDescription, false);
+ GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, attr, classDisplayName, false);
+ GET_BOOL_DS(schema, r, "isEphemeral", attr, isEphemeral, false);
+ GET_BOOL_DS(schema, r, "isDefunct", attr, isDefunct, false);
+ GET_BOOL_DS(schema, r, "systemOnly", attr, systemOnly, false);
attr->syntax = dsdb_syntax_for_attribute(attr);
if (!attr->syntax) {
{
WERROR status;
- GET_STRING_DS(schema, r, "name", mem_ctx, obj, cn, True);
- GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, True);
+ GET_STRING_DS(schema, r, "name", mem_ctx, obj, cn, true);
+ GET_STRING_DS(schema, r, "lDAPDisplayName", mem_ctx, obj, lDAPDisplayName, true);
GET_UINT32_DS(schema, r, "governsID", obj, governsID_id);
status = dsdb_map_int2oid(schema, obj->governsID_id, mem_ctx, &obj->governsID_oid);
if (!W_ERROR_IS_OK(status)) {
GET_GUID_DS(schema, r, "schemaIDGUID", mem_ctx, obj, schemaIDGUID);
GET_UINT32_DS(schema, r, "objectClassCategory", obj, objectClassCategory);
- GET_STRING_DS(schema, r, "rDNAttID", mem_ctx, obj, rDNAttID, False);
- GET_DN_DS(schema, r, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, True);
+ GET_STRING_DS(schema, r, "rDNAttID", mem_ctx, obj, rDNAttID, false);
+ GET_DN_DS(schema, r, "defaultObjectCategory", mem_ctx, obj, defaultObjectCategory, true);
- GET_STRING_DS(schema, r, "subClassOf", mem_ctx, obj, subClassOf, True);
+ GET_STRING_DS(schema, r, "subClassOf", mem_ctx, obj, subClassOf, true);
obj->systemAuxiliaryClass = NULL;
obj->systemPossSuperiors = NULL;
obj->mustContain = NULL;
obj->mayContain = NULL;
- GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, False);
+ obj->possibleInferiors = NULL;
+
+ GET_STRING_DS(schema, r, "defaultSecurityDescriptor", mem_ctx, obj, defaultSecurityDescriptor, false);
GET_UINT32_DS(schema, r, "schemaFlagsEx", obj, schemaFlagsEx);
GET_BLOB_DS(schema, r, "msDs-Schema-Extensions", mem_ctx, obj, msDs_Schema_Extensions);
- GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, False);
- GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, obj, adminDisplayName, False);
- GET_STRING_DS(schema, r, "adminDescription", mem_ctx, obj, adminDescription, False);
- GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, obj, classDisplayName, False);
- GET_BOOL_DS(schema, r, "defaultHidingValue", obj, defaultHidingValue, False);
- GET_BOOL_DS(schema, r, "isDefunct", obj, isDefunct, False);
- GET_BOOL_DS(schema, r, "systemOnly", obj, systemOnly, False);
+ GET_BOOL_DS(schema, r, "showInAdvancedViewOnly", obj, showInAdvancedViewOnly, false);
+ GET_STRING_DS(schema, r, "adminDisplayName", mem_ctx, obj, adminDisplayName, false);
+ GET_STRING_DS(schema, r, "adminDescription", mem_ctx, obj, adminDescription, false);
+ GET_STRING_DS(schema, r, "classDisplayName", mem_ctx, obj, classDisplayName, false);
+ GET_BOOL_DS(schema, r, "defaultHidingValue", obj, defaultHidingValue, false);
+ GET_BOOL_DS(schema, r, "isDefunct", obj, isDefunct, false);
+ GET_BOOL_DS(schema, r, "systemOnly", obj, systemOnly, false);
return WERR_OK;
}
return NULL;
}
+const struct dsdb_attribute *dsdb_attribute_by_linkID(const struct dsdb_schema *schema,
+ int linkID)
+{
+ struct dsdb_attribute *cur;
+
+ /* TODO: add binary search */
+ for (cur = schema->attributes; cur; cur = cur->next) {
+ if (cur->linkID != linkID) continue;
+
+ return cur;
+ }
+
+ return NULL;
+}
+
const struct dsdb_class *dsdb_class_by_governsID_id(const struct dsdb_schema *schema,
uint32_t id)
{
return NULL;
}
+WERROR dsdb_linked_attribute_lDAPDisplayName_list(const struct dsdb_schema *schema, TALLOC_CTX *mem_ctx, const char ***attr_list_ret)
+{
+ const char **attr_list = NULL;
+ struct dsdb_attribute *cur;
+ int i = 0;
+ for (cur = schema->attributes; cur; cur = cur->next) {
+ if (cur->linkID == 0) continue;
+
+ attr_list = talloc_realloc(mem_ctx, attr_list, const char *, i+2);
+ if (!attr_list) {
+ return WERR_NOMEM;
+ }
+ attr_list[i] = cur->lDAPDisplayName;
+ i++;
+ }
+ attr_list[i] = NULL;
+ *attr_list_ret = attr_list;
+ return WERR_OK;
+}
+
+/**
+ * Attach the schema to an opaque pointer on the ldb, so ldb modules
+ * can find it
+ */
+
int dsdb_set_schema(struct ldb_context *ldb, struct dsdb_schema *schema)
{
int ret;
return LDB_SUCCESS;
}
+/**
+ * Global variable to hold one copy of the schema, used to avoid memory bloat
+ */
static struct dsdb_schema *global_schema;
+/**
+ * Make this ldb use the 'global' schema, setup to avoid having multiple copies in this process
+ */
int dsdb_set_global_schema(struct ldb_context *ldb)
{
int ret;
if (!global_schema) {
- return LDB_SUCCESS;
+ return LDB_SUCCESS;
}
ret = ldb_set_opaque(ldb, "dsdb_schema", global_schema);
if (ret != LDB_SUCCESS) {
return LDB_SUCCESS;
}
-const struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb)
+/**
+ * Find the schema object for this ldb
+ */
+
+struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb)
{
const void *p;
- const struct dsdb_schema *schema;
+ struct dsdb_schema *schema;
/* see if we have a cached copy */
p = ldb_get_opaque(ldb, "dsdb_schema");
return schema;
}
+/**
+ * Make the schema found on this ldb the 'global' schema
+ */
+
void dsdb_make_schema_global(struct ldb_context *ldb)
{
- const void *p;
- const struct dsdb_schema *schema;
-
- /* see if we have a cached copy */
- p = ldb_get_opaque(ldb, "dsdb_schema");
- if (!p) {
- return;
- }
-
- schema = talloc_get_type(p, struct dsdb_schema);
+ struct dsdb_schema *schema = dsdb_get_schema(ldb);
if (!schema) {
return;
}
talloc_steal(talloc_autofree_context(), schema);
global_schema = schema;
+
+ dsdb_set_global_schema(ldb);
}
+
+/**
+ * Rather than read a schema from the LDB itself, read it from an ldif
+ * file. This allows schema to be loaded and used while adding the
+ * schema itself to the directory.
+ */
+
WERROR dsdb_attach_schema_from_ldif_file(struct ldb_context *ldb, const char *pf, const char *df)
{
struct ldb_ldif *ldif;
if (!msg) {
goto nomem;
}
+ talloc_steal(mem_ctx, msg);
+ talloc_free(ldif);
prefix_val = ldb_msg_find_ldb_val(msg, "prefixMap");
if (!prefix_val) {
goto nomem;
}
+ talloc_steal(mem_ctx, msg);
+ talloc_free(ldif);
+
is_sa = ldb_msg_check_string_attribute(msg, "objectClass", "attributeSchema");
is_sc = ldb_msg_check_string_attribute(msg, "objectClass", "classSchema");