⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 schema_init.c

📁 samba最新软件
💻 C
📖 第 1 页 / 共 3 页
字号:
	obj->systemAuxiliaryClass	= NULL;	obj->systemPossSuperiors	= NULL;	obj->systemMustContain		= NULL;	obj->systemMayContain		= NULL;	obj->auxiliaryClass		= NULL;	obj->possSuperiors		= NULL;	obj->mustContain		= NULL;	obj->mayContain			= NULL;	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);	return WERR_OK;}const struct dsdb_attribute *dsdb_attribute_by_attributeID_id(const struct dsdb_schema *schema,							      uint32_t id){	struct dsdb_attribute *cur;	/*	 * 0xFFFFFFFF is used as value when no mapping table is available,	 * so don't try to match with it	 */	if (id == 0xFFFFFFFF) return NULL;	/* TODO: add binary search */	for (cur = schema->attributes; cur; cur = cur->next) {		if (cur->attributeID_id != id) continue;		return cur;	}	return NULL;}const struct dsdb_attribute *dsdb_attribute_by_attributeID_oid(const struct dsdb_schema *schema,							       const char *oid){	struct dsdb_attribute *cur;	if (!oid) return NULL;	/* TODO: add binary search */	for (cur = schema->attributes; cur; cur = cur->next) {		if (strcmp(cur->attributeID_oid, oid) != 0) continue;		return cur;	}	return NULL;}const struct dsdb_attribute *dsdb_attribute_by_lDAPDisplayName(const struct dsdb_schema *schema,							       const char *name){	struct dsdb_attribute *cur;	if (!name) return NULL;	/* TODO: add binary search */	for (cur = schema->attributes; cur; cur = cur->next) {		if (strcasecmp(cur->lDAPDisplayName, name) != 0) continue;		return cur;	}	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){	struct dsdb_class *cur;	/*	 * 0xFFFFFFFF is used as value when no mapping table is available,	 * so don't try to match with it	 */	if (id == 0xFFFFFFFF) return NULL;	/* TODO: add binary search */	for (cur = schema->classes; cur; cur = cur->next) {		if (cur->governsID_id != id) continue;		return cur;	}	return NULL;}const struct dsdb_class *dsdb_class_by_governsID_oid(const struct dsdb_schema *schema,						     const char *oid){	struct dsdb_class *cur;	if (!oid) return NULL;	/* TODO: add binary search */	for (cur = schema->classes; cur; cur = cur->next) {		if (strcmp(cur->governsID_oid, oid) != 0) continue;		return cur;	}	return NULL;}const struct dsdb_class *dsdb_class_by_lDAPDisplayName(const struct dsdb_schema *schema,						       const char *name){	struct dsdb_class *cur;	if (!name) return NULL;	/* TODO: add binary search */	for (cur = schema->classes; cur; cur = cur->next) {		if (strcasecmp(cur->lDAPDisplayName, name) != 0) continue;		return cur;	}	return NULL;}const struct dsdb_class *dsdb_class_by_cn(const struct dsdb_schema *schema,					  const char *cn){	struct dsdb_class *cur;	if (!cn) return NULL;	/* TODO: add binary search */	for (cur = schema->classes; cur; cur = cur->next) {		if (strcasecmp(cur->cn, cn) != 0) continue;		return cur;	}	return NULL;}const char *dsdb_lDAPDisplayName_by_id(const struct dsdb_schema *schema,				       uint32_t id){	const struct dsdb_attribute *a;	const struct dsdb_class *c;	/* TODO: add binary search */	a = dsdb_attribute_by_attributeID_id(schema, id);	if (a) {		return a->lDAPDisplayName;	}	c = dsdb_class_by_governsID_id(schema, id);	if (c) {		return c->lDAPDisplayName;	}	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;	ret = ldb_set_opaque(ldb, "dsdb_schema", schema);	if (ret != LDB_SUCCESS) {		return ret;	}	talloc_steal(ldb, schema);	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;	}	ret = ldb_set_opaque(ldb, "dsdb_schema", global_schema);	if (ret != LDB_SUCCESS) {		return ret;	}	return LDB_SUCCESS;}/** * Find the schema object for this ldb */struct dsdb_schema *dsdb_get_schema(struct ldb_context *ldb){	const void *p;	struct dsdb_schema *schema;	/* see if we have a cached copy */	p = ldb_get_opaque(ldb, "dsdb_schema");	if (!p) {		return NULL;	}	schema = talloc_get_type(p, struct dsdb_schema);	if (!schema) {		return NULL;	}	return schema;}/** * Make the schema found on this ldb the 'global' schema */void dsdb_make_schema_global(struct ldb_context *ldb){	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;	struct ldb_message *msg;	TALLOC_CTX *mem_ctx;	WERROR status;	int ret;	struct dsdb_schema *schema;	const struct ldb_val *prefix_val;	const struct ldb_val *info_val;	struct ldb_val info_val_default;	mem_ctx = talloc_new(ldb);	if (!mem_ctx) {		goto nomem;	}	schema = dsdb_new_schema(mem_ctx, lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")));	/*	 * load the prefixMap attribute from pf	 */	ldif = ldb_ldif_read_string(ldb, &pf);	if (!ldif) {		status = WERR_INVALID_PARAM;		goto failed;	}	talloc_steal(mem_ctx, ldif);	msg = ldb_msg_canonicalize(ldb, ldif->msg);	if (!msg) {		goto nomem;	}	talloc_steal(mem_ctx, msg);	talloc_free(ldif);	prefix_val = ldb_msg_find_ldb_val(msg, "prefixMap");	if (!prefix_val) {	    	status = WERR_INVALID_PARAM;		goto failed;	}	info_val = ldb_msg_find_ldb_val(msg, "schemaInfo");	if (!info_val) {		info_val_default = strhex_to_data_blob("FF0000000000000000000000000000000000000000");		if (!info_val_default.data) {			goto nomem;		}		talloc_steal(mem_ctx, info_val_default.data);		info_val = &info_val_default;	}	status = dsdb_load_oid_mappings_ldb(schema, prefix_val, info_val);	if (!W_ERROR_IS_OK(status)) {		goto failed;	}	/*	 * load the attribute and class definitions outof df	 */	while ((ldif = ldb_ldif_read_string(ldb, &df))) {		bool is_sa;		bool is_sc;		talloc_steal(mem_ctx, ldif);		msg = ldb_msg_canonicalize(ldb, ldif->msg);		if (!msg) {			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");		if (is_sa) {			struct dsdb_attribute *sa;			sa = talloc_zero(schema, struct dsdb_attribute);			if (!sa) {				goto nomem;			}			status = dsdb_attribute_from_ldb(schema, msg, sa, sa);			if (!W_ERROR_IS_OK(status)) {				goto failed;			}			DLIST_ADD_END(schema->attributes, sa, struct dsdb_attribute *);		} else if (is_sc) {			struct dsdb_class *sc;			sc = talloc_zero(schema, struct dsdb_class);			if (!sc) {				goto nomem;			}			status = dsdb_class_from_ldb(schema, msg, sc, sc);			if (!W_ERROR_IS_OK(status)) {				goto failed;			}			DLIST_ADD_END(schema->classes, sc, struct dsdb_class *);		}	}	ret = dsdb_set_schema(ldb, schema);	if (ret != LDB_SUCCESS) {		status = WERR_FOOBAR;		goto failed;	}	goto done;nomem:	status = WERR_NOMEM;failed:done:	talloc_free(mem_ctx);	return status;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -