summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/include
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-01 06:21:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:01 -0500
commita06d66a3a669c3a0a0f816438e2b3e91e208f398 (patch)
tree0a80e63dad3f00cd584263e56df6f751b46de58e /source4/lib/ldb/include
parent8ab3f59a10d00357cb129a2051fd0f694b5c8081 (diff)
downloadsamba-a06d66a3a669c3a0a0f816438e2b3e91e208f398.tar.gz
samba-a06d66a3a669c3a0a0f816438e2b3e91e208f398.tar.bz2
samba-a06d66a3a669c3a0a0f816438e2b3e91e208f398.zip
r8037: a fairly major update to the internals of ldb. Changes are:
- moved the knowledge of attribute types out of ldb_tdb and into the generic ldb code. This allows the ldb_match() message match logic to be generic, so it can be used by other backend - added the generic ability to load attribute handlers, for canonicalisation, compare, ldif read and ldif write. In the future this will be used by the schema module to allow us to correctly obey the attributetype schema elements - added attribute handlers for some of the core ldap attribute types, Integer, DirectoryString, DN, ObjectClass etc - added automatic registration of attribute handlers for well-known attribute names 'cn', 'dc', 'dn', 'ou' and 'objectClass' - converted the objectSid special handlers for Samba to the new system - added more correct handling of indexing in tdb backend based on the attribute canonicalisation function - added generic support for subclasses, moving it out of the tdb backend. This will be used in future by the schema module - fixed several bugs in the dn_explode code. It still needs more work, but doesn't corrupt ldb dbs any more. (This used to be commit 944c5844ab441b96d8e5d7b2d151982139d1fab9)
Diffstat (limited to 'source4/lib/ldb/include')
-rw-r--r--source4/lib/ldb/include/ldb.h40
-rw-r--r--source4/lib/ldb/include/ldb_dn.h3
-rw-r--r--source4/lib/ldb/include/ldb_private.h51
3 files changed, 81 insertions, 13 deletions
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 8feec9e002..868d005399 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -186,16 +186,40 @@ char *ldb_binary_encode(void *ctx, struct ldb_val val);
/*
- functions for controlling ldif encode/decode
+ functions for controlling attribute handling
*/
-typedef int (*ldb_ldif_handler_t)(struct ldb_context *, const struct ldb_val *, struct ldb_val *);
+typedef int (*ldb_attr_handler_t)(struct ldb_context *, const struct ldb_val *, struct ldb_val *);
+typedef int (*ldb_attr_comparison_t)(struct ldb_context *, const struct ldb_val *, const struct ldb_val *);
-struct ldb_ldif_handler {
+struct ldb_attrib_handler {
const char *attr;
- ldb_ldif_handler_t read_fn;
- ldb_ldif_handler_t write_fn;
+
+ /* LDB_ATTR_FLAG_* */
+ unsigned flags;
+
+ /* convert from ldif to binary format */
+ ldb_attr_handler_t ldif_read_fn;
+
+ /* convert from binary to ldif format */
+ ldb_attr_handler_t ldif_write_fn;
+
+ /* canonicalise a value, for use by indexing and dn construction */
+ ldb_attr_handler_t canonicalise_fn;
+
+ /* compare two values */
+ ldb_attr_comparison_t comparison_fn;
};
+#define LDB_ATTR_FLAG_HIDDEN (1<<0)
+#define LDB_ATTR_FLAG_WILDCARD (1<<1)
+
+/* well-known ldap attribute syntaxes - see rfc2252 section 4.3.2 */
+#define LDB_SYNTAX_DN "1.3.6.1.4.1.1466.115.121.1.12"
+#define LDB_SYNTAX_DIRECTORY_STRING "1.3.6.1.4.1.1466.115.121.1.15"
+#define LDB_SYNTAX_INTEGER "1.3.6.1.4.1.1466.115.121.1.27"
+#define LDB_SYNTAX_OCTET_STRING "1.3.6.1.4.1.1466.115.121.1.40"
+#define LDB_SYNTAX_WILDCARD "LDB_SYNTAX_WILDCARD"
+#define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS"
/*
initialise a ldb context
@@ -296,9 +320,9 @@ struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char *s);
int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg);
char *ldb_base64_encode(void *mem_ctx, const char *buf, int len);
int ldb_base64_decode(char *s);
-int ldb_ldif_add_handlers(struct ldb_context *ldb,
- const struct ldb_ldif_handler *handlers,
- unsigned num_handlers);
+int ldb_attrib_add_handlers(struct ldb_context *ldb,
+ const struct ldb_attrib_handler *handlers,
+ unsigned num_handlers);
/* useful functions for ldb_message structure manipulation */
diff --git a/source4/lib/ldb/include/ldb_dn.h b/source4/lib/ldb/include/ldb_dn.h
index f355ee4879..723b89e316 100644
--- a/source4/lib/ldb/include/ldb_dn.h
+++ b/source4/lib/ldb/include/ldb_dn.h
@@ -38,5 +38,4 @@ struct ldb_dn {
struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn);
char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *edn);
int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1);
-struct ldb_dn *ldb_dn_casefold(void *mem_ctx, struct ldb_dn *edn, void *user_data,
- int (* case_fold_attr_fn)(void * user_data, char * attr));
+struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, struct ldb_dn *edn);
diff --git a/source4/lib/ldb/include/ldb_private.h b/source4/lib/ldb/include/ldb_private.h
index f6c1c7ff46..43c925e036 100644
--- a/source4/lib/ldb/include/ldb_private.h
+++ b/source4/lib/ldb/include/ldb_private.h
@@ -68,6 +68,23 @@ struct ldb_module_ops {
const char * (*errstring)(struct ldb_module *);
};
+
+/*
+ schema related information needed for matching rules
+*/
+struct ldb_schema {
+ /* attribute handling table */
+ unsigned num_attrib_handlers;
+ struct ldb_attrib_handler *attrib_handlers;
+
+ /* objectclass information */
+ unsigned num_classes;
+ struct ldb_subclass {
+ char *name;
+ char **subclasses;
+ } *classes;
+};
+
/*
every ldb connection is started by establishing a ldb_context
*/
@@ -85,9 +102,7 @@ struct ldb_context {
void *value;
} *opaque;
- /* ldif attribute handling table */
- unsigned ldif_num_handlers;
- struct ldb_ldif_handler *ldif_handlers;
+ struct ldb_schema schema;
};
/* the modules init function */
@@ -146,4 +161,34 @@ int lsqlite3_connect(struct ldb_context *ldb,
struct ldb_module *timestamps_module_init(struct ldb_context *ldb, const char *options[]);
struct ldb_module *schema_module_init(struct ldb_context *ldb, const char *options[]);
+const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb,
+ const char *attrib);
+
+int ldb_match_message(struct ldb_context *ldb,
+ struct ldb_message *msg,
+ struct ldb_parse_tree *tree,
+ const char *base,
+ enum ldb_scope scope);
+
+void ldb_remove_attrib_handler(struct ldb_context *ldb, const char *attrib);
+const struct ldb_attrib_handler *ldb_attrib_handler_syntax(struct ldb_context *ldb,
+ const char *syntax);
+int ldb_set_attrib_handlers(struct ldb_context *ldb,
+ const struct ldb_attrib_handler *handlers,
+ unsigned num_handlers);
+int ldb_setup_wellknown_attributes(struct ldb_context *ldb);
+
+struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn);
+char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *edn);
+int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1);
+struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, struct ldb_dn *edn);
+const char **ldb_subclass_list(struct ldb_context *ldb, const char *class);
+void ldb_subclass_remove(struct ldb_context *ldb, const char *class);
+int ldb_subclass_add(struct ldb_context *ldb, const char *class, const char *subclass);
+
+int ldb_handler_copy(struct ldb_context *ldb,
+ const struct ldb_val *in, struct ldb_val *out);
+int ldb_comparison_binary(struct ldb_context *ldb,
+ const struct ldb_val *v1, const struct ldb_val *v2);
+
#endif