4 Copyright (C) Andrew Tridgell 2004
5 Copyright (C) Stefan Metzmacher 2004
6 Copyright (C) Simo Sorce 2004-2005
8 ** NOTE! The following LGPL license applies to the ldb
9 ** library. This does NOT imply that all of Samba is released
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Lesser General Public
14 License as published by the Free Software Foundation; either
15 version 2 of the License, or (at your option) any later version.
17 This library is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 Lesser General Public License for more details.
22 You should have received a copy of the GNU Lesser General Public
23 License along with this library; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 * Component: ldb private header
32 * Description: defines internal ldb structures used by the subsystem and modules
34 * Author: Andrew Tridgell
35 * Author: Stefan Metzmacher
38 #ifndef _LDB_PRIVATE_H_
39 #define _LDB_PRIVATE_H_ 1
43 struct ldb_module_ops
;
45 /* basic module structure */
47 struct ldb_module
*prev
, *next
;
48 struct ldb_context
*ldb
;
50 const struct ldb_module_ops
*ops
;
54 these function pointers define the operations that a ldb module must perform
55 they correspond exactly to the ldb_*() interface
57 struct ldb_module_ops
{
59 int (*init_context
) (struct ldb_module
*);
60 int (*search
)(struct ldb_module
*, struct ldb_request
*); /* search */
61 int (*add
)(struct ldb_module
*, struct ldb_request
*); /* add */
62 int (*modify
)(struct ldb_module
*, struct ldb_request
*); /* modify */
63 int (*del
)(struct ldb_module
*, struct ldb_request
*); /* delete */
64 int (*rename
)(struct ldb_module
*, struct ldb_request
*); /* rename */
65 int (*request
)(struct ldb_module
*, struct ldb_request
*); /* match any other operation */
66 int (*extended
)(struct ldb_module
*, struct ldb_request
*); /* extended operations */
67 int (*start_transaction
)(struct ldb_module
*);
68 int (*end_transaction
)(struct ldb_module
*);
69 int (*del_transaction
)(struct ldb_module
*);
70 int (*wait
)(struct ldb_handle
*, enum ldb_wait_type
);
71 int (*sequence_number
)(struct ldb_module
*, struct ldb_request
*);
74 typedef int (*ldb_connect_fn
) (struct ldb_context
*ldb
, const char *url
, unsigned int flags
, const char *options
[],
75 struct ldb_module
**module
);
78 schema related information needed for matching rules
81 /* attribute handling table */
82 unsigned num_attributes
;
83 struct ldb_schema_attribute
*attributes
;
85 /* objectclass information */
94 every ldb connection is started by establishing a ldb_context
97 /* the operations provided by the backend */
98 struct ldb_module
*modules
;
100 /* debugging operations */
101 struct ldb_debug_ops debug_ops
;
103 /* custom utf8 functions */
104 struct ldb_utf8_fns utf8_fns
;
106 /* backend specific opaque parameters */
108 struct ldb_opaque
*next
;
113 struct ldb_schema schema
;
117 int transaction_active
;
123 unsigned int create_perms
;
127 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
131 simplify out of memory handling
133 #define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__)
135 /* The following definitions come from lib/ldb/common/ldb.c */
137 int ldb_connect_backend(struct ldb_context
*ldb
, const char *url
, const char *options
[],
138 struct ldb_module
**backend_module
);
140 /* The following definitions come from lib/ldb/common/ldb_modules.c */
142 const char **ldb_modules_list_from_string(struct ldb_context
*ldb
, TALLOC_CTX
*mem_ctx
, const char *string
);
143 int ldb_load_modules_list(struct ldb_context
*ldb
, const char **module_list
, struct ldb_module
*backend
, struct ldb_module
**out
);
144 int ldb_load_modules(struct ldb_context
*ldb
, const char *options
[]);
145 int ldb_init_module_chain(struct ldb_context
*ldb
, struct ldb_module
*module
);
146 int ldb_next_request(struct ldb_module
*module
, struct ldb_request
*request
);
147 int ldb_next_start_trans(struct ldb_module
*module
);
148 int ldb_next_end_trans(struct ldb_module
*module
);
149 int ldb_next_del_trans(struct ldb_module
*module
);
150 int ldb_next_init(struct ldb_module
*module
);
152 void ldb_set_errstring(struct ldb_context
*ldb
, const char *err_string
);
153 void ldb_asprintf_errstring(struct ldb_context
*ldb
, const char *format
, ...) PRINTF_ATTRIBUTE(2,3);
154 void ldb_reset_err_string(struct ldb_context
*ldb
);
156 int ldb_register_module(const struct ldb_module_ops
*);
157 int ldb_register_backend(const char *url_prefix
, ldb_connect_fn
);
158 int ldb_try_load_dso(struct ldb_context
*ldb
, const char *name
);
160 /* The following definitions come from lib/ldb/common/ldb_debug.c */
161 void ldb_debug(struct ldb_context
*ldb
, enum ldb_debug_level level
, const char *fmt
, ...) PRINTF_ATTRIBUTE(3, 4);
162 void ldb_debug_set(struct ldb_context
*ldb
, enum ldb_debug_level level
,
163 const char *fmt
, ...) PRINTF_ATTRIBUTE(3, 4);
165 /* The following definitions come from lib/ldb/common/ldb_ldif.c */
166 int ldb_should_b64_encode(const struct ldb_val
*val
);
168 int ldb_objectclass_init(void);
169 int ldb_operational_init(void);
170 int ldb_paged_results_init(void);
171 int ldb_rdn_name_init(void);
172 int ldb_schema_init(void);
173 int ldb_asq_init(void);
174 int ldb_sort_init(void);
175 int ldb_ldap_init(void);
176 int ldb_ildap_init(void);
177 int ldb_tdb_init(void);
178 int ldb_sqlite3_init(void);
180 int ldb_match_msg(struct ldb_context
*ldb
,
181 const struct ldb_message
*msg
,
182 const struct ldb_parse_tree
*tree
,
184 enum ldb_scope scope
);
186 const struct ldb_schema_syntax
*ldb_standard_syntax_by_name(struct ldb_context
*ldb
,
189 /* The following definitions come from lib/ldb/common/ldb_attributes.c */
191 int ldb_schema_attribute_add_with_syntax(struct ldb_context
*ldb
,
194 const struct ldb_schema_syntax
*syntax
);
195 int ldb_schema_attribute_add(struct ldb_context
*ldb
,
199 void ldb_schema_attribute_remove(struct ldb_context
*ldb
, const char *name
);
200 int ldb_setup_wellknown_attributes(struct ldb_context
*ldb
);
202 const char **ldb_subclass_list(struct ldb_context
*ldb
, const char *classname
);
203 void ldb_subclass_remove(struct ldb_context
*ldb
, const char *classname
);
204 int ldb_subclass_add(struct ldb_context
*ldb
, const char *classname
, const char *subclass
);
206 int ldb_handler_copy(struct ldb_context
*ldb
, void *mem_ctx
,
207 const struct ldb_val
*in
, struct ldb_val
*out
);
208 int ldb_comparison_binary(struct ldb_context
*ldb
, void *mem_ctx
,
209 const struct ldb_val
*v1
, const struct ldb_val
*v2
);
211 /* The following definitions come from lib/ldb/common/ldb_controls.c */
212 struct ldb_control
*get_control_from_list(struct ldb_control
**controls
, const char *oid
);
213 int save_controls(struct ldb_control
*exclude
, struct ldb_request
*req
, struct ldb_control
***saver
);
214 int check_critical_controls(struct ldb_control
**controls
);
216 /* The following definitions come from lib/ldb/common/ldb_utf8.c */
217 char *ldb_casefold_default(void *context
, void *mem_ctx
, const char *s
);
219 void ldb_msg_remove_element(struct ldb_message
*msg
, struct ldb_message_element
*el
);
222 Obtain current/next database sequence number
224 int ldb_sequence_number(struct ldb_context
*ldb
, enum ldb_sequence_type type
, uint64_t *seq_num
);
226 #define LDB_SEQ_GLOBAL_SEQUENCE 0x01
227 #define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02