2 #include "system/filesys.h"
3 #include "system/time.h"
5 #include "ldb_module.h"
7 /* this private structure is used by the ltdb backend in the
11 unsigned int connect_flags;
13 unsigned long long sequence_number;
15 /* the low level tdb seqnum - used to avoid loading BASEINFO when
20 struct ldb_message *indexlist;
21 bool one_level_indexes;
22 bool attribute_indexes;
23 const char *GUID_index_attribute;
29 bool disallow_dn_filter;
30 struct ltdb_idxptr *idxptr;
39 const struct ldb_schema_syntax *GUID_index_syntax;
43 struct ldb_module *module;
44 struct ldb_request *req;
46 bool request_terminated;
47 struct ltdb_req_spy *spy;
50 const struct ldb_parse_tree *tree;
53 const char * const *attrs;
54 struct tevent_timer *timeout_event;
60 /* special record types */
61 #define LTDB_INDEX "@INDEX"
62 #define LTDB_INDEXLIST "@INDEXLIST"
63 #define LTDB_IDX "@IDX"
64 #define LTDB_IDXVERSION "@IDXVERSION"
65 #define LTDB_IDXATTR "@IDXATTR"
66 #define LTDB_IDXONE "@IDXONE"
67 #define LTDB_IDXDN "@IDXDN"
68 #define LTDB_IDXGUID "@IDXGUID"
69 #define LTDB_IDX_DN_GUID "@IDX_DN_GUID"
70 #define LTDB_BASEINFO "@BASEINFO"
71 #define LTDB_OPTIONS "@OPTIONS"
72 #define LTDB_ATTRIBUTES "@ATTRIBUTES"
74 /* special attribute types */
75 #define LTDB_SEQUENCE_NUMBER "sequenceNumber"
76 #define LTDB_CHECK_BASE "checkBaseOnSearch"
77 #define LTDB_DISALLOW_DN_FILTER "disallowDNFilter"
78 #define LTDB_MOD_TIMESTAMP "whenChanged"
79 #define LTDB_OBJECTCLASS "objectClass"
82 #define LTDB_GUID_KEY_PREFIX "GUID="
83 #define LTDB_GUID_SIZE 16
85 /* The following definitions come from lib/ldb/ldb_tdb/ldb_cache.c */
87 int ltdb_cache_reload(struct ldb_module *module);
88 int ltdb_cache_load(struct ldb_module *module);
89 int ltdb_increase_sequence_number(struct ldb_module *module);
90 int ltdb_check_at_attributes_values(const struct ldb_val *value);
92 /* The following definitions come from lib/ldb/ldb_tdb/ldb_index.c */
94 struct ldb_parse_tree;
96 int ltdb_search_indexed(struct ltdb_context *ctx, uint32_t *);
97 int ltdb_index_add_new(struct ldb_module *module,
98 struct ltdb_private *ltdb,
99 const struct ldb_message *msg);
100 int ltdb_index_delete(struct ldb_module *module, const struct ldb_message *msg);
101 int ltdb_index_del_element(struct ldb_module *module,
102 struct ltdb_private *ltdb,
103 const struct ldb_message *msg,
104 struct ldb_message_element *el);
105 int ltdb_index_add_element(struct ldb_module *module,
106 struct ltdb_private *ltdb,
107 const struct ldb_message *msg,
108 struct ldb_message_element *el);
109 int ltdb_index_del_value(struct ldb_module *module,
110 struct ltdb_private *ltdb,
111 const struct ldb_message *msg,
112 struct ldb_message_element *el, unsigned int v_idx);
113 int ltdb_reindex(struct ldb_module *module);
114 int ltdb_index_transaction_start(struct ldb_module *module);
115 int ltdb_index_transaction_commit(struct ldb_module *module);
116 int ltdb_index_transaction_cancel(struct ldb_module *module);
118 /* The following definitions come from lib/ldb/ldb_tdb/ldb_search.c */
120 int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name,
121 const struct ldb_val *val);
122 void ltdb_search_dn1_free(struct ldb_module *module, struct ldb_message *msg);
123 int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg,
124 unsigned int unpack_flags);
125 int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn);
126 int ltdb_search_key(struct ldb_module *module, struct ltdb_private *ltdb,
127 struct TDB_DATA tdb_key,
128 struct ldb_message *msg,
129 unsigned int unpack_flags);
130 int ltdb_filter_attrs(TALLOC_CTX *mem_ctx,
131 const struct ldb_message *msg, const char * const *attrs,
132 struct ldb_message **filtered_msg);
133 int ltdb_search(struct ltdb_context *ctx);
135 /* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
136 int ltdb_lock_read(struct ldb_module *module);
137 int ltdb_unlock_read(struct ldb_module *module);
139 * Determine if this key could hold a record. We allow the new GUID
140 * index, the old DN index and a possible future ID=
142 bool ltdb_key_is_record(TDB_DATA key);
143 TDB_DATA ltdb_key_dn(struct ldb_module *module, struct ldb_dn *dn);
144 TDB_DATA ltdb_key_msg(struct ldb_module *module, const struct ldb_message *msg);
145 TDB_DATA ltdb_guid_to_key(struct ldb_module *module,
146 struct ltdb_private *ltdb,
148 const struct ldb_val *guid_val);
149 int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
150 int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg, struct ldb_request *req);
151 int ltdb_delete_noindex(struct ldb_module *module,
152 const struct ldb_message *msg);
153 int ltdb_err_map(enum TDB_ERROR tdb_code);
155 struct tdb_context *ltdb_wrap_open(TALLOC_CTX *mem_ctx,
156 const char *path, int hash_size, int tdb_flags,
157 int open_flags, mode_t mode,
158 struct ldb_context *ldb);