Samba4/LDB/Message

From SambaWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Structures

ldb_val

struct ldb_val {
    uint8_t *data; /*!< result data */
    size_t length; /*!< length of data */
};

ldb_message_element

struct ldb_message_element {
    unsigned int flags;
    const char *name;
    unsigned int num_values;
    struct ldb_val *values;
};

Results are given back as arrays of ldb_message_element.

ldb_message

struct ldb_message {
    struct ldb_dn *dn;
    unsigned int num_elements;
    struct ldb_message_element *elements;
};

An ldb_message represents all or part of a record. It can contain an arbitrary number of elements.

Methods

ldb_msg_new()

struct ldb_message *ldb_msg_new(TALLOC_CTX *mem_ctx);

Create an empty message

Parameters:

  • mem_ctx: the memory context to create in. You can pass NULL to get the top level context, however the ldb context (from ldb_init()) may be a better choice

ldb_msg_find_element()

struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, 
						 const char *attr_name);

Find an element within an message

ldb_val_equal_exact()

int ldb_val_equal_exact(const struct ldb_val *v1, const struct ldb_val *v2);

Compare two ldb_val values

Parameters:

  • v1: first ldb_val structure to be tested
  • v2: second ldb_val structure to be tested

Returns: 1 for a match, 0 if there is any difference

ldb_msg_find_val()

struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, 
				 struct ldb_val *val);

Find a value within an ldb_message_element.

Parameters:

  • el: the element to search
  • val: the value to search for

Note: This search is case sensitive

ldb_msg_add_empty()

int ldb_msg_add_empty(struct ldb_message *msg,
		const char *attr_name,
		int flags,
		struct ldb_message_element **return_el);

Add a new empty element to a ldb_message.

ldb_msg_add()

int ldb_msg_add(struct ldb_message *msg, 
		const struct ldb_message_element *el, 
		int flags);

ldb_msg_add_value()

int ldb_msg_add_value(struct ldb_message *msg, 
		const char *attr_name,
		const struct ldb_val *val,
		struct ldb_message_element **return_el);

ldb_msg_add_steal_value()

int ldb_msg_add_steal_value(struct ldb_message *msg, 
		      const char *attr_name,
		      struct ldb_val *val);

ldb_msg_add_steal_string()

int ldb_msg_add_steal_string(struct ldb_message *msg, 
			     const char *attr_name, char *str);

ldb_msg_add_string()

int ldb_msg_add_string(struct ldb_message *msg, 
		       const char *attr_name, const char *str);

ldb_msg_add_fmt()

int ldb_msg_add_fmt(struct ldb_message *msg, 
		    const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);

ldb_msg_element_compare()

int ldb_msg_element_compare(struct ldb_message_element *el1, 
			    struct ldb_message_element *el2);

ldb_msg_element_compare_name()

int ldb_msg_element_compare_name(struct ldb_message_element *el1, 
				 struct ldb_message_element *el2);