summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/include
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-08-18 15:02:01 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:33:32 -0500
commit3e4c4cff2177af33efdb15f03a1bbcb639505cee (patch)
tree852723e443ca41ef6b1d91dd3c11224eddebbd48 /source4/lib/ldb/include
parenta8d51f87620a688a286603766cbb7edb2b7c6e60 (diff)
downloadsamba-3e4c4cff2177af33efdb15f03a1bbcb639505cee.tar.gz
samba-3e4c4cff2177af33efdb15f03a1bbcb639505cee.tar.bz2
samba-3e4c4cff2177af33efdb15f03a1bbcb639505cee.zip
r9391: Convert all the code to use struct ldb_dn to ohandle ldap like distinguished names
Provide more functions to handle DNs in this form (This used to be commit 692e35b7797e39533dd2a1c4b63d9da30f1eb5ba)
Diffstat (limited to 'source4/lib/ldb/include')
-rw-r--r--source4/lib/ldb/include/ldb.h57
-rw-r--r--source4/lib/ldb/include/ldb_private.h39
2 files changed, 52 insertions, 44 deletions
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index fdf5dc8d91..13c9b72e6d 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -64,6 +64,16 @@ struct ldb_val {
};
#endif
+/* internal ldb exploded dn structures */
+struct ldb_dn_component {
+ char *name;
+ struct ldb_val value;
+};
+struct ldb_dn {
+ int comp_num;
+ struct ldb_dn_component *components;
+};
+
/* these flags are used in ldd_message_element.flags fields. The
LDA_FLAGS_MOD_* flags are used in ldap_modify() calls to specify
whether attributes are being added, deleted or modified */
@@ -95,7 +105,7 @@ struct ldb_message_element {
number of elements.
*/
struct ldb_message {
- char *dn;
+ struct ldb_dn *dn;
unsigned int num_elements;
struct ldb_message_element *elements;
void *private_data; /* private to the backend */
@@ -259,7 +269,7 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co
use talloc_free to free the ldb_message returned
*/
int ldb_search(struct ldb_context *ldb,
- const char *base,
+ const const struct ldb_dn *base,
enum ldb_scope scope,
const char *expression,
const char * const *attrs, struct ldb_message ***res);
@@ -268,7 +278,7 @@ int ldb_search(struct ldb_context *ldb,
like ldb_search() but takes a parse tree
*/
int ldb_search_bytree(struct ldb_context *ldb,
- const char *base,
+ const struct ldb_dn *base,
enum ldb_scope scope,
struct ldb_parse_tree *tree,
const char * const *attrs, struct ldb_message ***res);
@@ -289,7 +299,7 @@ int ldb_modify(struct ldb_context *ldb,
/*
rename a record in the database
*/
-int ldb_rename(struct ldb_context *ldb, const char *olddn, const char *newdn);
+int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn);
/*
create a named lock
@@ -304,7 +314,7 @@ int ldb_unlock(struct ldb_context *ldb, const char *lockname);
/*
delete a record from the database
*/
-int ldb_delete(struct ldb_context *ldb, const char *dn);
+int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn);
/*
@@ -337,19 +347,38 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb,
const struct ldb_attrib_handler *handlers,
unsigned num_handlers);
+/* The following definitions come from lib/ldb/common/ldb_dn.c */
+BOOL ldb_dn_is_special(const struct ldb_dn *dn);
+BOOL ldb_dn_check_special(const struct ldb_dn *dn, const char *check);
+char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value);
+struct ldb_dn *ldb_dn_new(void *mem_ctx);
+struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn);
+char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn);
+char *ldb_dn_linearize_casefold(struct ldb_context *ldb, const struct ldb_dn *edn);
+int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, const struct ldb_dn *dn);
+int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1);
+struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn);
+struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn);
+struct ldb_dn *ldb_dn_copy_partial(void *mem_ctx, const struct ldb_dn *dn, int num_el);
+struct ldb_dn *ldb_dn_copy(void *mem_ctx, const struct ldb_dn *dn);
+struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, const struct ldb_dn *dn);
+struct ldb_dn_component *ldb_dn_build_component(void *mem_ctx, const char *attr,
+ const char *val);
+struct ldb_dn *ldb_dn_build_child(void *mem_ctx, const char *attr,
+ const char * value,
+ const struct ldb_dn *base);
+struct ldb_dn *ldb_dn_make_child(void *mem_ctx,
+ const struct ldb_dn_component *component,
+ const struct ldb_dn *base);
+struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const struct ldb_dn *dn2);
+struct ldb_dn *ldb_dn_compose_string_dn(void *mem_ctx, const char *dn1, const struct ldb_dn *dn2);
+struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn);
/* useful functions for ldb_message structure manipulation */
-
int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2);
int ldb_attr_cmp(const char *dn1, const char *dn2);
char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value);
-/* case-fold a DN */
-char *ldb_dn_fold(void * mem_ctx,
- const char * dn,
- void * user_data,
- int (* case_fold_attr_fn)(void * user_data, char * attr));
-
/* create an empty message */
struct ldb_message *ldb_msg_new(void *mem_ctx);
@@ -411,9 +440,7 @@ const char *ldb_msg_find_string(const struct ldb_message *msg,
void ldb_msg_sort_elements(struct ldb_message *msg);
-void ldb_msg_free(struct ldb_context *ldb, struct ldb_message *msg);
-
-struct ldb_message *ldb_msg_copy(struct ldb_context *ldb,
+struct ldb_message *ldb_msg_copy(void *mem_ctx,
const struct ldb_message *msg);
struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb,
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index 43e6a3ecba..f5b50f5fc0 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -56,14 +56,14 @@ struct ldb_module {
*/
struct ldb_module_ops {
const char *name;
- int (*search)(struct ldb_module *, const char *, enum ldb_scope,
+ int (*search)(struct ldb_module *, const struct ldb_dn *, enum ldb_scope,
const char *, const char * const [], struct ldb_message ***);
- int (*search_bytree)(struct ldb_module *, const char *, enum ldb_scope,
+ int (*search_bytree)(struct ldb_module *, const struct ldb_dn *, enum ldb_scope,
struct ldb_parse_tree *, const char * const [], struct ldb_message ***);
int (*add_record)(struct ldb_module *, const struct ldb_message *);
int (*modify_record)(struct ldb_module *, const struct ldb_message *);
- int (*delete_record)(struct ldb_module *, const char *);
- int (*rename_record)(struct ldb_module *, const char *, const char *);
+ int (*delete_record)(struct ldb_module *, const struct ldb_dn *);
+ int (*rename_record)(struct ldb_module *, const struct ldb_dn *, const struct ldb_dn *);
int (*named_lock)(struct ldb_module *, const char *);
int (*named_unlock)(struct ldb_module *, const char *);
const char * (*errstring)(struct ldb_module *);
@@ -106,16 +106,6 @@ struct ldb_context {
struct ldb_schema schema;
};
-/* internal ldb exploded dn structures */
-struct ldb_dn_component {
- char *name;
- struct ldb_val value;
-};
-struct ldb_dn {
- int comp_num;
- struct ldb_dn_component *components;
-};
-
/* the modules init function */
typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb, const char *options[]);
@@ -132,19 +122,19 @@ typedef struct ldb_module *(*ldb_module_init_function)(struct ldb_context *ldb,
int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
int ldb_next_search(struct ldb_module *module,
- const char *base,
+ const struct ldb_dn *base,
enum ldb_scope scope,
const char *expression,
const char * const *attrs, struct ldb_message ***res);
int ldb_next_search_bytree(struct ldb_module *module,
- const char *base,
+ const struct ldb_dn *base,
enum ldb_scope scope,
struct ldb_parse_tree *tree,
const char * const *attrs, struct ldb_message ***res);
int ldb_next_add_record(struct ldb_module *module, const struct ldb_message *message);
int ldb_next_modify_record(struct ldb_module *module, const struct ldb_message *message);
-int ldb_next_delete_record(struct ldb_module *module, const char *dn);
-int ldb_next_rename_record(struct ldb_module *module, const char *olddn, const char *newdn);
+int ldb_next_delete_record(struct ldb_module *module, const struct ldb_dn *dn);
+int ldb_next_rename_record(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn);
int ldb_next_named_lock(struct ldb_module *module, const char *lockname);
int ldb_next_named_unlock(struct ldb_module *module, const char *lockname);
const char *ldb_next_errstring(struct ldb_module *module);
@@ -174,10 +164,10 @@ struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *optio
struct ldb_module *rdn_name_module_init(struct ldb_context *ldb, const char *options[]);
-int ldb_match_msg(struct ldb_context *ldb,
+int ldb_match_msg(struct ldb_context *ldb,
struct ldb_message *msg,
struct ldb_parse_tree *tree,
- const char *base,
+ const struct ldb_dn *base,
enum ldb_scope scope);
void ldb_remove_attrib_handler(struct ldb_context *ldb, const char *attrib);
@@ -188,15 +178,6 @@ int ldb_set_attrib_handlers(struct ldb_context *ldb,
unsigned num_handlers);
int ldb_setup_wellknown_attributes(struct ldb_context *ldb);
-
-/* The following definitions come from lib/ldb/common/ldb_dn.c */
-struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn);
-char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn);
-int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, const struct ldb_dn *dn);
-int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1);
-struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn);
-struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn);
-
/* The following definitions come from lib/ldb/common/ldb_attributes.c */
const char **ldb_subclass_list(struct ldb_context *ldb, const char *class);
void ldb_subclass_remove(struct ldb_context *ldb, const char *class);