Samba4/LDB/Message: Difference between revisions
From SambaWiki
Line 96: | Line 96: | ||
Add a new empty element to a ldb_message. |
Add a new empty element to a ldb_message. |
||
== ldb_msg_add() == |
|||
<pre> |
|||
int ldb_msg_add(struct ldb_message *msg, |
|||
const struct ldb_message_element *el, |
|||
int flags); |
|||
</pre> |
|||
== ldb_msg_add_value() == |
|||
<pre> |
|||
int ldb_msg_add_value(struct ldb_message *msg, |
|||
const char *attr_name, |
|||
const struct ldb_val *val, |
|||
struct ldb_message_element **return_el); |
|||
</pre> |
|||
== ldb_msg_add_steal_value() == |
|||
<pre> |
|||
int ldb_msg_add_steal_value(struct ldb_message *msg, |
|||
const char *attr_name, |
|||
struct ldb_val *val); |
|||
</pre> |
|||
== ldb_msg_add_steal_string() == |
|||
<pre> |
|||
int ldb_msg_add_steal_string(struct ldb_message *msg, |
|||
const char *attr_name, char *str); |
|||
</pre> |
|||
== ldb_msg_add_string() == |
|||
<pre> |
|||
int ldb_msg_add_string(struct ldb_message *msg, |
|||
const char *attr_name, const char *str); |
|||
</pre> |
|||
== ldb_msg_add_fmt() == |
|||
<pre> |
|||
int ldb_msg_add_fmt(struct ldb_message *msg, |
|||
const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); |
|||
</pre> |
Revision as of 22:21, 11 November 2009
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);