void *context;
};
+/**
+ The user can optionally supply a custom utf8 functions,
+ to handle comparisons and casefolding.
+*/
+struct ldb_utf8_fns {
+ void *context;
+ char *(*casefold)(void *context, void *mem_ctx, const char *s);
+};
+
/**
Flag value for database connection mode.
/**
OID for LDAP Attribute Scoped Query extension.
- This control is include in SearchRequest or SearchResponse
+ This control is included in SearchRequest or SearchResponse
messages as part of the controls field of the LDAPMessage.
*/
#define LDB_CONTROL_ASQ_OID "1.2.840.113556.1.4.1504"
/**
- OID for LDAPrectory Sync extension.
+ OID for LDAP Directory Sync extension.
- This control is include in SearchRequest or SearchResponse
+ This control is included in SearchRequest or SearchResponse
messages as part of the controls field of the LDAPMessage.
*/
#define LDB_CONTROL_DIRSYNC_OID "1.2.840.113556.1.4.841"
+/**
+ OID for LDAP Virtual List View Request extension.
+
+ This control is included in SearchRequest messages
+ as part of the controls field of the LDAPMessage.
+*/
+#define LDB_CONTROL_VLV_REQ_OID "2.16.840.1.113730.3.4.9"
+
+/**
+ OID for LDAP Virtual List View Response extension.
+
+ This control is included in SearchResponse messages
+ as part of the controls field of the LDAPMessage.
+*/
+#define LDB_CONTROL_VLV_RESP_OID "2.16.840.1.113730.3.4.10"
+
struct ldb_paged_control {
int size;
int cookie_len;
char *cookie;
};
+struct ldb_vlv_req_control {
+ int beforeCount;
+ int afterCount;
+ int type;
+ union {
+ struct {
+ int offset;
+ int contentCount;
+ } byOffset;
+ struct {
+ int value_len;
+ char *value;
+ } gtOrEq;
+ } match;
+ int ctxid_len;
+ char *contextId;
+};
+
+struct ldb_vlv_resp_control {
+ int targetPosition;
+ int contentCount;
+ int vlv_result;
+ int ctxid_len;
+ char *contextId;
+};
+
struct ldb_control {
const char *oid;
int critical;
LDB_REQ_MODIFY,
LDB_REQ_DELETE,
LDB_REQ_RENAME,
+ LDB_ASYNC_SEARCH,
+ LDB_ASYNC_ADD,
+ LDB_ASYNC_MODIFY,
+ LDB_ASYNC_DELETE,
+ LDB_ASYNC_RENAME,
+
LDB_REQ_REGISTER
};
+enum ldb_reply_type {
+ LDB_REPLY_ENTRY,
+ LDB_REPLY_REFERRAL,
+ LDB_REPLY_DONE
+};
+
+enum ldb_async_wait_type {
+ LDB_WAIT_ALL,
+ LDB_WAIT_NONE
+};
+
+enum ldb_async_state {
+ LDB_ASYNC_INIT,
+ LDB_ASYNC_PENDING,
+ LDB_ASYNC_DONE
+};
+
struct ldb_result {
unsigned int count;
struct ldb_message **msgs;
+ char **refs;
+ struct ldb_control **controls;
+};
+
+struct ldb_async_result {
+ enum ldb_reply_type type;
+ struct ldb_message *message;
+ char *referral;
struct ldb_control **controls;
};
+struct ldb_async_handle {
+ int status;
+ enum ldb_async_state state;
+ void *private_data;
+ struct ldb_module *module;
+};
+
struct ldb_search {
const struct ldb_dn *base;
enum ldb_scope scope;
struct ldb_control **controls;
struct ldb_credentials *creds;
+
+ struct {
+ void *context;
+ int (*callback)(struct ldb_context *, void *, struct ldb_async_result *);
+
+ int timeout;
+ struct ldb_async_handle *handle;
+ } async;
};
int ldb_request(struct ldb_context *ldb, struct ldb_request *request);
+int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type);
+
+/**
+ Initialise ldbs' global information
+
+ This is required before any other LDB call
+
+ \return 0 if initialisation succeeded, -1 otherwise
+*/
+int ldb_global_init(void);
+
/**
Initialise an ldb context
- tdb://path
- ldapi://path
- ldap://host
- - sqlite3://path
+ - sqlite://path
\param ldb the context associated with the database (from ldb_init())
\param url the URL of the database to connect to, as noted above
*/
const char *ldb_errstring(struct ldb_context *ldb);
+/**
+ return a string explaining what a ldb error constant meancs
+*/
+const char *ldb_strerror(int ldb_err);
+
+/**
+ setup the default utf8 functions
+ FIXME: these functions do not yet handle utf8
+*/
+void ldb_set_utf8_default(struct ldb_context *ldb);
+
/**
Casefold a string
+ \param ldb the ldb context
\param mem_ctx the memory context to allocate the result string
memory from.
\param s the string that is to be folded
\return a copy of the string, converted to upper case
- \todo This function should be UTF8 aware, but currently is not.
+ \note The default function is not yet UTF8 aware. Provide your own
+ set of functions through ldb_set_utf8_fns()
*/
-char *ldb_casefold(void *mem_ctx, const char *s);
+char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s);
/**
- Compare two strings, without regard to case.
-
- \param s1 the first string to compare
- \param s2 the second string to compare
+ Check the attribute name is valid according to rfc2251
+ \param s tthe string to check
- \return 0 if the strings are the same, non-zero if there are any
- differences except for case.
-
- \note This function is not UTF8 aware.
+ \return 1 if the name is ok
*/
-int ldb_caseless_cmp(const char *s1, const char *s2);
+int ldb_valid_attr_name(const char *s);
/*
ldif manipulation functions
case; non-zero if there are any differences
*/
int ldb_attr_cmp(const char *attr1, const char *attr2);
+char *ldb_attr_casefold(void *mem_ctx, const char *s);
int ldb_attr_dn(const char *attr);
-char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value);
/**
Create an empty message
int ldb_msg_add_value(struct ldb_message *msg,
const char *attr_name,
const struct ldb_val *val);
+int ldb_msg_add_steal_value(struct ldb_message *msg,
+ const char *attr_name,
+ struct ldb_val *val);
+int ldb_msg_add_steal_string(struct ldb_message *msg,
+ const char *attr_name, char *str);
int ldb_msg_add_string(struct ldb_message *msg,
const char *attr_name, const char *str);
int ldb_msg_add_fmt(struct ldb_message *msg,
const char *fmt, va_list ap),
void *context);
+/**
+ this allows the user to set custom utf8 function for error reporting
+*/
+void ldb_set_utf8_fns(struct ldb_context *ldb,
+ void *context,
+ char *(*casefold)(void *, void *, const char *));
+
/**
this sets up debug to print messages on stderr
*/