4 Copyright (C) Andrew Tridgell 2004
6 ** NOTE! The following LGPL license applies to the ldb
7 ** library. This does NOT imply that all of Samba is released
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 * Component: ldb core API
30 * Description: core API routines interfacing to ldb backends
32 * Author: Andrew Tridgell
38 connect to a database. The URL can either be one of the following forms
42 flags is made up of LDB_FLG_*
44 the options are passed uninterpreted to the backend, and are
47 struct ldb_context *ldb_connect(const char *url, unsigned int flags,
48 const char *options[])
51 if (strncmp(url, "tdb:", 4) == 0) {
52 return ltdb_connect(url, flags, options);
55 if (strncmp(url, "ldap", 4) == 0) {
56 return lldb_connect(url, flags, options);
64 close the connection to the database
66 int ldb_close(struct ldb_context *ldb)
68 return ldb->ops->close(ldb);
73 search the database given a LDAP-like search expression
75 return the number of records found, or -1 on error
77 int ldb_search(struct ldb_context *ldb,
80 const char *expression,
81 const char *attrs[], struct ldb_message ***res)
83 return ldb->ops->search(ldb, base, scope, expression, attrs, res);
87 free a set of messages returned by ldb_search
89 int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs)
91 return ldb->ops->search_free(ldb, msgs);
96 add a record to the database. Will fail if a record with the given class and key
99 int ldb_add(struct ldb_context *ldb,
100 const struct ldb_message *message)
102 return ldb->ops->add(ldb, message);
106 modify the specified attributes of a record
108 int ldb_modify(struct ldb_context *ldb,
109 const struct ldb_message *message)
111 return ldb->ops->modify(ldb, message);
116 delete a record from the database
118 int ldb_delete(struct ldb_context *ldb, const char *dn)
120 return ldb->ops->delete(ldb, dn);
124 return extended error information
126 const char *ldb_errstring(struct ldb_context *ldb)
128 return ldb->ops->errstring(ldb);