-/*
+/*
ldb database library
Copyright (C) Andrew Tridgell 2004
** NOTE! The following LGPL license applies to the ldb
** library. This does NOT imply that all of Samba is released
** under the LGPL
-
+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
major restrictions as compared to normal LDAP:
- each record must have a unique key field
- - the key must be representable as a NULL terminated C string and may not
+ - the key must be representable as a NULL terminated C string and may not
contain a comma or braces
major restrictions as compared to tdb:
blobs of arbitrary size.
\note the data is null (0x00) terminated, but the length does not
- include the terminator.
+ include the terminator.
*/
struct ldb_val {
uint8_t *data; /*!< result data */
/**
a ldb_message represents all or part of a record. It can contain an arbitrary
- number of elements.
+ number of elements.
*/
struct ldb_message {
struct ldb_dn *dn;
struct ldb_message *msg; /*!< The changes */
};
-enum ldb_scope {LDB_SCOPE_DEFAULT=-1,
- LDB_SCOPE_BASE=0,
+enum ldb_scope {LDB_SCOPE_DEFAULT=-1,
+ LDB_SCOPE_BASE=0,
LDB_SCOPE_ONELEVEL=1,
LDB_SCOPE_SUBTREE=2};
struct tevent_context;
/* debugging uses one of the following levels */
-enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR,
+enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR,
LDB_DEBUG_WARNING, LDB_DEBUG_TRACE};
/**
of a severity level
*/
struct ldb_debug_ops {
- void (*debug)(void *context, enum ldb_debug_level level,
+ void (*debug)(void *context, enum ldb_debug_level level,
const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0);
void *context;
};
/**
Flag to tell ldif handlers not to force encoding of binary
- structures in base64
+ structures in base64
*/
#define LDB_FLG_SHOW_BINARY 16
/**
The attribute is not returned by default
*/
-#define LDB_ATTR_FLAG_HIDDEN (1<<0)
+#define LDB_ATTR_FLAG_HIDDEN (1<<0)
/* the attribute handler name should be freed when released */
-#define LDB_ATTR_FLAG_ALLOCATED (1<<1)
+#define LDB_ATTR_FLAG_ALLOCATED (1<<1)
/**
The attribute is supplied by the application and should not be removed
*/
-#define LDB_ATTR_FLAG_FIXED (1<<2)
+#define LDB_ATTR_FLAG_FIXED (1<<2)
/*
when this is set, attempts to create two records which have the same
This is the well-known LDAP attribute syntax for a DN.
- See <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
+ See <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
*/
#define LDB_SYNTAX_DN "1.3.6.1.4.1.1466.115.121.1.12"
This is the well-known LDAP attribute syntax for a Directory String.
- \sa <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
+ \sa <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
*/
#define LDB_SYNTAX_DIRECTORY_STRING "1.3.6.1.4.1.1466.115.121.1.15"
This is the well-known LDAP attribute syntax for an integer.
- See <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
+ See <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
*/
#define LDB_SYNTAX_INTEGER "1.3.6.1.4.1.1466.115.121.1.27"
This is the well-known LDAP attribute syntax for a boolean.
- See <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
+ See <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
*/
#define LDB_SYNTAX_BOOLEAN "1.3.6.1.4.1.1466.115.121.1.7"
This is the well-known LDAP attribute syntax for an octet string.
- See <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
+ See <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
*/
#define LDB_SYNTAX_OCTET_STRING "1.3.6.1.4.1.1466.115.121.1.40"
This is the well-known LDAP attribute syntax for a UTC time.
- See <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
+ See <a href="http://www.ietf.org/rfc/rfc2252.txt">RFC 2252</a>, Section 4.3.2
*/
#define LDB_SYNTAX_UTC_TIME "1.3.6.1.4.1.1466.115.121.1.53"
#define LDB_SYNTAX_GENERALIZED_TIME "1.3.6.1.4.1.1466.115.121.1.24"
/**
OID for getting and manipulating attributes from the ldb
without interception in the operational module.
- It can be used to access attribute that used to be stored in the sam
+ It can be used to access attribute that used to be stored in the sam
and that are now calculated.
*/
#define LDB_CONTROL_BYPASS_OPERATIONAL_OID "1.3.6.1.4.1.7165.4.3.13"
OID for the paged results control. This control is included in the
searchRequest and searchResultDone messages as part of the controls
field of the LDAPMessage, as defined in Section 4.1.12 of
- LDAP v3.
+ LDAP v3.
\sa <a href="http://www.ietf.org/rfc/rfc2696.txt">RFC 2696</a>.
*/
#define LDB_CONTROL_ASQ_NAME "asq"
/**
- OID for LDAP Directory Sync extension.
+ OID for LDAP Directory Sync extension.
This control is included in SearchRequest or SearchResponse
messages as part of the controls field of the LDAPMessage.
#define LDB_CONTROL_PERMISSIVE_MODIFY_OID "1.2.840.113556.1.4.1413"
#define LDB_CONTROL_PERMISSIVE_MODIFY_NAME "permissive_modify"
-/**
- OID to allow the server to be more 'fast and loose' with the data being added.
+/**
+ OID to allow the server to be more 'fast and loose' with the data being added.
\sa <a href="http://msdn.microsoft.com/en-us/library/aa366982(v=VS.85).aspx">Microsoft documentation of this OID</a>
*/
struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb);
/**
- The default async search callback function
+ The default async search callback function
\param req the request we are callback of
\param ares a single reply from the async core
\param ret_req the request structure is returned here (talloced on mem_ctx)
\param ldb the context associated with the database (from ldb_init())
\param mem_ctx a talloc memory context (used as parent of ret_req)
- \param message contains the entry to be added
+ \param message contains the entry to be added
\param controls an array of controls
\param context the callback function context
\param the callback function to handle the async replies
int ldb_request_replace_control(struct ldb_request *req, const char *oid, bool critical, void *data);
/**
- check if a control with the specified "oid" exist and return it
+ check if a control with the specified "oid" exist and return it
\param req the request struct where to add the control
\param oid the object identifier of the control as string
- \return the control, NULL if not found
+ \return the control, NULL if not found
*/
struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char *oid);
/**
- check if a control with the specified "oid" exist and return it
+ check if a control with the specified "oid" exist and return it
\param rep the reply struct where to add the control
\param oid the object identifier of the control as string
- \return the control, NULL if not found
+ \return the control, NULL if not found
*/
struct ldb_control *ldb_reply_get_control(struct ldb_reply *rep, const char *oid);
/**
Search the database
- This function searches the database, and returns
+ This function searches the database, and returns
records that match an LDAP-like search expression
\param ldb the context associated with the database (from ldb_init())
This function adds a record to the database. This function will fail
if a record with the specified class and key already exists in the
- database.
+ database.
\param ldb the context associated with the database (from
ldb_init())
\return result code (LDB_SUCCESS if the record was added, otherwise
a failure code)
*/
-int ldb_add(struct ldb_context *ldb,
+int ldb_add(struct ldb_context *ldb,
const struct ldb_message *message);
/**
\return result code (LDB_SUCCESS if the record was modified as
requested, otherwise a failure code)
*/
-int ldb_modify(struct ldb_context *ldb,
+int ldb_modify(struct ldb_context *ldb,
const struct ldb_message *message);
/**
\param ldb the context associated with the database (from
ldb_init())
\param olddn the DN for the record to be renamed.
- \param newdn the new DN
+ \param newdn the new DN
\return result code (LDB_SUCCESS if the record was renamed as
requested, otherwise a failure code)
int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn);
/**
- The default async extended operation callback function
+ The default async extended operation callback function
\param req the request we are callback of
\param ares a single reply from the async core
\param mem_ctx a talloc memory context (used as parent of ret_req)
\param oid the OID of the extended operation.
\param data a void pointer a the extended operation specific parameters,
- it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it
+ it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it
\param controls an array of controls
\param context the callback function context
\param the callback function to handle the async replies
\param ldb the context associated with the database (from ldb_init())
\param oid the OID of the extended operation.
\param data a void pointer a the extended operation specific parameters,
- it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it
+ it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it
\param res the result of the extended operation
\return result code (LDB_SUCCESS if the extended operation returned fine,
otherwise a failure code)
*/
-int ldb_extended(struct ldb_context *ldb,
+int ldb_extended(struct ldb_context *ldb,
const char *oid,
void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */
struct ldb_result **res);
\param ldb the ldb context
\param mem_ctx the memory context to allocate the result string
- memory from.
+ memory from.
\param s the string that is to be folded
\return a copy of the string, converted to upper case
\param ldb the ldb context (from ldb_init())
\param fprintf_fn a function pointer for the write function. This must take
a private data pointer, followed by a format string, and then a variable argument
- list.
+ list.
\param private_data pointer that will be provided back to the write
function. This is useful for maintaining state or context.
\param ldif the message to write out
\sa ldb_ldif_read for the reader equivalent to this function.
*/
int ldb_ldif_write(struct ldb_context *ldb,
- int (*fprintf_fn)(void *, const char *, ...) PRINTF_ATTRIBUTE(2,3),
+ int (*fprintf_fn)(void *, const char *, ...) PRINTF_ATTRIBUTE(2,3),
void *private_data,
const struct ldb_ldif *ldif);
Read an LDIF message
This function creates an LDIF message using a caller supplied read
- function.
+ function.
\param ldb the ldb context (from ldb_init())
\param fgetc_fn a function pointer for the read function. This must
\sa ldb_ldif_write for the writer equivalent to this function.
*/
-struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
+struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb,
int (*fgetc_fn)(void *), void *private_data);
/**
\sa ldb_ldif_read_string for the reader equivalent to this function.
*/
-char * ldb_ldif_write_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
+char * ldb_ldif_write_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
const struct ldb_ldif *msg);
convenient function to turn a ldb_message into a string. Useful for
debugging
*/
-char *ldb_ldif_message_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
+char *ldb_ldif_message_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
enum ldb_changetype changetype,
const struct ldb_message *msg);
Base64 encode a buffer
\param mem_ctx the memory context that the result is allocated
- from.
+ from.
\param buf pointer to the array that is to be encoded
\param len the number of elements in the array to be encoded
/**
Get the linear form of a DN (without any extended components)
-
+
\param dn The DN to linearize
*/
const char *ldb_dn_get_linearized(struct ldb_dn *dn);
/**
- Allocate a copy of the linear form of a DN (without any extended components) onto the supplied memory context
-
+ Allocate a copy of the linear form of a DN (without any extended components) onto the supplied memory context
+
\param dn The DN to linearize
\param mem_ctx TALLOC context to return result on
*/
/**
Get the linear form of a DN (with any extended components)
-
+
\param mem_ctx TALLOC context to return result on
\param dn The DN to linearize
\param mode Style of extended DN to return (0 is HEX representation of binary form, 1 is a string form)
void ldb_dn_remove_extended_components(struct ldb_dn *dn);
bool ldb_dn_has_extended(struct ldb_dn *dn);
-int ldb_dn_extended_add_syntax(struct ldb_context *ldb,
+int ldb_dn_extended_add_syntax(struct ldb_context *ldb,
unsigned flags,
const struct ldb_dn_extended_syntax *syntax);
-/**
+/**
Allocate a new DN from a string
\param mem_ctx TALLOC context to return resulting ldb_dn structure on
- \param dn The new DN
+ \param dn The new DN
\note The DN will not be parsed at this time. Use ldb_dn_validate to tell if the DN is syntacticly correct
*/
struct ldb_dn *ldb_dn_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *dn);
-/**
+/**
Allocate a new DN from a printf style format string and arguments
\param mem_ctx TALLOC context to return resulting ldb_dn structure on
*/
struct ldb_dn *ldb_dn_new_fmt(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...) PRINTF_ATTRIBUTE(3,4);
-/**
+/**
Allocate a new DN from a struct ldb_val (useful to avoid buffer overrun)
\param mem_ctx TALLOC context to return resulting ldb_dn structure on
- \param dn The new DN
+ \param dn The new DN
\note The DN will not be parsed at this time. Use ldb_dn_validate to tell if the DN is syntacticly correct
*/
struct ldb_dn *ldb_dn_from_ldb_val(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const struct ldb_val *strdn);
/**
- Determine if this DN is syntactically valid
+ Determine if this DN is syntactically valid
\param dn The DN to validate
*/
/**
add a element to a ldb_message
*/
-int ldb_msg_add(struct ldb_message *msg,
- const struct ldb_message_element *el,
+int ldb_msg_add(struct ldb_message *msg,
+ const struct ldb_message_element *el,
int flags);
-int ldb_msg_add_value(struct ldb_message *msg,
+int ldb_msg_add_value(struct ldb_message *msg,
const char *attr_name,
const struct ldb_val *val,
struct ldb_message_element **return_el);
-int ldb_msg_add_steal_value(struct ldb_message *msg,
+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,
+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,
+int ldb_msg_add_string(struct ldb_message *msg,
const char *attr_name, const char *str);
int ldb_msg_add_linearized_dn(struct ldb_message *msg, const char *attr_name,
struct ldb_dn *dn);
-int ldb_msg_add_fmt(struct ldb_message *msg,
+int ldb_msg_add_fmt(struct ldb_message *msg,
const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
/**
compare two message elements - return 0 on match
*/
-int ldb_msg_element_compare(struct ldb_message_element *el1,
+int ldb_msg_element_compare(struct ldb_message_element *el1,
struct ldb_message_element *el2);
-int ldb_msg_element_compare_name(struct ldb_message_element *el1,
+int ldb_msg_element_compare_name(struct ldb_message_element *el1,
struct ldb_message_element *el2);
/**
single valued.
*/
const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, const char *attr_name);
-int ldb_msg_find_attr_as_int(const struct ldb_message *msg,
+int ldb_msg_find_attr_as_int(const struct ldb_message *msg,
const char *attr_name,
int default_value);
-unsigned int ldb_msg_find_attr_as_uint(const struct ldb_message *msg,
+unsigned int ldb_msg_find_attr_as_uint(const struct ldb_message *msg,
const char *attr_name,
unsigned int default_value);
-int64_t ldb_msg_find_attr_as_int64(const struct ldb_message *msg,
+int64_t ldb_msg_find_attr_as_int64(const struct ldb_message *msg,
const char *attr_name,
int64_t default_value);
-uint64_t ldb_msg_find_attr_as_uint64(const struct ldb_message *msg,
+uint64_t ldb_msg_find_attr_as_uint64(const struct ldb_message *msg,
const char *attr_name,
uint64_t default_value);
-double ldb_msg_find_attr_as_double(const struct ldb_message *msg,
+double ldb_msg_find_attr_as_double(const struct ldb_message *msg,
const char *attr_name,
double default_value);
-int ldb_msg_find_attr_as_bool(const struct ldb_message *msg,
+int ldb_msg_find_attr_as_bool(const struct ldb_message *msg,
const char *attr_name,
int default_value);
-const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg,
+const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg,
const char *attr_name,
const char *default_value);
void ldb_msg_sort_elements(struct ldb_message *msg);
-struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx,
+struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx,
const struct ldb_message *msg);
-struct ldb_message *ldb_msg_copy(TALLOC_CTX *mem_ctx,
+struct ldb_message *ldb_msg_copy(TALLOC_CTX *mem_ctx,
const struct ldb_message *msg);
/*
* to steal the returned object into a TALLOC_CTX
* with short lifetime.
*/
-struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb,
+struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb,
const struct ldb_message *msg) _DEPRECATED_;
int ldb_msg_normalize(struct ldb_context *ldb,
* to steal the returned object into a TALLOC_CTX
* with short lifetime.
*/
-struct ldb_message *ldb_msg_diff(struct ldb_context *ldb,
+struct ldb_message *ldb_msg_diff(struct ldb_context *ldb,
struct ldb_message *msg1,
struct ldb_message *msg2) _DEPRECATED_;
/**
Duplicate an ldb_val structure
- This function copies an ldb value structure.
+ This function copies an ldb value structure.
\param mem_ctx the memory context that the duplicated value will be
allocated from
this allows the user to set a debug function for error reporting
*/
int ldb_set_debug(struct ldb_context *ldb,
- void (*debug)(void *context, enum ldb_debug_level level,
+ void (*debug)(void *context, enum ldb_debug_level level,
const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0),
void *context);
void ldb_msg_remove_element(struct ldb_message *msg, struct ldb_message_element *el);
-void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree,
- const char *attr,
+void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree,
+ const char *attr,
const char *replace);
/*
This function converts a time_t structure to an LDAP formatted
GeneralizedTime string.
-
+
\param mem_ctx the memory context to allocate the return string in
\param t the time structure to convert
This function converts a time_t structure to an LDAP formatted
UTCTime string.
-
+
\param mem_ctx the memory context to allocate the return string in
\param t the time structure to convert
/**
Convert a control into its string representation.
-
+
\param mem_ctx TALLOC context to return result on, and to allocate error_string on
\param control A struct ldb_control to convert
- \return string representation of the control
+ \return string representation of the control
*/
char* ldb_control_to_string(TALLOC_CTX *mem_ctx, const struct ldb_control *control);
/**
- Convert a string representing a control into a ldb_control structure
-
+ Convert a string representing a control into a ldb_control structure
+
\param ldb LDB context
\param mem_ctx TALLOC context to return result on, and to allocate error_string on
\param control_strings A string-formatted control
*/
struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *control_strings);
/**
- Convert an array of string represention of a control into an array of ldb_control structures
-
+ Convert an array of string represention of a control into an array of ldb_control structures
+
\param ldb LDB context
\param mem_ctx TALLOC context to return result on, and to allocate error_string on
\param control_strings Array of string-formatted controls
struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char **control_strings);
/**
- return the ldb flags
+ return the ldb flags
*/
unsigned int ldb_get_flags(struct ldb_context *ldb);