From 58d50a614f1b4a3fc6b60ad5f777d987263fe54f Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 31 Mar 2004 06:45:39 +0000 Subject: make a more recent snapshot of ldb available to interested people. Note that I decided to make it LGPL. ldb is not finished yet, but enough of it is there for people to get an idea of what it does, and quite a few simple tests work (This used to be commit dc6f41f9e777d37f883303ddef0d96840d80f78e) --- source4/lib/ldb/include/ldb.h | 204 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 source4/lib/ldb/include/ldb.h (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h new file mode 100644 index 0000000000..35474d23c5 --- /dev/null +++ b/source4/lib/ldb/include/ldb.h @@ -0,0 +1,204 @@ +/* + ldb database library + + Copyright (C) Andrew Tridgell 2004 + + ** NOTE! The following LGPL license applies to the ldb + ** library. This does NOT imply that all of Samba is released + ** under the LGPL + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +/* + * Name: ldb + * + * Component: ldb header + * + * Description: defines for base ldb API + * + * Author: Andrew Tridgell + */ + +/* + major restrictions as compared to normal LDAP: + + - no async calls. + - each record must have a unique key field + - the key must be representable as a NULL terminated C string and may not + contain a comma or braces + + major restrictions as compared to tdb: + + - no explicit locking calls + +*/ + + +/* + an individual lump of data in a result comes in this format. The + pointer will usually be to a UTF-8 string if the application is + sensible, but it can be to anything you like, including binary data + blobs of arbitrary size. +*/ +struct ldb_val { + unsigned int length; + void *data; +}; + +/* 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 */ +#define LDB_FLAG_MOD_MASK 0x3 +#define LDB_FLAG_MOD_ADD 1 +#define LDB_FLAG_MOD_REPLACE 2 +#define LDB_FLAG_MOD_DELETE 3 + + +/* + results are given back as arrays of ldb_message_element +*/ +struct ldb_message_element { + unsigned int flags; + char *name; + struct ldb_val value; +}; + + +/* + a ldb_message represents all or part of a record. It can contain an arbitrary + number of elements. +*/ +struct ldb_message { + char *dn; + unsigned int num_elements; + struct ldb_message_element *elements; + void *private; /* private to the backend */ +}; + + +enum ldb_scope {LDB_SCOPE_DEFAULT=-1, + LDB_SCOPE_BASE=0, + LDB_SCOPE_ONELEVEL=1, + LDB_SCOPE_SUBTREE=2}; + +struct ldb_context; + +/* + the fuction type for the callback used in traversing the database +*/ +typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); + + +/* + these function pointers define the operations that a ldb backend must perform + they correspond exactly to the ldb_*() interface +*/ +struct ldb_backend_ops { + int (*close)(struct ldb_context *); + int (*search)(struct ldb_context *, const char *, enum ldb_scope, + const char *, const char *[], struct ldb_message ***); + int (*search_free)(struct ldb_context *, struct ldb_message **); + int (*add)(struct ldb_context *, const struct ldb_message *); + int (*modify)(struct ldb_context *, const struct ldb_message *); + int (*delete)(struct ldb_context *, const char *); + const char * (*errstring)(struct ldb_context *); +}; + +/* + every ldb connection is started by establishing a ldb_context +*/ +struct ldb_context { + /* a private pointer for the backend to use */ + void *private; + + /* the operations provided by the backend */ + const struct ldb_backend_ops *ops; +}; + + +#define LDB_FLG_RDONLY 1 + +/* + connect to a database. The URL can either be one of the following forms + ldb://path + ldapi://path + + flags is made up of LDB_FLG_* + + the options are passed uninterpreted to the backend, and are + backend specific +*/ +struct ldb_context *ldb_connect(const char *url, unsigned int flags, + const char *options[]); + +/* + close the connection to the database +*/ +int ldb_close(struct ldb_context *ldb); + + +/* + search the database given a LDAP-like search expression + + return the number of records found, or -1 on error +*/ +int ldb_search(struct ldb_context *ldb, + const char *base, + enum ldb_scope scope, + const char *expression, + const char *attrs[], struct ldb_message ***res); + +/* + free a set of messages returned by ldb_search +*/ +int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs); + + +/* + add a record to the database. Will fail if a record with the given class and key + already exists +*/ +int ldb_add(struct ldb_context *ldb, + const struct ldb_message *message); + +/* + modify the specified attributes of a record +*/ +int ldb_modify(struct ldb_context *ldb, + const struct ldb_message *message); + +/* + delete a record from the database +*/ +int ldb_delete(struct ldb_context *ldb, const char *dn); + + +/* + return extended error information from the last call +*/ +const char *ldb_errstring(struct ldb_context *ldb); + +/* + ldif manipulation functions +*/ +int ldif_write(int (*fprintf_fn)(void *, const char *, ...), + void *private, + const struct ldb_message *msg); +void ldif_read_free(struct ldb_message *msg); +struct ldb_message *ldif_read(int (*fgetc_fn)(void *), void *private); +struct ldb_message *ldif_read_file(FILE *f); +struct ldb_message *ldif_read_string(const char *s); +int ldif_write_file(FILE *f, const struct ldb_message *msg); -- cgit From ee44733f94864fb0a1ae15d48e3335c0705a82ae Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 3 Apr 2004 12:29:21 +0000 Subject: added the rest of the ldb_modify() code, which required a fairly large change in the ldb API. The API is now much closer to LDAP. (This used to be commit e9e85c464411c561c5073d262a2e3533fec175ca) --- source4/lib/ldb/include/ldb.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 35474d23c5..12064bbf75 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -73,7 +73,8 @@ struct ldb_val { struct ldb_message_element { unsigned int flags; char *name; - struct ldb_val value; + unsigned int num_values; + struct ldb_val *values; }; @@ -88,6 +89,20 @@ struct ldb_message { void *private; /* private to the backend */ }; +enum ldb_changetype { + LDB_CHANGETYPE_NONE=0, + LDB_CHANGETYPE_ADD, + LDB_CHANGETYPE_DELETE, + LDB_CHANGETYPE_MODIFY +}; + +/* + a ldif record - from ldif_read +*/ +struct ldb_ldif { + enum ldb_changetype changetype; + struct ldb_message msg; +}; enum ldb_scope {LDB_SCOPE_DEFAULT=-1, LDB_SCOPE_BASE=0, @@ -196,9 +211,9 @@ const char *ldb_errstring(struct ldb_context *ldb); */ int ldif_write(int (*fprintf_fn)(void *, const char *, ...), void *private, - const struct ldb_message *msg); -void ldif_read_free(struct ldb_message *msg); -struct ldb_message *ldif_read(int (*fgetc_fn)(void *), void *private); -struct ldb_message *ldif_read_file(FILE *f); -struct ldb_message *ldif_read_string(const char *s); -int ldif_write_file(FILE *f, const struct ldb_message *msg); + const struct ldb_ldif *ldif); +void ldif_read_free(struct ldb_ldif *); +struct ldb_ldif *ldif_read(int (*fgetc_fn)(void *), void *private); +struct ldb_ldif *ldif_read_file(FILE *f); +struct ldb_ldif *ldif_read_string(const char *s); +int ldif_write_file(FILE *f, const struct ldb_ldif *msg); -- cgit From ac193579e7db00c7a2ea0aadaaf0d34c10dcf1a5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 10 Apr 2004 20:18:22 +0000 Subject: r152: a quick airport commit .... added ldbedit, a _really_ useful command added ldbadd, ldbdel, ldbsearch and ldbmodify to build solved lots of timezone issues, we now pass the torture tests with client and server in different zones fixed several build issues I know this breaks the no-LDAP build. Wait till I arrive in San Jose for that fix. (This used to be commit af34710d4da1841653624fe304b1c8d812c0fdd9) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 12064bbf75..dc1b1d7732 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -174,7 +174,7 @@ int ldb_search(struct ldb_context *ldb, const char *base, enum ldb_scope scope, const char *expression, - const char *attrs[], struct ldb_message ***res); + char * const attrs[], struct ldb_message ***res); /* free a set of messages returned by ldb_search -- cgit From 6411aa483f9233af098b4893ad67ebd2fd9d5868 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 28 Apr 2004 07:05:28 +0000 Subject: r381: make the code more C++ friendly (This used to be commit 8acecc7f27e25ab876fffffe43ae75b5f77aff77) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index dc1b1d7732..d010d8dd40 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -128,7 +128,7 @@ struct ldb_backend_ops { int (*search_free)(struct ldb_context *, struct ldb_message **); int (*add)(struct ldb_context *, const struct ldb_message *); int (*modify)(struct ldb_context *, const struct ldb_message *); - int (*delete)(struct ldb_context *, const char *); + int (*delete_record)(struct ldb_context *, const char *); const char * (*errstring)(struct ldb_context *); }; @@ -137,7 +137,7 @@ struct ldb_backend_ops { */ struct ldb_context { /* a private pointer for the backend to use */ - void *private; + void *private_data; /* the operations provided by the backend */ const struct ldb_backend_ops *ops; -- cgit From b0b97592be312b3553ac31cc3f3cb994de06e506 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 28 Apr 2004 07:32:37 +0000 Subject: r382: More C++ friendliness fixes. (This used to be commit e96f3a2005cf6f4da2ecd4670a35eab1b4f250d0) --- source4/lib/ldb/include/ldb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index d010d8dd40..ef00cdf32c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -86,7 +86,7 @@ struct ldb_message { char *dn; unsigned int num_elements; struct ldb_message_element *elements; - void *private; /* private to the backend */ + void *private_data; /* private to the backend */ }; enum ldb_changetype { @@ -210,10 +210,10 @@ const char *ldb_errstring(struct ldb_context *ldb); ldif manipulation functions */ int ldif_write(int (*fprintf_fn)(void *, const char *, ...), - void *private, + void *private_data, const struct ldb_ldif *ldif); void ldif_read_free(struct ldb_ldif *); -struct ldb_ldif *ldif_read(int (*fgetc_fn)(void *), void *private); +struct ldb_ldif *ldif_read(int (*fgetc_fn)(void *), void *private_data); struct ldb_ldif *ldif_read_file(FILE *f); struct ldb_ldif *ldif_read_string(const char *s); int ldif_write_file(FILE *f, const struct ldb_ldif *msg); -- cgit From a00c266702ca81a3689996198590b5b69a967940 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 28 Apr 2004 13:06:25 +0000 Subject: r387: more C++ friendly changes (This used to be commit ac0c525a8b8a05cc275fb9f4c1dcfd749604c85f) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index ef00cdf32c..6369ab683a 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -126,8 +126,8 @@ struct ldb_backend_ops { int (*search)(struct ldb_context *, const char *, enum ldb_scope, const char *, const char *[], struct ldb_message ***); int (*search_free)(struct ldb_context *, struct ldb_message **); - int (*add)(struct ldb_context *, const struct ldb_message *); - int (*modify)(struct ldb_context *, const struct ldb_message *); + int (*add_record)(struct ldb_context *, const struct ldb_message *); + int (*modify_record)(struct ldb_context *, const struct ldb_message *); int (*delete_record)(struct ldb_context *, const char *); const char * (*errstring)(struct ldb_context *); }; -- cgit From 0dad5a34273bf5cadcfd4a36d69bdffbf69eb073 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 1 May 2004 09:45:56 +0000 Subject: r435: a major upgrade for ldb - added the ability to mark record attributes as being CASE_INSENSITIVE, WILDCARD or INTEGER. - added the ability to support objectclass subclasses, and to search by a parent class - added internal support for case insensitive versus case sensitive indexing (not UTF8 compliant yet) - cleaned up a number of const warnings - added a number of helper functions for fetching integers, strings and doubles - added a in-memory cache for important database properties, supported by a database sequence number - changed some variable names to avoid conflicts with C++ (This used to be commit f2bf06f25c2e6c744817711c7bedbd1d3b52f994) --- source4/lib/ldb/include/ldb.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6369ab683a..215671c98a 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -124,7 +124,7 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_backend_ops { int (*close)(struct ldb_context *); int (*search)(struct ldb_context *, const char *, enum ldb_scope, - const char *, const char *[], struct ldb_message ***); + const char *, char * const [], struct ldb_message ***); int (*search_free)(struct ldb_context *, struct ldb_message **); int (*add_record)(struct ldb_context *, const struct ldb_message *); int (*modify_record)(struct ldb_context *, const struct ldb_message *); @@ -206,6 +206,11 @@ int ldb_delete(struct ldb_context *ldb, const char *dn); */ const char *ldb_errstring(struct ldb_context *ldb); +/* + casefold a string (should be UTF8, but at the moment it isn't) +*/ +char *ldb_casefold(const char *s); + /* ldif manipulation functions */ @@ -217,3 +222,4 @@ struct ldb_ldif *ldif_read(int (*fgetc_fn)(void *), void *private_data); struct ldb_ldif *ldif_read_file(FILE *f); struct ldb_ldif *ldif_read_string(const char *s); int ldif_write_file(FILE *f, const struct ldb_ldif *msg); + -- cgit From 208e09747c242ab5bd59a658033db49efa8d8696 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 3 May 2004 14:51:26 +0000 Subject: r456: - added -i option to ldbsearch - fixed sorting bug in ldb index handing (This used to be commit cdd48e2b9b3ca6be5503eec401e09db162408ac8) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 215671c98a..c0521ecffa 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -124,7 +124,7 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_backend_ops { int (*close)(struct ldb_context *); int (*search)(struct ldb_context *, const char *, enum ldb_scope, - const char *, char * const [], struct ldb_message ***); + const char *, const char * const [], struct ldb_message ***); int (*search_free)(struct ldb_context *, struct ldb_message **); int (*add_record)(struct ldb_context *, const struct ldb_message *); int (*modify_record)(struct ldb_context *, const struct ldb_message *); @@ -174,7 +174,7 @@ int ldb_search(struct ldb_context *ldb, const char *base, enum ldb_scope scope, const char *expression, - char * const attrs[], struct ldb_message ***res); + const char * const *attrs, struct ldb_message ***res); /* free a set of messages returned by ldb_search -- cgit From 232bc1503fc0e3f85b4711f077d2566dc0f0c823 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 5 May 2004 04:27:29 +0000 Subject: r490: - expanded the test suite to test modify and delete operations - made yet another attempt to make ldb const clean. - "make test" now runs both the tdb and ldap backend tests, and run the ldbtest utility with and without indexing - added prototypes in ldb.h for ldb_msg_*() public functions (This used to be commit 01e87406768cb5a98ac8530a2f361a4987a36cd3) --- source4/lib/ldb/include/ldb.h | 45 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c0521ecffa..cee72c3c21 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -124,7 +124,7 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_backend_ops { int (*close)(struct ldb_context *); int (*search)(struct ldb_context *, const char *, enum ldb_scope, - const char *, const char * const [], struct ldb_message ***); + const char *, char * const [], struct ldb_message ***); int (*search_free)(struct ldb_context *, struct ldb_message **); int (*add_record)(struct ldb_context *, const struct ldb_message *); int (*modify_record)(struct ldb_context *, const struct ldb_message *); @@ -174,7 +174,7 @@ int ldb_search(struct ldb_context *ldb, const char *base, enum ldb_scope scope, const char *expression, - const char * const *attrs, struct ldb_message ***res); + char * const *attrs, struct ldb_message ***res); /* free a set of messages returned by ldb_search @@ -223,3 +223,44 @@ struct ldb_ldif *ldif_read_file(FILE *f); struct ldb_ldif *ldif_read_string(const char *s); int ldif_write_file(FILE *f, const struct ldb_ldif *msg); + +/* useful functions for ldb_message structure manipulation */ + +/* find an element within an message */ +struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, + const char *attr_name); + +/* compare two ldb_val values - return 0 on match */ +int ldb_val_equal_exact(const struct ldb_val *v1, const struct ldb_val *v2); + +/* find a value within an ldb_message_element */ +struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, + struct ldb_val *val); + +/* add a new empty element to a ldb_message */ +int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags); + +/* add a element to a ldb_message */ +int ldb_msg_add(struct ldb_message *msg, + const struct ldb_message_element *el, + int flags); + +/* compare two message elements - return 0 on match */ +int ldb_msg_element_compare(struct ldb_message_element *el1, + struct ldb_message_element *el2); + +/* find elements in a message and convert to a specific type, with + a give default value if not found. Assumes that elements are + single valued */ +int ldb_msg_find_int(const struct ldb_message *msg, + const char *attr_name, + int default_value); +unsigned int ldb_msg_find_uint(const struct ldb_message *msg, + const char *attr_name, + int default_value); +double ldb_msg_find_double(const struct ldb_message *msg, + const char *attr_name, + double default_value); +const char *ldb_msg_find_string(const struct ldb_message *msg, + const char *attr_name, + const char *default_value); -- cgit From d8ce7c6a2acbf371509a23775470e7614bcb6027 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 May 2004 04:40:15 +0000 Subject: r502: modified ldb to allow the use of an external pool memory allocator. The way to use this is to call ldb_set_alloc() with a function pointer to whatever memory allocator you like. It includes a context pointer to allow for pool based allocators. (This used to be commit 3955c482e6c2c9e975a4bb809ec8cb6068e48e34) --- source4/lib/ldb/include/ldb.h | 71 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 10 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index cee72c3c21..852389d415 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -32,6 +32,9 @@ * Author: Andrew Tridgell */ +#ifndef _LDB_H_ +#define _LDB_H_ 1 + /* major restrictions as compared to normal LDAP: @@ -46,7 +49,6 @@ */ - /* an individual lump of data in a result comes in this format. The pointer will usually be to a UTF-8 string if the application is @@ -58,6 +60,9 @@ struct ldb_val { void *data; }; +#include "ldb_parse.h" + + /* 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 */ @@ -130,8 +135,24 @@ struct ldb_backend_ops { int (*modify_record)(struct ldb_context *, const struct ldb_message *); int (*delete_record)(struct ldb_context *, const char *); const char * (*errstring)(struct ldb_context *); + + /* this is called when the alloc ops changes to ensure we + don't have any old allocated data in the context */ + void (*cache_free)(struct ldb_context *); }; + +/* + the user can optionally supply a allocator function. It is presumed + it will act like a modern realloc(), with a context ptr to allow + for pool allocators +*/ +struct ldb_alloc_ops { + void *(*alloc)(void *context, void *ptr, size_t size); + void *context; +}; + + /* every ldb connection is started by establishing a ldb_context */ @@ -141,6 +162,9 @@ struct ldb_context { /* the operations provided by the backend */ const struct ldb_backend_ops *ops; + + /* memory allocation info */ + struct ldb_alloc_ops alloc_ops; }; @@ -209,19 +233,21 @@ const char *ldb_errstring(struct ldb_context *ldb); /* casefold a string (should be UTF8, but at the moment it isn't) */ -char *ldb_casefold(const char *s); +char *ldb_casefold(struct ldb_context *ldb, const char *s); /* ldif manipulation functions */ -int ldif_write(int (*fprintf_fn)(void *, const char *, ...), +int ldif_write(struct ldb_context *ldb, + int (*fprintf_fn)(void *, const char *, ...), void *private_data, const struct ldb_ldif *ldif); -void ldif_read_free(struct ldb_ldif *); -struct ldb_ldif *ldif_read(int (*fgetc_fn)(void *), void *private_data); -struct ldb_ldif *ldif_read_file(FILE *f); -struct ldb_ldif *ldif_read_string(const char *s); -int ldif_write_file(FILE *f, const struct ldb_ldif *msg); +void ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *); +struct ldb_ldif *ldif_read(struct ldb_context *ldb, + int (*fgetc_fn)(void *), void *private_data); +struct ldb_ldif *ldif_read_file(struct ldb_context *ldb, FILE *f); +struct ldb_ldif *ldif_read_string(struct ldb_context *ldb, const char *s); +int ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); /* useful functions for ldb_message structure manipulation */ @@ -238,10 +264,12 @@ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, struct ldb_val *val); /* add a new empty element to a ldb_message */ -int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags); +int ldb_msg_add_empty(struct ldb_context *ldb, + struct ldb_message *msg, const char *attr_name, int flags); /* add a element to a ldb_message */ -int ldb_msg_add(struct ldb_message *msg, +int ldb_msg_add(struct ldb_context *ldb, + struct ldb_message *msg, const struct ldb_message_element *el, int flags); @@ -264,3 +292,26 @@ double ldb_msg_find_double(const struct ldb_message *msg, const char *ldb_msg_find_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); + + +/* + this allows the user to choose their own allocation function + the allocation function should behave like a modern realloc() + function, which means that: + malloc(size) == alloc(context, NULL, size) + free(ptr) == alloc(context, ptr, 0) + realloc(ptr, size) == alloc(context, ptr, size) + The context argument is provided to allow for pool based allocators, + which often take a context argument +*/ +int ldb_set_alloc(struct ldb_context *ldb, + void *(*alloc)(void *context, void *ptr, size_t size), + void *context); + + +/* these are used as type safe versions of the ldb allocation functions */ +#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) +#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count) +#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count) + +#endif -- cgit From 68293565de0b799dcc51e001dabf53adf88ee7ad Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 May 2004 09:55:05 +0000 Subject: r513: added a generic ldb debug system to allow the Samba debug functions to be cleanly interfaced to ldb (This used to be commit 74b89d5f960d6b936751e3f057b4540eb80b79cd) --- source4/lib/ldb/include/ldb.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 852389d415..adb6c31952 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -152,6 +152,21 @@ struct ldb_alloc_ops { void *context; }; +/* debugging uses one of the following levels */ +enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, + LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; + +/* + the user can optionally supply a debug function. The function + is based on the vfprintf() style of interface, but with the addition + of a severity level +*/ +struct ldb_debug_ops { + void (*debug)(void *context, enum ldb_debug_level level, + const char *fmt, va_list ap); + void *context; +}; + /* every ldb connection is started by establishing a ldb_context @@ -165,6 +180,9 @@ struct ldb_context { /* memory allocation info */ struct ldb_alloc_ops alloc_ops; + + /* memory allocation info */ + struct ldb_debug_ops debug_ops; }; @@ -308,6 +326,17 @@ int ldb_set_alloc(struct ldb_context *ldb, void *(*alloc)(void *context, void *ptr, size_t size), void *context); +/* + this allows the user to set a debug function for error reporting +*/ +int ldb_set_debug(struct ldb_context *ldb, + void (*debug)(void *context, enum ldb_debug_level level, + const char *fmt, va_list ap), + void *context); + +/* this sets up debug to print messages on stderr */ +int ldb_set_debug_stderr(struct ldb_context *ldb); + /* these are used as type safe versions of the ldb allocation functions */ #define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) -- cgit From 265023fafa463c742f89510879acb2a830de8ab9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 7 May 2004 23:54:41 +0000 Subject: r574: - another attempt at const cleanliness in ldb - fixed a problem with searching for values containing an '=' sign - fixed the semantics of attempting an attribute deletion on an attribute that doesn't exist. - added some more ldb_msg_*() utilities (This used to be commit 62b4ec367d170330d837b0f1fe5cd13205a53b59) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index adb6c31952..7215bf5705 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -129,7 +129,7 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_backend_ops { int (*close)(struct ldb_context *); int (*search)(struct ldb_context *, const char *, enum ldb_scope, - const char *, char * const [], struct ldb_message ***); + const char *, const char * const [], struct ldb_message ***); int (*search_free)(struct ldb_context *, struct ldb_message **); int (*add_record)(struct ldb_context *, const struct ldb_message *); int (*modify_record)(struct ldb_context *, const struct ldb_message *); @@ -216,7 +216,7 @@ int ldb_search(struct ldb_context *ldb, const char *base, enum ldb_scope scope, const char *expression, - char * const *attrs, struct ldb_message ***res); + const char * const *attrs, struct ldb_message ***res); /* free a set of messages returned by ldb_search -- cgit From f0a8f718ff474009300af6746fa0fbb61c649ea9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 20 May 2004 13:25:06 +0000 Subject: r792: - changed the ldb ldif_* functions to be in the ldb_ namespace - added better error reporting in ldbdel - fixed a bug in handling packing of records which contain elements with no values (it caused db corruption) - allow search with "dn" as target attribute (This used to be commit 36575396234e3d35dbd442c8f1ff54a17ae64e64) --- source4/lib/ldb/include/ldb.h | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7215bf5705..448d5607a8 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -60,9 +60,6 @@ struct ldb_val { void *data; }; -#include "ldb_parse.h" - - /* 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 */ @@ -256,16 +253,16 @@ char *ldb_casefold(struct ldb_context *ldb, const char *s); /* ldif manipulation functions */ -int ldif_write(struct ldb_context *ldb, - int (*fprintf_fn)(void *, const char *, ...), - void *private_data, - const struct ldb_ldif *ldif); -void ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *); -struct ldb_ldif *ldif_read(struct ldb_context *ldb, - int (*fgetc_fn)(void *), void *private_data); -struct ldb_ldif *ldif_read_file(struct ldb_context *ldb, FILE *f); -struct ldb_ldif *ldif_read_string(struct ldb_context *ldb, const char *s); -int ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); +int ldb_ldif_write(struct ldb_context *ldb, + int (*fprintf_fn)(void *, const char *, ...), + void *private_data, + const struct ldb_ldif *ldif); +void ldb_ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *); +struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, + int (*fgetc_fn)(void *), void *private_data); +struct ldb_ldif *ldb_ldif_read_file(struct ldb_context *ldb, FILE *f); +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); /* useful functions for ldb_message structure manipulation */ -- cgit From b553acce4b426e1a2e4fda3a9acbfbf41003154a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 5 Jun 2004 01:30:27 +0000 Subject: r1018: fix a const and unsigned int problem in ldb (This used to be commit 3d52ca93731ad67c14ac42f627e3feb1a964b29a) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 448d5607a8..241f186991 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -300,7 +300,7 @@ int ldb_msg_find_int(const struct ldb_message *msg, int default_value); unsigned int ldb_msg_find_uint(const struct ldb_message *msg, const char *attr_name, - int default_value); + unsigned int default_value); double ldb_msg_find_double(const struct ldb_message *msg, const char *attr_name, double default_value); -- cgit From 1429ed54f14055a1a9399452cb6cfc94f9451cf5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 3 Oct 2004 06:39:19 +0000 Subject: r2792: got rid of talloc_ldb_alloc() and instead created talloc_realloc_fn(), so talloc now doesn't contain any ldb specific functions. allow NULL to be passed to a couple more talloc() functions (This used to be commit 1246f80d806fb5f63cfbf3879de6d546384552a8) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 241f186991..4b1401f673 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -145,7 +145,7 @@ struct ldb_backend_ops { for pool allocators */ struct ldb_alloc_ops { - void *(*alloc)(void *context, void *ptr, size_t size); + void *(*alloc)(const void *context, void *ptr, size_t size); void *context; }; @@ -320,7 +320,7 @@ const char *ldb_msg_find_string(const struct ldb_message *msg, which often take a context argument */ int ldb_set_alloc(struct ldb_context *ldb, - void *(*alloc)(void *context, void *ptr, size_t size), + void *(*alloc)(const void *context, void *ptr, size_t size), void *context); /* -- cgit From a9bd40549767c19207f3ec520a3e4346beeabef4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 20 Oct 2004 19:28:02 +0000 Subject: r3093: - implment ldb_rename() and ldbrename - add tests for ldbrename - disable all tests which regenerate the index (this is broken for me...the process hangs, tridge we need to discuss that) - link only the needed stuff to the ldb tools - build ldbtest inside samba metze (This used to be commit 18552f4786c24e0019cc87726ef4c05365fe586e) --- source4/lib/ldb/include/ldb.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4b1401f673..3c78f12fb5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -2,6 +2,7 @@ ldb database library Copyright (C) Andrew Tridgell 2004 + Copyright (C) Stefan Metzmacher 2004 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -30,6 +31,7 @@ * Description: defines for base ldb API * * Author: Andrew Tridgell + * Author: Stefan Metzmacher */ #ifndef _LDB_H_ @@ -131,6 +133,7 @@ struct ldb_backend_ops { int (*add_record)(struct ldb_context *, const struct ldb_message *); int (*modify_record)(struct ldb_context *, const struct ldb_message *); int (*delete_record)(struct ldb_context *, const char *); + int (*rename_record)(struct ldb_context *, const char *olddn, const char *newdn); const char * (*errstring)(struct ldb_context *); /* this is called when the alloc ops changes to ensure we @@ -234,6 +237,11 @@ int ldb_add(struct ldb_context *ldb, int ldb_modify(struct ldb_context *ldb, const struct ldb_message *message); +/* + rename a record in the database +*/ +int ldb_rename(struct ldb_context *ldb, const char *olddn, const char *newdn); + /* delete a record from the database */ -- cgit From 679e95db033fd11d17c1f1ac5e44f6cc4df2220e Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 15 Nov 2004 11:40:27 +0000 Subject: r3754: merge in ldb modules support from the tmp branch ldbPlugins (This used to be commit 71323f424b4561af1fdddd2358629049be3dad8c) --- source4/lib/ldb/include/ldb.h | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3c78f12fb5..6a06678e0e 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -121,26 +121,39 @@ struct ldb_context; typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); +struct ldb_module_ops; + +/* basic module structure */ +struct ldb_module { + struct ldb_module *prev, *next; + struct ldb_context *ldb; + void *private_data; + const struct ldb_module_ops *ops; +}; + /* - these function pointers define the operations that a ldb backend must perform + these function pointers define the operations that a ldb module must perform they correspond exactly to the ldb_*() interface */ -struct ldb_backend_ops { - int (*close)(struct ldb_context *); - int (*search)(struct ldb_context *, const char *, enum ldb_scope, +struct ldb_module_ops { + const char *name; + int (*close)(struct ldb_module *); + int (*search)(struct ldb_module *, const char *, enum ldb_scope, const char *, const char * const [], struct ldb_message ***); - int (*search_free)(struct ldb_context *, struct ldb_message **); - int (*add_record)(struct ldb_context *, const struct ldb_message *); - int (*modify_record)(struct ldb_context *, const struct ldb_message *); - int (*delete_record)(struct ldb_context *, const char *); - int (*rename_record)(struct ldb_context *, const char *olddn, const char *newdn); - const char * (*errstring)(struct ldb_context *); + int (*search_free)(struct ldb_module *, 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 *); + const char * (*errstring)(struct ldb_module *); /* this is called when the alloc ops changes to ensure we don't have any old allocated data in the context */ - void (*cache_free)(struct ldb_context *); + void (*cache_free)(struct ldb_module *); }; +/* the modules init function */ +typedef struct ldb_module *(*init_ldb_module_function)(void); /* the user can optionally supply a allocator function. It is presumed @@ -172,11 +185,8 @@ struct ldb_debug_ops { every ldb connection is started by establishing a ldb_context */ struct ldb_context { - /* a private pointer for the backend to use */ - void *private_data; - /* the operations provided by the backend */ - const struct ldb_backend_ops *ops; + struct ldb_module *modules; /* memory allocation info */ struct ldb_alloc_ops alloc_ops; -- cgit From 8a18778286a16423d7d6e483fdb308a91e294efe Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 16 Nov 2004 09:00:52 +0000 Subject: r3783: - don't use make proto for ldb anymore - split ldh.h out of samba's includes.h - make ldb_context and ldb_module private to the subsystem - use ltdb_ prefix for all ldb_tdb functions metze (This used to be commit f5ee40d6ce8224e280070975efc9911558fe675c) --- source4/lib/ldb/include/ldb.h | 93 +++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 56 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6a06678e0e..03d0cc7a3b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -121,39 +121,7 @@ struct ldb_context; typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); -struct ldb_module_ops; - -/* basic module structure */ -struct ldb_module { - struct ldb_module *prev, *next; - struct ldb_context *ldb; - void *private_data; - const struct ldb_module_ops *ops; -}; - -/* - these function pointers define the operations that a ldb module must perform - they correspond exactly to the ldb_*() interface -*/ -struct ldb_module_ops { - const char *name; - int (*close)(struct ldb_module *); - int (*search)(struct ldb_module *, const char *, enum ldb_scope, - const char *, const char * const [], struct ldb_message ***); - int (*search_free)(struct ldb_module *, 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 *); - const char * (*errstring)(struct ldb_module *); - - /* this is called when the alloc ops changes to ensure we - don't have any old allocated data in the context */ - void (*cache_free)(struct ldb_module *); -}; - -/* the modules init function */ -typedef struct ldb_module *(*init_ldb_module_function)(void); +struct ldb_module; /* the user can optionally supply a allocator function. It is presumed @@ -180,22 +148,6 @@ struct ldb_debug_ops { void *context; }; - -/* - every ldb connection is started by establishing a ldb_context -*/ -struct ldb_context { - /* the operations provided by the backend */ - struct ldb_module *modules; - - /* memory allocation info */ - struct ldb_alloc_ops alloc_ops; - - /* memory allocation info */ - struct ldb_debug_ops debug_ops; -}; - - #define LDB_FLG_RDONLY 1 /* @@ -285,6 +237,9 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif /* useful functions for ldb_message structure manipulation */ +int ldb_dn_cmp(const char *dn1, const char *dn2); +int ldb_attr_cmp(const char *dn1, const char *dn2); + /* find an element within an message */ struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, const char *attr_name); @@ -305,6 +260,12 @@ int ldb_msg_add(struct ldb_context *ldb, struct ldb_message *msg, const struct ldb_message_element *el, int flags); +int ldb_msg_add_value(struct ldb_context *ldb, + struct ldb_message *msg, + const char *attr_name, + struct ldb_val *val); +int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, + const char *attr_name, char *str); /* compare two message elements - return 0 on match */ int ldb_msg_element_compare(struct ldb_message_element *el1, @@ -313,19 +274,27 @@ int ldb_msg_element_compare(struct ldb_message_element *el1, /* find elements in a message and convert to a specific type, with a give default value if not found. Assumes that elements are single valued */ +const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, const char *attr_name); int ldb_msg_find_int(const struct ldb_message *msg, const char *attr_name, int default_value); unsigned int ldb_msg_find_uint(const struct ldb_message *msg, const char *attr_name, unsigned int default_value); +int64_t ldb_msg_find_int64(const struct ldb_message *msg, + const char *attr_name, + int64_t default_value); +uint64_t ldb_msg_find_uint64(const struct ldb_message *msg, + const char *attr_name, + uint64_t default_value); double ldb_msg_find_double(const struct ldb_message *msg, const char *attr_name, double default_value); const char *ldb_msg_find_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); - +struct ldb_val ldb_val_dup(struct ldb_context *ldb, + const struct ldb_val *v); /* this allows the user to choose their own allocation function @@ -341,6 +310,24 @@ int ldb_set_alloc(struct ldb_context *ldb, void *(*alloc)(const void *context, void *ptr, size_t size), void *context); +/* these are used as type safe versions of the ldb allocation functions */ +#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) +#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count) +#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count) + +void *ldb_realloc(struct ldb_context *ldb, void *ptr, size_t size); +void *ldb_malloc(struct ldb_context *ldb, size_t size); +void ldb_free(struct ldb_context *ldb, void *ptr); +void *ldb_strndup(struct ldb_context *ldb, const char *str, size_t maxlen); +void *ldb_strdup(struct ldb_context *ldb, const char *str); +void *ldb_realloc_array(struct ldb_context *ldb, + void *ptr, size_t el_size, unsigned count); + +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a,b) +#endif +int ldb_asprintf(struct ldb_context *ldb, char **strp, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); + /* this allows the user to set a debug function for error reporting */ @@ -352,10 +339,4 @@ int ldb_set_debug(struct ldb_context *ldb, /* this sets up debug to print messages on stderr */ int ldb_set_debug_stderr(struct ldb_context *ldb); - -/* these are used as type safe versions of the ldb allocation functions */ -#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) -#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count) -#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count) - #endif -- cgit From 09c1b9cbe5175636bcf4b606edfd0022bd9cfd6b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 31 Dec 2004 03:51:42 +0000 Subject: r4427: - added ldb_msg_*() functions for sorting, comparing and copying messages - added a ldb_msg_canonicalize() function that fixes a record to not have any duplicate elements - changed ldbedit to use ldb_msg_canonicalize(). This fixes a bug when you rename multiple elements in a record in one edit (This used to be commit f006e724400843419c8b6155cbeae1876983855e) --- source4/lib/ldb/include/ldb.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 03d0cc7a3b..9dff510417 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -293,6 +293,18 @@ double ldb_msg_find_double(const struct ldb_message *msg, const char *ldb_msg_find_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); + +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, + const struct ldb_message *msg); + +struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, + const struct ldb_message *msg); + + struct ldb_val ldb_val_dup(struct ldb_context *ldb, const struct ldb_val *v); -- cgit From 1a988ec9af7960616fb4661b20d86ff05146d836 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 2 Jan 2005 07:49:29 +0000 Subject: r4474: - converted ldb to use talloc internally - added gcov flags to Makefile.ldb - expanded ldb test suite to get more coverage (This used to be commit 0ab98f50a7e0fe15347a99e5c29a6590a87729a0) --- source4/lib/ldb/include/ldb.h | 46 +++++-------------------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9dff510417..7aa2b6f4cd 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -105,7 +105,7 @@ enum ldb_changetype { */ struct ldb_ldif { enum ldb_changetype changetype; - struct ldb_message msg; + struct ldb_message *msg; }; enum ldb_scope {LDB_SCOPE_DEFAULT=-1, @@ -123,16 +123,6 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_module; -/* - the user can optionally supply a allocator function. It is presumed - it will act like a modern realloc(), with a context ptr to allow - for pool allocators -*/ -struct ldb_alloc_ops { - void *(*alloc)(const void *context, void *ptr, size_t size); - void *context; -}; - /* debugging uses one of the following levels */ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; @@ -240,6 +230,9 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif int ldb_dn_cmp(const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); +/* create an empty message */ +struct ldb_message *ldb_msg_new(void *mem_ctx); + /* find an element within an message */ struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, const char *attr_name); @@ -305,40 +298,11 @@ struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, const struct ldb_message *msg); -struct ldb_val ldb_val_dup(struct ldb_context *ldb, - const struct ldb_val *v); - -/* - this allows the user to choose their own allocation function - the allocation function should behave like a modern realloc() - function, which means that: - malloc(size) == alloc(context, NULL, size) - free(ptr) == alloc(context, ptr, 0) - realloc(ptr, size) == alloc(context, ptr, size) - The context argument is provided to allow for pool based allocators, - which often take a context argument -*/ -int ldb_set_alloc(struct ldb_context *ldb, - void *(*alloc)(const void *context, void *ptr, size_t size), - void *context); - -/* these are used as type safe versions of the ldb allocation functions */ -#define ldb_malloc_p(ldb, type) (type *)ldb_malloc(ldb, sizeof(type)) -#define ldb_malloc_array_p(ldb, type, count) (type *)ldb_realloc_array(ldb, NULL, sizeof(type), count) -#define ldb_realloc_p(ldb, p, type, count) (type *)ldb_realloc_array(ldb, p, sizeof(type), count) - -void *ldb_realloc(struct ldb_context *ldb, void *ptr, size_t size); -void *ldb_malloc(struct ldb_context *ldb, size_t size); -void ldb_free(struct ldb_context *ldb, void *ptr); -void *ldb_strndup(struct ldb_context *ldb, const char *str, size_t maxlen); -void *ldb_strdup(struct ldb_context *ldb, const char *str); -void *ldb_realloc_array(struct ldb_context *ldb, - void *ptr, size_t el_size, unsigned count); +struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a,b) #endif -int ldb_asprintf(struct ldb_context *ldb, char **strp, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4); /* this allows the user to set a debug function for error reporting -- cgit From cec158231b5618a9a93e478b6b60914305508086 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 11 Jan 2005 13:52:29 +0000 Subject: r4678: Add some const to LDB. Andrew Bartlett (This used to be commit d4da9fb1600dba5daca9acb83f528c8f5f42f0ce) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7aa2b6f4cd..0bb8105c44 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -256,7 +256,7 @@ int ldb_msg_add(struct ldb_context *ldb, int ldb_msg_add_value(struct ldb_context *ldb, struct ldb_message *msg, const char *attr_name, - struct ldb_val *val); + const struct ldb_val *val); int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, const char *attr_name, char *str); -- cgit From ea2209e3db4dc1a6d455e01d5339b0b981c361b1 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 29 Jan 2005 04:04:38 +0000 Subject: r5092: Add a bit more const - moving it further into the LDB layer. Andrew Bartlett (This used to be commit ffad9b22be595279b247fa72d51145830fecbb06) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0bb8105c44..310000b244 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -258,7 +258,7 @@ int ldb_msg_add_value(struct ldb_context *ldb, const char *attr_name, const struct ldb_val *val); int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, - const char *attr_name, char *str); + const char *attr_name, const char *str); /* compare two message elements - return 0 on match */ int ldb_msg_element_compare(struct ldb_message_element *el1, -- cgit From ff4797a9e4b01fe8cc9421e911371677433d070c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 12 Feb 2005 11:30:33 +0000 Subject: r5357: added ldb_msg_add_fmt(), for creating formatted ldb record values (This used to be commit 18fb48204f4c0e22ea7e61575b3f174f30ff035c) --- source4/lib/ldb/include/ldb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 310000b244..c6f96f6dea 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -259,6 +259,8 @@ int ldb_msg_add_value(struct ldb_context *ldb, const struct ldb_val *val); int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, const char *attr_name, const char *str); +int ldb_msg_add_fmt(struct ldb_context *ldb, struct ldb_message *msg, + const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(4,5); /* compare two message elements - return 0 on match */ int ldb_msg_element_compare(struct ldb_message_element *el1, -- cgit From 5a88d5211ba0f6b1d09cdd92489b34d0e603716b Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 13 Feb 2005 12:27:57 +0000 Subject: r5374: - changed the dn key code in the ldb tdb backend to correctly honor the case sensitive/insensitive flags on sections of a dn. So if a dn is made up of 4 attributes, and 2 of those are case insensitive and 2 are case sensitive, then all the attribute names are uppercases, but only the values of the case insensitive attributes are uppercased when forming the tdb key. - added code to canonicalise the dn, removing leading and trailing spaces from attribute names and values - when the @ATTRIBUTES record changes, fix the dn keys of any records that should now have new dn keys due to changes in the case sensitivity of the record I really did this to allow me to make the WINS database properly case insensitive, but it is also the correct general fix for ldb, as it matches the LDAP specification (and w2k LDAP server behaviour) (This used to be commit 0f034dc5636d182a1d9207ad662b3fc8df7ca3e4) --- source4/lib/ldb/include/ldb.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c6f96f6dea..09b4cbf84a 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -140,6 +140,11 @@ struct ldb_debug_ops { #define LDB_FLG_RDONLY 1 +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a,b) +#endif + + /* connect to a database. The URL can either be one of the following forms ldb://path @@ -302,10 +307,6 @@ struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); -#ifndef PRINTF_ATTRIBUTE -#define PRINTF_ATTRIBUTE(a,b) -#endif - /* this allows the user to set a debug function for error reporting */ -- cgit From b1b14817eaa6e6579596d54166e17bc8d5605c01 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 27 Feb 2005 11:35:47 +0000 Subject: r5585: LDB interfaces change: changes: - ldb_wrap disappears from code and become a private structure of db_wrap.c thanks to our move to talloc in ldb code, we do not need to expose it anymore - removal of ldb_close() function form the code thanks to our move to talloc in ldb code, we do not need it anymore use talloc_free() to close and free an ldb database - some minor updates to ldb modules code to cope with the change and fix some bugs I found out during the process (This used to be commit d58be9e74b786a11a57e89df36081d55730dfe0a) --- source4/lib/ldb/include/ldb.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 09b4cbf84a..0eb661d7ce 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -158,12 +158,6 @@ struct ldb_debug_ops { struct ldb_context *ldb_connect(const char *url, unsigned int flags, const char *options[]); -/* - close the connection to the database -*/ -int ldb_close(struct ldb_context *ldb); - - /* search the database given a LDAP-like search expression -- cgit From fe4d985b6f3d318d9b58a16677be3b4ae34fba15 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 25 Apr 2005 12:46:18 +0000 Subject: r6470: Remove ldb_search_free() it is not needed anymore. Just use talloc_free() to release the memory after an ldb_search(). (This used to be commit 4f0948dab0aa5e8b6a4ce486f3668ca8dfae23db) --- source4/lib/ldb/include/ldb.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0eb661d7ce..f748bb6b42 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -162,6 +162,8 @@ struct ldb_context *ldb_connect(const char *url, unsigned int flags, search the database given a LDAP-like search expression return the number of records found, or -1 on error + + use talloc_free to free the ldb_message returned */ int ldb_search(struct ldb_context *ldb, const char *base, @@ -169,12 +171,6 @@ int ldb_search(struct ldb_context *ldb, const char *expression, const char * const *attrs, struct ldb_message ***res); -/* - free a set of messages returned by ldb_search -*/ -int ldb_search_free(struct ldb_context *ldb, struct ldb_message **msgs); - - /* add a record to the database. Will fail if a record with the given class and key already exists -- cgit From 9a9cf9e0753c7cf040feecf670c0986a17c16dce Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 16 May 2005 22:31:45 +0000 Subject: r6833: split out the routine that calculates the diff between two ldb messages from ldbedit, so other progs can use it. (This used to be commit fa4f33558af3c65ff31424c01db16cb9d427503d) --- source4/lib/ldb/include/ldb.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index f748bb6b42..18d974cf42 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -295,6 +295,10 @@ struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, const struct ldb_message *msg); +struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, + struct ldb_message *msg1, + struct ldb_message *msg2); + struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); /* -- cgit From a1ba224107fbcf6f8a9a3091f42cde2a0c47f85e Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 4 Jun 2005 17:13:43 +0000 Subject: r7276: - moved static tdb function ltdb_dn_fold() into common/ so that it can be called from multiple backends. (ldb_sqlite3 needs it too.) Added parameter for a callback function that determines whether an attribute needs case folding. - begin to prepare for sqlite3 in build process - work-in-progress updates, on ldb_sqlite3 (This used to be commit a80bced0b96ffb655559a43cf7f4d7a34deb5a7d) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 18d974cf42..8ccf8967cb 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -225,6 +225,9 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif int ldb_dn_cmp(const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); +/* case-fold a DN */ +char *ldb_dn_fold(struct ldb_module *module, const char *dn, int (*case_fold_attr_fn)(struct ldb_module * module, char * attr)); + /* create an empty message */ struct ldb_message *ldb_msg_new(void *mem_ctx); -- cgit From a6717fae681f89cf427e282d645029ca0b3e4d44 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Thu, 9 Jun 2005 02:47:26 +0000 Subject: r7418: work in progress (This used to be commit 2a13e7655b1bce88694ddbb6a4d9349008ba42f0) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8ccf8967cb..91a826447a 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -203,7 +203,7 @@ const char *ldb_errstring(struct ldb_context *ldb); /* casefold a string (should be UTF8, but at the moment it isn't) */ -char *ldb_casefold(struct ldb_context *ldb, const char *s); +char *ldb_casefold(void *mem_ctx, const char *s); /* ldif manipulation functions -- cgit From 4b0e5bd75373ffa2d847706a71fd0349dfa15e71 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 13 Jun 2005 09:10:17 +0000 Subject: r7527: - added a ldb_search_bytree() interface, which takes a ldb_parse_tree instead of a search expression. This allows our ldap server to pass its ASN.1 parsed search expressions straight to ldb, instead of going via strings. - updated all the ldb modules code to handle the new interface - got rid of the separate ldb_parse.h now that the ldb_parse structures are exposed externally - moved to C99 structure initialisation in ldb - switched ldap server to using ldb_search_bytree() (This used to be commit 96620ab2ee5d440bbbc51c1bc0cad9977770f897) --- source4/lib/ldb/include/ldb.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 91a826447a..02df0ae810 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -145,6 +145,31 @@ struct ldb_debug_ops { #endif +/* structues for ldb_parse_tree handling code */ +enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; + +struct ldb_parse_tree { + enum ldb_parse_op operation; + union { + struct { + char *attr; + struct ldb_val value; + } simple; + struct { + unsigned int num_elements; + struct ldb_parse_tree **elements; + } list; + struct { + struct ldb_parse_tree *child; + } not; + } u; +}; + +struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); +char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); +char *ldb_binary_encode(void *ctx, struct ldb_val val); + + /* connect to a database. The URL can either be one of the following forms ldb://path @@ -171,6 +196,15 @@ int ldb_search(struct ldb_context *ldb, const char *expression, const char * const *attrs, struct ldb_message ***res); +/* + like ldb_search() but takes a parse tree +*/ +int ldb_search_bytree(struct ldb_context *ldb, + const char *base, + enum ldb_scope scope, + struct ldb_parse_tree *tree, + const char * const *attrs, struct ldb_message ***res); + /* add a record to the database. Will fail if a record with the given class and key already exists -- cgit From 4fec6356ea190d202783fe19013387462a22c441 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 14 Jun 2005 01:35:44 +0000 Subject: r7558: added support in ldb for extended ldap search requests. These are using to perform such things as bitop tests on integers. So far I have only added support for the 1.2.840.113556.1.4.803 and 1.2.840.113556.1.4.804 rules, which are for bitwise and/or (This used to be commit 5f773b065f1db959e59c02de68bcf30cef1a6c2c) --- source4/lib/ldb/include/ldb.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 02df0ae810..5773e39fa9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -146,7 +146,8 @@ struct ldb_debug_ops { /* structues for ldb_parse_tree handling code */ -enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; +enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_EXTENDED=2, + LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; struct ldb_parse_tree { enum ldb_parse_op operation; @@ -155,6 +156,12 @@ struct ldb_parse_tree { char *attr; struct ldb_val value; } simple; + struct { + char *attr; + int dnAttributes; + char *rule_id; + struct ldb_val value; + } extended; struct { unsigned int num_elements; struct ldb_parse_tree **elements; -- cgit From 785b452a042f00b561df55243e8aaee920d84ce6 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 14 Jun 2005 03:04:24 +0000 Subject: r7561: moved OID constants into ldb.h and used manifest constants in ldb_match.c (This used to be commit 42cbb155c20779c458f727488c8554842b24681b) --- source4/lib/ldb/include/ldb.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 5773e39fa9..7a28d05b38 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -71,6 +71,12 @@ struct ldb_val { #define LDB_FLAG_MOD_DELETE 3 +/* + well known object IDs +*/ +#define LDB_OID_COMPARATOR_AND "1.2.840.113556.1.4.803" +#define LDB_OID_COMPARATOR_OR "1.2.840.113556.1.4.804" + /* results are given back as arrays of ldb_message_element */ -- cgit From 3e92471d4cfa169b97da73752b6eb6d1ea8cb466 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 15 Jun 2005 01:02:53 +0000 Subject: r7596: next step in ldap cleanup. I'm aiming to get rid of the cut&pasted ldif parsing code in libcli/ldap/ldap_ldif.c, and instead use the ldb ldif code. To do that I have changed the ldap code to use 'struct ldb_message_element' instead of 'struct ldap_attribute'. They are essentially the same structure anyway, so by making them really the same it will be much easier to use the ldb code in libcli/ldap/ I have also made 'struct ldb_val' the same as a DATA_BLOB, which will simplify data handling in quite a few places (I haven't yet removed all the code that maps between these two, that will come later) (This used to be commit 87fc3073392236221a3a6b933284e9e477c24ae5) --- source4/lib/ldb/include/ldb.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7a28d05b38..4bf2f9581f 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -57,10 +57,12 @@ sensible, but it can be to anything you like, including binary data blobs of arbitrary size. */ +#ifndef ldb_val struct ldb_val { - unsigned int length; - void *data; + uint8_t *data; + size_t length; }; +#endif /* these flags are used in ldd_message_element.flags fields. The LDA_FLAGS_MOD_* flags are used in ldap_modify() calls to specify @@ -82,7 +84,7 @@ struct ldb_val { */ struct ldb_message_element { unsigned int flags; - char *name; + const char *name; unsigned int num_values; struct ldb_val *values; }; -- cgit From f021dffb6991138213967521c743f03f474f9af9 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 15 Jun 2005 02:43:42 +0000 Subject: r7601: ldb_sqlite3 work in progress (This used to be commit 0a64948152a446b5e127578d49b1ed8a90a1a222) --- source4/lib/ldb/include/ldb.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4bf2f9581f..fabaec5da2 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -275,7 +275,10 @@ int ldb_dn_cmp(const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); /* case-fold a DN */ -char *ldb_dn_fold(struct ldb_module *module, const char *dn, int (*case_fold_attr_fn)(struct ldb_module * module, char * attr)); +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); -- cgit From ed3d8091ce2b2014350a2f7f22202dde6846a130 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 18 Jun 2005 07:42:21 +0000 Subject: r7709: - convert ldb to use popt, so that it can interact with the samba cmdline credentials code (which will be done soon) - added a ldb_init() call, and changed ldb_connect() to take a ldb context. This allows for much better error handling in ldb_connect(), and also made the popt conversion easier - fixed up all the existing backends with the new syntax - improved error handling in *_connect() - fixed a crash bug in the new case_fold_required() code - ensured that ltdb_rename() and all ltdb_search() paths get the read lock - added a ldb_oom() macro to make it easier to report out of memory situations in ldb code (This used to be commit f648fdf187669d6d87d01dd4e786b03cd420f220) --- source4/lib/ldb/include/ldb.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index fabaec5da2..ecfa77f436 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -184,6 +184,10 @@ struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); char *ldb_binary_encode(void *ctx, struct ldb_val val); +/* + initialise a ldb context +*/ +struct ldb_context *ldb_init(void *mem_ctx); /* connect to a database. The URL can either be one of the following forms @@ -195,8 +199,7 @@ char *ldb_binary_encode(void *ctx, struct ldb_val val); the options are passed uninterpreted to the backend, and are backend specific */ -struct ldb_context *ldb_connect(const char *url, unsigned int flags, - const char *options[]); +int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); /* search the database given a LDAP-like search expression -- cgit From 56cc32800036472ebc29362d65e422c0b410e3fc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 19 Jun 2005 01:31:27 +0000 Subject: r7740: get rid of our duplicate base64 routines (This used to be commit cf17f90a83cf04815544c5408eb56d00546b3e88) --- source4/lib/ldb/include/ldb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index ecfa77f436..e980633a62 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -270,6 +270,8 @@ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, struct ldb_ldif *ldb_ldif_read_file(struct ldb_context *ldb, FILE *f); 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); /* useful functions for ldb_message structure manipulation */ -- cgit From bd7a474b1967423711ff93c0080ce0f89270e3f9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 20 Jun 2005 04:56:43 +0000 Subject: r7776: add a method for getting arbitrary opaque data into a ldb context, for use by backends. Currently only EventContext is used in this way. (This used to be commit 9fa21b245843371f7777682ee4e5b98e2925b4d0) --- source4/lib/ldb/include/ldb.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e980633a62..9a3186b41c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -372,4 +372,8 @@ int ldb_set_debug(struct ldb_context *ldb, /* this sets up debug to print messages on stderr */ int ldb_set_debug_stderr(struct ldb_context *ldb); +/* control backend specific opaque values */ +int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value); +void *ldb_get_opaque(struct ldb_context *ldb, const char *name); + #endif -- cgit From eb0a13025aa6d693c7e9fa213ef04fa58cf60e3e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Jun 2005 06:35:55 +0000 Subject: r7803: added support in ldb for callers to setup ldif read/write functions, so that ldbedit, ldbsearch etc can display nice human readable ldif, while storing the data as binary blobs. This will be used for storing NDR encoded objectSid and similar attributes, while making the command line interface sane (This used to be commit 37e283089a846fc0608fef3981a3447300e33728) --- source4/lib/ldb/include/ldb.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9a3186b41c..48290beb92 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -184,6 +184,19 @@ struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); char *ldb_binary_encode(void *ctx, struct ldb_val val); + +/* + functions for controlling ldif encode/decode +*/ +typedef int (*ldb_ldif_handler_t)(struct ldb_context *, const struct ldb_val *, struct ldb_val *); + +struct ldb_ldif_handler { + const char *attr; + ldb_ldif_handler_t read_fn; + ldb_ldif_handler_t write_fn; +}; + + /* initialise a ldb context */ -- cgit From 5be159f304411b58c417a979c819f9ab211a0337 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 21 Jun 2005 07:52:00 +0000 Subject: r7804: added the samba specific ldif handlers into the tree, but don't enable them just yet. I have tested them, and they work fine, but enabling them will break code in rpc_server/ and samdb, so we need to fix that first (This used to be commit 07d459406b4c63e49141e0e533e1274b4052abf9) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 48290beb92..3102676327 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -285,6 +285,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); /* useful functions for ldb_message structure manipulation */ -- cgit From fdc0450db25021eddcc65d032fd3fd8ca5976928 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 22 Jun 2005 02:39:07 +0000 Subject: r7828: Although there is still plenty to do, ldb_sqlite3 now passes the set of tests in tests/test-sqlite3.sh (tests/test-generic.sh). There are lots of optimizations still TBD, and some things are REALLY slow right now (e.g. each add() operation takes 1/3 - 1/2 second) but it's ready for interested parties to poke it and prod it and see how (un)reasonable it is. Play away. Still to be implemented or improved: - tdb specials (@MODULES, @SUBCLASSES, etc.) - all DNs are case-folded in their entirty right now (since doing otherwise would require @ATTRIBUTES to be implemented) - speed improvements and optimizations. I am quite confident that the excessively slow add() operation can be much improved, and other areas can be somewhat improved. (This used to be commit 1dd865005594671e7effe06fb088fa97fa08de0b) --- source4/lib/ldb/include/ldb.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3102676327..1b5c7c4f57 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -254,6 +254,16 @@ int ldb_modify(struct ldb_context *ldb, */ int ldb_rename(struct ldb_context *ldb, const char *olddn, const char *newdn); +/* + create a named lock +*/ +int ldb_lock(struct ldb_context *ldb, const char *lockname); + +/* + release a named lock +*/ +int ldb_unlock(struct ldb_context *ldb, const char *lockname); + /* delete a record from the database */ -- cgit From 1702f52498168c0437416dec1014cedead634774 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 26 Jun 2005 23:59:22 +0000 Subject: r7936: new ldb_dn_explode and ldb_dn_casefold functions and co (This used to be commit 7ccf21ab4eeb9821e457308a239f2103a106fb12) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 1b5c7c4f57..8feec9e002 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -279,6 +279,7 @@ const char *ldb_errstring(struct ldb_context *ldb); casefold a string (should be UTF8, but at the moment it isn't) */ char *ldb_casefold(void *mem_ctx, const char *s); +int ldb_caseless_cmp(const char *s1, const char *s2); /* ldif manipulation functions -- cgit From a06d66a3a669c3a0a0f816438e2b3e91e208f398 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 1 Jul 2005 06:21:26 +0000 Subject: 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) --- source4/lib/ldb/include/ldb.h | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') 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 */ -- cgit From 1c5105065a44173667de2a022dd2417e56b527d6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 2 Jul 2005 17:30:03 +0000 Subject: r8082: large rewite of ldb_dn.c - we do not support multpiple attribute components anymore, makes code a lot easier they will be readded later if we found out they are really used, so far my tests show w2k3 do not handle them as well - fix escaping issues, move component value to be in an ldb_val structure still need to handle binary values case - make cononicalize functions leak less memory by giving a specific memory context - fix tests scripts so that test-ldap can start - make test not delete databases on completion so that I can inspect them (This used to be commit 624a73148d125690ce18515f19231d26df207738) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 868d005399..1f642d3bff 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -188,8 +188,8 @@ char *ldb_binary_encode(void *ctx, struct ldb_val val); /* functions for controlling attribute handling */ -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 *); +typedef int (*ldb_attr_handler_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, struct ldb_val *); +typedef int (*ldb_attr_comparison_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, const struct ldb_val *); struct ldb_attrib_handler { const char *attr; -- cgit From 7c78ec0e145064696552d750eaaa70f00a0882e8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 12 Jul 2005 05:56:06 +0000 Subject: r8342: allow ldb_ldif_read_string() to continue in the string, so you can read multiple records (This used to be commit 4b11c00421b5152fd7d4be0be0db983bb310021d) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 1f642d3bff..b2468b6ecb 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -316,7 +316,7 @@ void ldb_ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *); struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, int (*fgetc_fn)(void *), void *private_data); struct ldb_ldif *ldb_ldif_read_file(struct ldb_context *ldb, FILE *f); -struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char *s); +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); -- cgit From c9b0e86a436b5b169a4c33bd25eac379cb622b17 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 12 Jul 2005 12:04:54 +0000 Subject: r8373: New wildcard matching code. This code applies correct ldap standard wildcard matching code removes WILDCARD matching from tdb @ATTRIBUTES, that's now handled independently adds some more tests for wildcard matching fixes dn comparison code in ldb_match (This used to be commit 4eb5863042011988d85092d7dde3d809aa15bd59) --- source4/lib/ldb/include/ldb.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index b2468b6ecb..8233e78f0e 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -154,7 +154,8 @@ struct ldb_debug_ops { /* structues for ldb_parse_tree handling code */ -enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_EXTENDED=2, +enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_EXTENDED=2, + LDB_OP_SUBSTRING=3, LDB_OP_PRESENT=4, LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; struct ldb_parse_tree { @@ -164,6 +165,15 @@ struct ldb_parse_tree { char *attr; struct ldb_val value; } simple; + struct { + char *attr; + } present; + struct { + char *attr; + int start_with_wildcard; + int end_with_wildcard; + struct ldb_val **chunks; + } substring; struct { char *attr; int dnAttributes; @@ -211,14 +221,12 @@ struct ldb_attrib_handler { }; #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" /* -- cgit From 52bef30fd48393fa7b24ade7622c758373bd6dbe Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 13 Jul 2005 05:55:28 +0000 Subject: r8414: Some C++ friendlyness fixes - 'not' is apparently a keyword in C++. (This used to be commit bcfb3a45e4a5962fe763f8071d4458f4bd11605b) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8233e78f0e..c2d7b0d614 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -186,7 +186,7 @@ struct ldb_parse_tree { } list; struct { struct ldb_parse_tree *child; - } not; + } isnot; } u; }; -- cgit From cb2c43f7b032c26adf82f3ba7d6e3dc855f89fa4 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 16 Jul 2005 18:16:32 +0000 Subject: r8515: ldb_dn_cmp now uses ldb_dn_compare so that the DNs are compared on a content level not ona form level, his means that the 2 DNs: a) cn= user, dc=this, dc = is,dc=test b) cn=user,dc=this,dc=is,dc=test are now identical even if the string form differ (spaces) (This used to be commit 76d496c30867ae80434483a34b0d842523aed762) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c2d7b0d614..485e2bc730 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -335,7 +335,7 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, /* useful functions for ldb_message structure manipulation */ -int ldb_dn_cmp(const char *dn1, const char *dn2); +int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); int ldb_attr_cmp(const char *dn1, const char *dn2); /* case-fold a DN */ -- cgit From bfb11862698743ee36bc6050269378321e6e577c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 19 Jul 2005 09:09:00 +0000 Subject: r8585: add to ldb and ldap comparison functionality better pares filters Approx is currently only a stub need to dig more info to understand what it really means and how it works exactly (This used to be commit a9e8cd0bad27ed2b3c6a12302e787ba3c9a70a3c) --- source4/lib/ldb/include/ldb.h | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 485e2bc730..6670089902 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -154,26 +154,34 @@ struct ldb_debug_ops { /* structues for ldb_parse_tree handling code */ -enum ldb_parse_op {LDB_OP_SIMPLE=1, LDB_OP_EXTENDED=2, - LDB_OP_SUBSTRING=3, LDB_OP_PRESENT=4, - LDB_OP_AND='&', LDB_OP_OR='|', LDB_OP_NOT='!'}; +enum ldb_parse_op { LDB_OP_AND=1, LDB_OP_OR=2, LDB_OP_NOT=3, + LDB_OP_EQUALITY=4, LDB_OP_SUBSTRING=5, + LDB_OP_GREATER=6, LDB_OP_LESS=7, LDB_OP_PRESENT=8, + LDB_OP_APPROX=9, LDB_OP_EXTENDED=10 }; struct ldb_parse_tree { enum ldb_parse_op operation; union { struct { - char *attr; - struct ldb_val value; - } simple; + struct ldb_parse_tree *child; + } isnot; struct { char *attr; - } present; + struct ldb_val value; + } equality; struct { char *attr; int start_with_wildcard; int end_with_wildcard; struct ldb_val **chunks; } substring; + struct { + char *attr; + } present; + struct { + char *attr; + struct ldb_val value; + } comparison; struct { char *attr; int dnAttributes; @@ -184,9 +192,6 @@ struct ldb_parse_tree { unsigned int num_elements; struct ldb_parse_tree **elements; } list; - struct { - struct ldb_parse_tree *child; - } isnot; } u; }; -- cgit From 7a8ac7588720ebd1ea61a539ca4040d322c4fcf2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 21 Jul 2005 01:56:22 +0000 Subject: r8659: return ldif formatted attributes in the ejs ldb search call, so sids show up as strings not binary blobs (This used to be commit d2c29a5a51f68cabb9ef587376bf0a6b936cdd76) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6670089902..7399b8ffe7 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -440,4 +440,7 @@ int ldb_set_debug_stderr(struct ldb_context *ldb); int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value); void *ldb_get_opaque(struct ldb_context *ldb, const char *name); +const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, + const char *attrib); + #endif -- cgit From 6195932b4241d94453438a857179debc08495ece Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 18 Aug 2005 11:15:15 +0000 Subject: r9387: regedit uses "New Key #nn" for newly created keys, which conflicts with the stricter DN rules in ldb. Escape the DN components to cope. Simo, sorry for making a change in ldb_dn.c while you have changes pending. Please feel free to revert these and switch reg_backend_ldb.c to use the new dn construction code. (This used to be commit 136ecf5cb23758558b4119b08047fc273be8b0f8) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7399b8ffe7..fdf5dc8d91 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -342,6 +342,7 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, 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, -- cgit From 3e4c4cff2177af33efdb15f03a1bbcb639505cee Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 18 Aug 2005 15:02:01 +0000 Subject: 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) --- source4/lib/ldb/include/ldb.h | 57 +++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 15 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') 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, -- cgit From ac90ddfdb28050912ecab0e998089b93216c5c35 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 18 Aug 2005 16:18:48 +0000 Subject: r9392: Fix ldb_dn_compose to make build farm happy Add ldb_dn_string_compose so that you can build a dn starting from a struct ldb_dn base and a set of parameters to be composed in a format string with the same syntax of printf (This used to be commit 31c69d0655752cc8ea3bc5b7ea87792291302091) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 13c9b72e6d..e7862522e4 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -371,7 +371,7 @@ 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 *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...); struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn); /* useful functions for ldb_message structure manipulation */ -- cgit From 7c7b93f6497737a09d3e76a626ee4f20284effde Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 18 Aug 2005 16:27:09 +0000 Subject: r9393: Fix ldb standalone build (This used to be commit 796d0ea2fcf5132b157a397cc1a54aa26c042691) --- source4/lib/ldb/include/ldb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e7862522e4..fc447102d6 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -348,6 +348,11 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, unsigned num_handlers); /* The following definitions come from lib/ldb/common/ldb_dn.c */ + +#ifndef BOOL +typedef int BOOL; +#endif + 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); -- cgit From f2ac4b8d6b24bec9aecfe00daf8c0b4ccf3964a6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 18 Aug 2005 16:41:27 +0000 Subject: r9394: avoid to use BOOL in ldb (This used to be commit d2055849fba56e8620403621f3fb9684f24e853f) --- source4/lib/ldb/include/ldb.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index fc447102d6..89e88fd4e9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -349,12 +349,8 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, /* The following definitions come from lib/ldb/common/ldb_dn.c */ -#ifndef BOOL -typedef int BOOL; -#endif - -BOOL ldb_dn_is_special(const struct ldb_dn *dn); -BOOL ldb_dn_check_special(const struct ldb_dn *dn, const char *check); +int ldb_dn_is_special(const struct ldb_dn *dn); +int 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); -- cgit From 69fb6840637e07318914d632571c8481f3573461 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 25 Aug 2005 19:02:03 +0000 Subject: r9621: Bunch of bug fixes. Add 'format' option to samba3dump (text,summary,ldif) (This used to be commit dc6aab8d4a6d0fe47756c90d3d311b6009d571ff) --- source4/lib/ldb/include/ldb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 89e88fd4e9..46b359b8ba 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -162,8 +162,7 @@ struct ldb_debug_ops { #define PRINTF_ATTRIBUTE(a,b) #endif - -/* structues for ldb_parse_tree handling code */ +/* structures for ldb_parse_tree handling code */ enum ldb_parse_op { LDB_OP_AND=1, LDB_OP_OR=2, LDB_OP_NOT=3, LDB_OP_EQUALITY=4, LDB_OP_SUBSTRING=5, LDB_OP_GREATER=6, LDB_OP_LESS=7, LDB_OP_PRESENT=8, -- cgit From a45c4fd5e24c8ae50bd86c6c84d1a3278e1bdab6 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 25 Aug 2005 23:05:41 +0000 Subject: r9625: Get rid of "duplicate const" warning. (This used to be commit 0ec755cfa0499bf1f271584db3c028d87973f1af) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 46b359b8ba..66b0343891 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -268,7 +268,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 const struct ldb_dn *base, + const struct ldb_dn *base, enum ldb_scope scope, const char *expression, const char * const *attrs, struct ldb_message ***res); -- cgit From 46a8d809376cab59c579c654b0de5105727a9585 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 18 Sep 2005 10:47:03 +0000 Subject: r10304: check for basic ldb_message sanity and return appropriate LDB_ERR_ value (This used to be commit 610f5646f0816820ac9342e81d46d139e26cc918) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 66b0343891..008327eb05 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -3,6 +3,7 @@ Copyright (C) Andrew Tridgell 2004 Copyright (C) Stefan Metzmacher 2004 + Copyright (C) Simo Sorce 2005 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -451,6 +452,8 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, struct ldb_message *msg1, struct ldb_message *msg2); +int ldb_msg_sanity_check(const struct ldb_message *msg); + struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); /* -- cgit From d78ea3e34abd30fb388c4cc39e12611e211416a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 22 Sep 2005 04:16:46 +0000 Subject: r10406: added --nosync option to all ldb tools, so that you can control if transactions are synchronous or not on the command line. add LDB_FLG_NOSYNC flag to ldb_connect() so we can make our temporary ldb databases non-synchronous (This used to be commit dba41164e0c52f1e4351bd9057b16661cee3a822) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 008327eb05..f7abd920eb 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -158,6 +158,7 @@ struct ldb_debug_ops { }; #define LDB_FLG_RDONLY 1 +#define LDB_FLG_NOSYNC 2 #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a,b) -- cgit From 2ce3b5a00347cc3120efd12cd58d52a5c43305b3 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 22 Sep 2005 09:06:37 +0000 Subject: r10419: Remove unused prototypes of locking functions (thanks Jelmer) omment about transactions (This used to be commit 33352507593875a147276841fdb70de8edd668f5) --- source4/lib/ldb/include/ldb.h | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index f7abd920eb..0e794c6209 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -49,6 +49,7 @@ major restrictions as compared to tdb: - no explicit locking calls + UPDATE: we have transactions now, better than locking --SSS. */ @@ -302,16 +303,6 @@ int ldb_modify(struct ldb_context *ldb, */ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn); -/* - create a named lock -*/ -int ldb_lock(struct ldb_context *ldb, const char *lockname); - -/* - release a named lock -*/ -int ldb_unlock(struct ldb_context *ldb, const char *lockname); - /* delete a record from the database */ -- cgit From 63b43dd12fb579aaaccedd07aaa630cb1cd7aa88 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 24 Sep 2005 15:42:15 +0000 Subject: r10477: expose transactions outside ldb and change the API once more do not autostart transactions on ldb operations if a transaction is already in place test transactions on winsdb all my tests passes so far tridge please confirm this is ok for you (This used to be commit c2bb2a36bdbe0ec7519697a9a9ba7526a0defac2) --- source4/lib/ldb/include/ldb.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0e794c6209..f371c340cc 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -308,6 +308,21 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct */ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); +/* + start a transaction +*/ +int ldb_transaction_start(struct ldb_context *ldb); + +/* + commit a transaction +*/ +int ldb_transaction_commit(struct ldb_context *ldb); + +/* + cancel a transaction +*/ +int ldb_transaction_cancel(struct ldb_context *ldb); + /* return extended error information from the last call -- cgit From 0e90afb4e7737d60d902aee1df4cbeb85a7b693d Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 29 Sep 2005 10:18:26 +0000 Subject: r10603: neaten up the ldb module initialisation code (This used to be commit 8e7c4c98a7b4fd814f298fba1b6b686cb58339f8) --- source4/lib/ldb/include/ldb.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index f371c340cc..73bac2088a 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -143,6 +143,10 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) struct ldb_module; +/* module initialisation function */ +typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char **); + + /* debugging uses one of the following levels */ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; -- cgit From a599edf04cbdeef9014923ba0d3713b8ff84f266 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 06:10:23 +0000 Subject: r10913: This patch isn't as big as it looks ... most of the changes are fixes to make all the ldb code compile without warnings on gcc4. Unfortunately That required a lot of casts :-( I have also added the start of an 'operational' module, which will replace the timestamp module, plus add support for some other operational attributes In ldb_msg_*() I added some new utility functions to make the operational module sane, and remove the 'ldb' argument from the ldb_msg_add_*() functions. That argument was only needed back in the early days of ldb when we didn't use the hierarchical talloc and thus needed a place to get the allocation function from. Now its just a pain to pass around everywhere. Also added a ldb_debug_set() function that calls ldb_debug() plus sets the result using ldb_set_errstring(). That saves on some awkward coding in a few places. (This used to be commit f6818daecca95760c12f79fd307770cbe3346f57) --- source4/lib/ldb/include/ldb.h | 44 +++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 73bac2088a..d75ca4fe86 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -182,24 +182,24 @@ struct ldb_parse_tree { struct ldb_parse_tree *child; } isnot; struct { - char *attr; + const char *attr; struct ldb_val value; } equality; struct { - char *attr; + const char *attr; int start_with_wildcard; int end_with_wildcard; struct ldb_val **chunks; } substring; struct { - char *attr; + const char *attr; } present; struct { - char *attr; + const char *attr; struct ldb_val value; } comparison; struct { - char *attr; + const char *attr; int dnAttributes; char *rule_id; struct ldb_val value; @@ -241,7 +241,10 @@ struct ldb_attrib_handler { ldb_attr_comparison_t comparison_fn; }; -#define LDB_ATTR_FLAG_HIDDEN (1<<0) +#define LDB_ATTR_FLAG_HIDDEN (1<<0) /* the attribute is not returned by default */ +#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */ +#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */ + /* 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" @@ -383,7 +386,7 @@ 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_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...); +struct ldb_dn *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...) PRINTF_ATTRIBUTE(3,4); struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn); /* useful functions for ldb_message structure manipulation */ @@ -406,22 +409,19 @@ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, struct ldb_val *val); /* add a new empty element to a ldb_message */ -int ldb_msg_add_empty(struct ldb_context *ldb, - struct ldb_message *msg, const char *attr_name, int flags); +int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags); /* add a element to a ldb_message */ -int ldb_msg_add(struct ldb_context *ldb, - struct ldb_message *msg, +int ldb_msg_add(struct ldb_message *msg, const struct ldb_message_element *el, int flags); -int ldb_msg_add_value(struct ldb_context *ldb, - struct ldb_message *msg, +int ldb_msg_add_value(struct ldb_message *msg, const char *attr_name, const struct ldb_val *val); -int ldb_msg_add_string(struct ldb_context *ldb, struct ldb_message *msg, +int ldb_msg_add_string(struct ldb_message *msg, const char *attr_name, const char *str); -int ldb_msg_add_fmt(struct ldb_context *ldb, struct ldb_message *msg, - const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(4,5); +int ldb_msg_add_fmt(struct ldb_message *msg, + const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); /* compare two message elements - return 0 on match */ int ldb_msg_element_compare(struct ldb_message_element *el1, @@ -485,4 +485,16 @@ void *ldb_get_opaque(struct ldb_context *ldb, const char *name); const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, const char *attrib); + +const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs); +int ldb_attr_in_list(const char * const *attrs, const char *attr); + + +void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, + const char *attr, + const char *replace); + +void ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); +int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); + #endif -- cgit From 33da2fabe6c3b1e20a955d72e1ebd0e850751df0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 06:30:47 +0000 Subject: r10914: moved the ldap time string functions into ldb so they can be used by the time attribute handling functions (This used to be commit 93c296d52718e77f8b702e1721b548eaadc56c76) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index d75ca4fe86..0af88f8427 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -497,4 +497,7 @@ void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, void ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); +char *ldb_timestring(TALLOC_CTX *mem_ctx, time_t t); +time_t ldb_string_to_time(const char *s); + #endif -- cgit From 49cc13a8f0fbc4f68e14720b733329ce45135cec Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 07:54:15 +0000 Subject: r10915: added a standard attribute handler for a ldap UTC time string (This used to be commit efd7dd1a775c06f21924f35760f7768b4e8db449) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0af88f8427..d346d0edac 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -251,6 +251,7 @@ struct ldb_attrib_handler { #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_UTC_TIME "1.3.6.1.4.1.1466.115.121.1.53" #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" /* @@ -452,6 +453,8 @@ const char *ldb_msg_find_string(const struct ldb_message *msg, void ldb_msg_sort_elements(struct ldb_message *msg); +struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx, + const struct ldb_message *msg); struct ldb_message *ldb_msg_copy(void *mem_ctx, const struct ldb_message *msg); -- cgit From dc3e65b25295f68d0c7c5d3a7cc9bade638661f4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 08:11:45 +0000 Subject: r10917: copy the element name in a ldb_msg_rename_attr() and ldb_msg_copy_attr() to ensure that callers (like the ldap server) can talloc_steal the name (This used to be commit 9c914542cc346758c82f89990c80eb096a9c0959) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index d346d0edac..3629d9ec47 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -497,7 +497,7 @@ void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, const char *attr, const char *replace); -void ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); +int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); char *ldb_timestring(TALLOC_CTX *mem_ctx, time_t t); -- cgit From c8978cb1f15b1ddc0c420baa568bd11db080b744 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 12 Oct 2005 08:51:12 +0000 Subject: r10918: - fixed standalone ldb build - added note about allowedAttributesEffective (will be needed for mmc) - fixed some more ldb warnings (This used to be commit e9e4d81b6976549db8a7668572a5da466fbec4a9) --- source4/lib/ldb/include/ldb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3629d9ec47..adc8a3e061 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -453,7 +453,7 @@ const char *ldb_msg_find_string(const struct ldb_message *msg, void ldb_msg_sort_elements(struct ldb_message *msg); -struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx, +struct ldb_message *ldb_msg_copy_shallow(void *mem_ctx, const struct ldb_message *msg); struct ldb_message *ldb_msg_copy(void *mem_ctx, const struct ldb_message *msg); @@ -489,7 +489,7 @@ const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, const char *attrib); -const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs); +const char **ldb_attr_list_copy(void *mem_ctx, const char * const *attrs); int ldb_attr_in_list(const char * const *attrs, const char *attr); @@ -500,7 +500,7 @@ void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); -char *ldb_timestring(TALLOC_CTX *mem_ctx, time_t t); +char *ldb_timestring(void *mem_ctx, time_t t); time_t ldb_string_to_time(const char *s); #endif -- cgit From 1307149624bcda8c45d538c33a46c4f3b9058afb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 12 Oct 2005 14:58:14 +0000 Subject: r10924: we don't need this line twice metze (This used to be commit f1ee8d4b58d97888dc4c57af34c7604ee9dd2a73) --- source4/lib/ldb/include/ldb.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index adc8a3e061..fd3577a470 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -243,7 +243,6 @@ struct ldb_attrib_handler { #define LDB_ATTR_FLAG_HIDDEN (1<<0) /* the attribute is not returned by default */ #define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */ -#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */ /* well-known ldap attribute syntaxes - see rfc2252 section 4.3.2 */ -- cgit From d96f706bb0a6b41eddec9d467ef3d5f31bee41ab Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 13 Oct 2005 04:24:49 +0000 Subject: r10953: Add a new function to form a canonicalName out of a DN to ldb_dn.c Use this new function in the client and server for the CrackNames case, where we particularly need it. Andrew Bartlett (This used to be commit 380037ee09ef8293bdb288d6c015e7c80f180a30) --- source4/lib/ldb/include/ldb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index fd3577a470..27313613ab 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -502,4 +502,6 @@ int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *rep char *ldb_timestring(void *mem_ctx, time_t t); time_t ldb_string_to_time(const char *s); +char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); +char *ldb_dn_canonical_ex_string(void *mem_ctx, const struct ldb_dn *dn); #endif -- cgit From 0fa924bb8f446e35a0fd543cda20b23c81e7dc9e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 13 Oct 2005 05:04:16 +0000 Subject: r10954: added support for canonicalName in the operational module, using the dn->canonicalName function abartlet just committed (This used to be commit 197e8a27f0557869eacd17b74e1b14e0665883b1) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 27313613ab..c26229678e 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -498,6 +498,7 @@ void ldb_parse_tree_attr_replace(struct ldb_parse_tree *tree, int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *replace); int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); +void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); char *ldb_timestring(void *mem_ctx, time_t t); time_t ldb_string_to_time(const char *s); -- cgit From 804cf59a489dd41a83fda56acfec4e9f561b1245 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 28 Oct 2005 07:05:32 +0000 Subject: r11364: added a ldb_attr_dn() function for testing if an attribute name is "dn" or "distinguishedName". This makes us a bit more consistent (This used to be commit b41b374b55f9a056c47ffa2ff88aa5272dbc42fc) --- source4/lib/ldb/include/ldb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c26229678e..c4f877cf5f 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -391,7 +391,8 @@ 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); +int ldb_attr_cmp(const char *attr1, const char *attr2); +int ldb_attr_dn(const char *attr); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); /* create an empty message */ -- cgit From d3b91ae169b17881dfba4848a7cae30b95a97c70 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 5 Nov 2005 05:44:26 +0000 Subject: r11512: fix typo (This used to be commit 4143c22e3077bd5aecb3427ff0a8857dab799400) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c4f877cf5f..98a5113390 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -76,7 +76,7 @@ struct ldb_dn { struct ldb_dn_component *components; }; -/* these flags are used in ldd_message_element.flags fields. The +/* these flags are used in ldb_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 */ #define LDB_FLAG_MOD_MASK 0x3 -- cgit From 5c9590587197dcb95007fdc54318187d5716c7c6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 8 Nov 2005 00:11:45 +0000 Subject: r11567: Ldb API change patch. This patch changes the way lsb_search is called and the meaning of the returned integer. The last argument of ldb_search is changed from struct ldb_message to struct ldb_result which contains a pointer to a struct ldb_message list and a count of the number of messages. The return is not the count of messages anymore but instead it is an ldb error value. I tryed to keep the patch as tiny as possible bu as you can guess I had to change a good amount of places. I also tried to double check all my changes being sure that the calling functions would still behave as before. But this patch is big enough that I fear some bug may have been introduced anyway even if it passes the test suite. So if you are currently working on any file being touched please give it a deep look and blame me for any error. Simo. (This used to be commit 22c8c97e6fb466b41859e090e959d7f1134be780) --- source4/lib/ldb/include/ldb.h | 63 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 98a5113390..86e6a021da 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -253,6 +253,65 @@ struct ldb_attrib_handler { #define LDB_SYNTAX_UTC_TIME "1.3.6.1.4.1.1466.115.121.1.53" #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" +struct ldb_controls; +struct ldb_credentials; + +enum ldb_request_type { + LDB_REQ_SEARCH, + LDB_REQ_ADD, + LDB_REQ_MODIFY, + LDB_REQ_DELETE, + LDB_REQ_RENAME +}; + +struct ldb_result { + unsigned int count; + struct ldb_message **msgs; +}; + +struct ldb_search { + const struct ldb_dn *base; + enum ldb_scope scope; + struct ldb_parse_tree *tree; + const char * const *attrs; + struct ldb_result **res; +}; + +struct ldb_add { + const struct ldb_message *message; +}; + +struct ldb_modify { + const struct ldb_message *message; +}; + +struct ldb_delete { + const struct ldb_dn *dn; +}; + +struct ldb_rename { + const struct ldb_dn *olddn; + const struct ldb_dn *newdn; +}; + +struct ldb_request { + + int operation; + + union { + struct ldb_search search; + struct ldb_add add; + struct ldb_modify mod; + struct ldb_delete del; + struct ldb_rename rename; + } op; + + struct ldb_controls *controls; + struct ldb_credentials *creds; +}; + +int ldb_request(struct ldb_context *ldb, struct ldb_request *request); + /* initialise a ldb context */ @@ -281,7 +340,7 @@ int ldb_search(struct ldb_context *ldb, const struct ldb_dn *base, enum ldb_scope scope, const char *expression, - const char * const *attrs, struct ldb_message ***res); + const char * const *attrs, struct ldb_result **res); /* like ldb_search() but takes a parse tree @@ -290,7 +349,7 @@ int ldb_search_bytree(struct ldb_context *ldb, const struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, - const char * const *attrs, struct ldb_message ***res); + const char * const *attrs, struct ldb_result **res); /* add a record to the database. Will fail if a record with the given class and key -- cgit From 6eabad9c9d977c1c5c6ecf7494a0be42ad113d23 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 29 Nov 2005 12:34:03 +0000 Subject: r11958: - fixed memory leaks in the ldb_result handling in ldb operations - removed an unnecessary level of pointer in ldb_search structure (This used to be commit b8d4afb14a18dfd8bac79882a035e74d3ed312bd) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 86e6a021da..2fdf40b3bc 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -274,7 +274,7 @@ struct ldb_search { enum ldb_scope scope; struct ldb_parse_tree *tree; const char * const *attrs; - struct ldb_result **res; + struct ldb_result *res; }; struct ldb_add { -- cgit From bceca723044e9cf5d835e8d732be3ab57906505e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 19 Dec 2005 07:07:11 +0000 Subject: r12361: Add a new function: ldb_binary_encode_string() This is for use on user-supplied arguments to printf style format strings which will become ldb filters. I have used it on LSA, SAMR and the auth/ code so far. Also add comments to cracknames code. Andrew Bartlett (This used to be commit 8308cf6e0472790c1c9d521d19322557907f4418) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2fdf40b3bc..9c3b033091 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -214,7 +214,7 @@ struct ldb_parse_tree { struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); char *ldb_binary_encode(void *ctx, struct ldb_val val); - +char *ldb_binary_encode_string(void *mem_ctx, const char *string); /* functions for controlling attribute handling -- cgit From c908d0b2aa111659e57a73efb8c33c413965c846 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 6 Jan 2006 04:01:23 +0000 Subject: r12733: Merge ldap/ldb controls into main tree There's still lot of work to do but the patch is stable enough to be pushed into the main samba4 tree. Simo. (This used to be commit 77125feaff252cab44d26593093a9c211c846ce8) --- source4/lib/ldb/include/ldb.h | 57 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 9 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9c3b033091..299a5d171e 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -141,12 +141,6 @@ struct ldb_context; typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); -struct ldb_module; - -/* module initialisation function */ -typedef struct ldb_module *(*ldb_module_init_t)(struct ldb_context *, const char **); - - /* debugging uses one of the following levels */ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; @@ -253,7 +247,41 @@ struct ldb_attrib_handler { #define LDB_SYNTAX_UTC_TIME "1.3.6.1.4.1.1466.115.121.1.53" #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" -struct ldb_controls; +/* sorting helpers */ +typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); + +#define LDB_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319" +#define LDB_CONTROL_EXTENDED_DN_OID "1.2.840.113556.1.4.529" +#define LDB_CONTROL_SERVER_SORT_OID "1.2.840.113556.1.4.473" +#define LDB_CONTROL_SORT_RESP_OID "1.2.840.113556.1.4.474" + +struct ldb_paged_control { + int size; + int cookie_len; + char *cookie; +}; + +struct ldb_extended_dn_control { + int type; +}; + +struct ldb_server_sort_control { + char *attributeName; + char *orderingRule; + int reverse; +}; + +struct ldb_sort_resp_control { + int result; + char *attr_desc; +}; + +struct ldb_control { + const char *oid; + int critical; + void *data; +}; + struct ldb_credentials; enum ldb_request_type { @@ -261,12 +289,14 @@ enum ldb_request_type { LDB_REQ_ADD, LDB_REQ_MODIFY, LDB_REQ_DELETE, - LDB_REQ_RENAME + LDB_REQ_RENAME, + LDB_REQ_REGISTER }; struct ldb_result { unsigned int count; struct ldb_message **msgs; + struct ldb_control **controls; }; struct ldb_search { @@ -294,6 +324,10 @@ struct ldb_rename { const struct ldb_dn *newdn; }; +struct ldb_register_control { + const char *oid; +}; + struct ldb_request { int operation; @@ -304,9 +338,10 @@ struct ldb_request { struct ldb_modify mod; struct ldb_delete del; struct ldb_rename rename; + struct ldb_register_control reg; } op; - struct ldb_controls *controls; + struct ldb_control **controls; struct ldb_credentials *creds; }; @@ -427,6 +462,7 @@ int 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); +struct ldb_dn *ldb_dn_explode_or_special(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); @@ -565,4 +601,7 @@ time_t ldb_string_to_time(const char *s); char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); char *ldb_dn_canonical_ex_string(void *mem_ctx, const struct ldb_dn *dn); + + +void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp); #endif -- cgit From 4a8656fd65b4bd9a02bf15a0fc46b1e4de35e905 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 11 Jan 2006 16:31:57 +0000 Subject: r12850: - add Doxygen comments to ldb - 'make doxygen' generated the api documentation under apidocs/ Many thanks to Brad Hards for the patches! metze (This used to be commit e98d483174c555366e62dd27600e6b242cab7a7f) --- source4/lib/ldb/include/ldb.h | 600 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 534 insertions(+), 66 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 299a5d171e..2a718334fe 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -35,8 +35,17 @@ * Author: Stefan Metzmacher */ +/** + \file ldb.h Samba's ldb database + + This header file provides the main API for ldb. +*/ + #ifndef _LDB_H_ + +/*! \cond DOXYGEN_IGNORE */ #define _LDB_H_ 1 +/*! \endcond */ /* major restrictions as compared to normal LDAP: @@ -53,45 +62,85 @@ */ -/* - an individual lump of data in a result comes in this format. The - pointer will usually be to a UTF-8 string if the application is - sensible, but it can be to anything you like, including binary data - blobs of arbitrary size. -*/ #ifndef ldb_val +/** + Result value + + An individual lump of data in a result comes in this format. The + pointer will usually be to a UTF-8 string if the application is + sensible, but it can be to anything you like, including binary data + blobs of arbitrary size. + + \note the data is null (0x00) terminated, but the length does not + include the terminator. +*/ struct ldb_val { - uint8_t *data; - size_t length; + uint8_t *data; /*!< result data */ + size_t length; /*!< length of data */ }; #endif -/* internal ldb exploded dn structures */ +/** + internal ldb exploded dn structures +*/ struct ldb_dn_component { - char *name; + char *name; struct ldb_val value; }; + struct ldb_dn { int comp_num; struct ldb_dn_component *components; }; -/* these flags are used in ldb_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 */ +/** + There are a number of flags that are used with ldap_modify() in + ldb_message_element.flags fields. The LDA_FLAGS_MOD_ADD, + LDA_FLAGS_MOD_DELETE and LDA_FLAGS_MOD_REPLACE flags are used in + ldap_modify() calls to specify whether attributes are being added, + deleted or modified respectively. +*/ #define LDB_FLAG_MOD_MASK 0x3 + +/** + Flag value used in ldap_modify() to indicate that attributes are + being added. + + \sa LDB_FLAG_MOD_MASK +*/ #define LDB_FLAG_MOD_ADD 1 + +/** + Flag value used in ldap_modify() to indicate that attributes are + being replaced. + + \sa LDB_FLAG_MOD_MASK +*/ #define LDB_FLAG_MOD_REPLACE 2 + +/** + Flag value used in ldap_modify() to indicate that attributes are + being deleted. + + \sa LDB_FLAG_MOD_MASK +*/ #define LDB_FLAG_MOD_DELETE 3 +/** + OID for logic AND comaprison. -/* - well known object IDs + This is the well known object ID for a logical AND comparitor. */ #define LDB_OID_COMPARATOR_AND "1.2.840.113556.1.4.803" + +/** + OID for logic OR comparison. + + This is the well known object ID for a logical OR comparitor. +*/ #define LDB_OID_COMPARATOR_OR "1.2.840.113556.1.4.804" -/* +/** results are given back as arrays of ldb_message_element */ struct ldb_message_element { @@ -102,7 +151,7 @@ struct ldb_message_element { }; -/* +/** a ldb_message represents all or part of a record. It can contain an arbitrary number of elements. */ @@ -120,12 +169,15 @@ enum ldb_changetype { LDB_CHANGETYPE_MODIFY }; -/* - a ldif record - from ldif_read +/** + LDIF record + + This structure contains a LDIF record, as returned from ldif_read() + and equivalent functions. */ struct ldb_ldif { - enum ldb_changetype changetype; - struct ldb_message *msg; + enum ldb_changetype changetype; /*!< The type of change */ + struct ldb_message *msg; /*!< The changes */ }; enum ldb_scope {LDB_SCOPE_DEFAULT=-1, @@ -145,7 +197,7 @@ typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *) enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; -/* +/** the user can optionally supply a debug function. The function is based on the vfprintf() style of interface, but with the addition of a severity level @@ -156,14 +208,31 @@ struct ldb_debug_ops { void *context; }; +/** + Flag value for database connection mode. + + If LDB_FLG_RDONLY is used in ldb_connect, then the database will be + opened read-only, if possible. +*/ #define LDB_FLG_RDONLY 1 + +/** + Flag value for database connection mode. + + If LDB_FLG_NOSYNC is used in ldb_connect, then the database will be + opened without synchronous operations, if possible. +*/ #define LDB_FLG_NOSYNC 2 +/*! \cond DOXYGEN_IGNORE */ #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a,b) #endif +/*! \endcond */ -/* structures for ldb_parse_tree handling code */ +/* + structures for ldb_parse_tree handling code +*/ enum ldb_parse_op { LDB_OP_AND=1, LDB_OP_OR=2, LDB_OP_NOT=3, LDB_OP_EQUALITY=4, LDB_OP_SUBSTRING=5, LDB_OP_GREATER=6, LDB_OP_LESS=7, LDB_OP_PRESENT=8, @@ -235,24 +304,106 @@ struct ldb_attrib_handler { ldb_attr_comparison_t comparison_fn; }; -#define LDB_ATTR_FLAG_HIDDEN (1<<0) /* the attribute is not returned by default */ -#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) /* the attribute is constructed from other attributes */ +/** + The attribute is not returned by default +*/ +#define LDB_ATTR_FLAG_HIDDEN (1<<0) +/** + The attribute is constructed from other attributes +*/ +#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) + +/** + LDAP attribute syntax for a DN + + This is the well-known LDAP attribute syntax for a DN. -/* well-known ldap attribute syntaxes - see rfc2252 section 4.3.2 */ + See RFC 2252, Section 4.3.2 +*/ #define LDB_SYNTAX_DN "1.3.6.1.4.1.1466.115.121.1.12" + +/** + LDAP attribute syntax for a Directory String + + This is the well-known LDAP attribute syntax for a Directory String. + + See RFC 2252, Section 4.3.2 +*/ #define LDB_SYNTAX_DIRECTORY_STRING "1.3.6.1.4.1.1466.115.121.1.15" + +/** + LDAP attribute syntax for an integer + + This is the well-known LDAP attribute syntax for an integer. + + See RFC 2252, Section 4.3.2 +*/ #define LDB_SYNTAX_INTEGER "1.3.6.1.4.1.1466.115.121.1.27" + +/** + LDAP attribute syntax for an octet string + + This is the well-known LDAP attribute syntax for an octet string. + + See RFC 2252, Section 4.3.2 +*/ #define LDB_SYNTAX_OCTET_STRING "1.3.6.1.4.1.1466.115.121.1.40" + +/** + LDAP attribute syntax for UTC time. + + This is the well-known LDAP attribute syntax for a UTC time. + + See RFC 2252, Section 4.3.2 +*/ #define LDB_SYNTAX_UTC_TIME "1.3.6.1.4.1.1466.115.121.1.53" + #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" /* sorting helpers */ typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); +/** + OID for the paged results control. This control is included in the + searchRequest and searchResultDone messages as part of the controls + field of the LDAPMessage, as defined in Section 4.1.12 of + LDAP v3. + + \sa RFC 2696. +*/ #define LDB_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319" + +/** + OID for extended DN + + \sa Microsoft documentation of this OID +*/ #define LDB_CONTROL_EXTENDED_DN_OID "1.2.840.113556.1.4.529" + +/** + OID for LDAP server sort result extension. + + This control is included in the searchRequest message as part of + the controls field of the LDAPMessage, as defined in Section 4.1.12 + of LDAP v3. The controlType is set to + "1.2.840.113556.1.4.473". The criticality MAY be either TRUE or + FALSE (where absent is also equivalent to FALSE) at the client's + option. + + \sa RFC 2891. +*/ #define LDB_CONTROL_SERVER_SORT_OID "1.2.840.113556.1.4.473" + +/** + OID for LDAP server sort result response extension. + + This control is included in the searchResultDone message as part of + the controls field of the LDAPMessage, as defined in Section 4.1.12 of + LDAP v3. + + \sa RFC 2891. +*/ #define LDB_CONTROL_SORT_RESP_OID "1.2.840.113556.1.4.474" struct ldb_paged_control { @@ -347,29 +498,60 @@ struct ldb_request { int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -/* - initialise a ldb context +/** + Initialise an ldb context + + This is required before any other LDB call. + + \param mem_ctx pointer to a talloc memory context. Pass NULL if there is + no suitable context available. + + \return pointer to ldb_context that should be free'd (using talloc_free()) + at the end of the program. */ struct ldb_context *ldb_init(void *mem_ctx); -/* - connect to a database. The URL can either be one of the following forms - ldb://path - ldapi://path +/** + Connect to a database. + + This is typically called soon after ldb_init(), and is required prior to + any search or database modification operations. + + The URL can be one of the following forms: + - tdb://path + - ldapi://path + - ldap://host + - sqlite3://path - flags is made up of LDB_FLG_* + \param ldb the context associated with the database (from ldb_init()) + \param url the URL of the database to connect to, as noted above + \param flags a combination of LDB_FLG_* to modify the connection behaviour + \param options backend specific options - passed uninterpreted to the backend - the options are passed uninterpreted to the backend, and are - backend specific + \return result code (LDB_SUCCESS on success, or a failure code) + + \note It is an error to connect to a database that does not exist in readonly mode + (that is, with LDB_FLG_RDONLY). However in read-write mode, the database will be + created if it does not exist. */ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); -/* - search the database given a LDAP-like search expression +/** + Search the database + + This function searches the database, and returns + records that match an LDAP-like search expression - return the number of records found, or -1 on error + \param ldb the context associated with the database (from ldb_init()) + \param base the Base Distinguished Name for the query (pass NULL for root DN) + \param scope the search scope for the query + \param expression the search expression to use for this query + \param attrs the search attributes for the query (pass NULL if none required) + \param res the return result - use talloc_free to free the ldb_message returned + \return result code (LDB_SUCCESS on success, or a failure code) + + \note use talloc_free() to free the ldb_result returned */ int ldb_search(struct ldb_context *ldb, const struct ldb_dn *base, @@ -386,71 +568,263 @@ int ldb_search_bytree(struct ldb_context *ldb, struct ldb_parse_tree *tree, const char * const *attrs, struct ldb_result **res); -/* - add a record to the database. Will fail if a record with the given class and key - already exists +/** + Add a record to the database. + + This function adds a record to the database. This function will fail + if a record with the specified class and key already exists in the + database. + + \param ldb the context associated with the database (from + ldb_init()) + \param message the message containing the record to add. + + \return result code (LDB_SUCCESS if the record was added, otherwise + a failure code) */ int ldb_add(struct ldb_context *ldb, const struct ldb_message *message); -/* - modify the specified attributes of a record +/** + Modify the specified attributes of a record + + This function modifies a record that is in the database. + + \param ldb the context associated with the database (from + ldb_init()) + \param message the message containing the changes required. + + \return result code (LDB_SUCCESS if the record was modified as + requested, otherwise a failure code) */ int ldb_modify(struct ldb_context *ldb, const struct ldb_message *message); -/* - rename a record in the database +/** + Rename a record in the database + + This function renames a record in the database. + + \param ldb the context associated with the database (from + ldb_init()) + \param olddn the DN for the record to be renamed. + \param newdn the new DN + + \return result code (LDB_SUCCESS if the record was renamed as + requested, otherwise a failure code) */ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn); -/* - delete a record from the database +/** + Delete a record from the database + + This function deletes a record from the database. + + \param ldb the context associated with the database (from + ldb_init()) + \param dn the DN for the record to be deleted. + + \return result code (LDB_SUCCESS if the record was deleted, + otherwise a failure code) */ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); -/* +/** start a transaction */ int ldb_transaction_start(struct ldb_context *ldb); -/* +/** commit a transaction */ int ldb_transaction_commit(struct ldb_context *ldb); -/* +/** cancel a transaction */ int ldb_transaction_cancel(struct ldb_context *ldb); -/* +/** return extended error information from the last call */ const char *ldb_errstring(struct ldb_context *ldb); -/* - casefold a string (should be UTF8, but at the moment it isn't) +/** + Casefold a string + + \param mem_ctx the memory context to allocate the result string + memory from. + \param s the string that is to be folded + \return a copy of the string, converted to upper case + + \todo This function should be UTF8 aware, but currently is not. */ char *ldb_casefold(void *mem_ctx, const char *s); + +/** + Compare two strings, without regard to case. + + \param s1 the first string to compare + \param s2 the second string to compare + + \return 0 if the strings are the same, non-zero if there are any + differences except for case. + + \note This function is not UTF8 aware. +*/ int ldb_caseless_cmp(const char *s1, const char *s2); /* ldif manipulation functions */ +/** + Write an LDIF message + + This function writes an LDIF message using a caller supplied write + function. + + \param ldb the ldb context (from ldb_init()) + \param fprintf_fn a function pointer for the write function. This must take + a private data pointer, followed by a format string, and then a variable argument + list. + \param private_data pointer that will be provided back to the write + function. This is useful for maintaining state or context. + \param ldif the message to write out + + \return the total number of bytes written, or an error code as returned + from the write function. + + \sa ldb_ldif_write_file for a more convenient way to write to a + file stream. + + \sa ldb_ldif_read for the reader equivalent to this function. +*/ int ldb_ldif_write(struct ldb_context *ldb, int (*fprintf_fn)(void *, const char *, ...), void *private_data, const struct ldb_ldif *ldif); -void ldb_ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *); + +/** + Clean up an LDIF message + + This function cleans up a LDIF message read using ldb_ldif_read() + or related functions (such as ldb_ldif_read_string() and + ldb_ldif_read_file(). + + \param ldb the ldb context (from ldb_init()) + \param msg the message to clean up and free + +*/ +void ldb_ldif_read_free(struct ldb_context *ldb, struct ldb_ldif *msg); + +/** + Read an LDIF message + + This function creates an LDIF message using a caller supplied read + function. + + \param ldb the ldb context (from ldb_init()) + \param fgetc_fn a function pointer for the read function. This must + take a private data pointer, and must return a pointer to an + integer corresponding to the next byte read (or EOF if there is no + more data to be read). + \param private_data pointer that will be provided back to the read + function. This is udeful for maintaining state or context. + + \return the LDIF message that has been read in + + \note You must free the LDIF message when no longer required, using + ldb_ldif_read_free(). + + \sa ldb_ldif_read_file for a more convenient way to read from a + file stream. + + \sa ldb_ldif_read_string for a more convenient way to read from a + string (char array). + + \sa ldb_ldif_write for the writer equivalent to this function. +*/ struct ldb_ldif *ldb_ldif_read(struct ldb_context *ldb, int (*fgetc_fn)(void *), void *private_data); + +/** + Read an LDIF message from a file + + This function reads the next LDIF message from the contents of a + file stream. If you want to get all of the LDIF messages, you will + need to repeatedly call this function, until it returns NULL. + + \param ldb the ldb context (from ldb_init()) + \param f the file stream to read from (typically from fdopen()) + + \sa ldb_ldif_read_string for an equivalent function that will read + from a string (char array). + + \sa ldb_ldif_write_file for the writer equivalent to this function. + +*/ struct ldb_ldif *ldb_ldif_read_file(struct ldb_context *ldb, FILE *f); + +/** + Read an LDIF message from a string + + This function reads the next LDIF message from the contents of a char + array. If you want to get all of the LDIF messages, you will need + to repeatedly call this function, until it returns NULL. + + \param ldb the ldb context (from ldb_init()) + \param s pointer to the char array to read from + + \sa ldb_ldif_read_file for an equivalent function that will read + from a file stream. + + \sa ldb_ldif_write for a more general (arbitrary read function) + version of this function. +*/ struct ldb_ldif *ldb_ldif_read_string(struct ldb_context *ldb, const char **s); + +/** + Write an LDIF message to a file + + \param ldb the ldb context (from ldb_init()) + \param f the file stream to write to (typically from fdopen()) + \param msg the message to write out + + \return the total number of bytes written, or a negative error code + + \sa ldb_ldif_read_file for the reader equivalent to this function. +*/ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif *msg); + +/** + Base64 encode a buffer + + \param mem_ctx the memory context that the result is allocated + from. + \param buf pointer to the array that is to be encoded + \param len the number of elements in the array to be encoded + + \return pointer to an array containing the encoded data + + \note The caller is responsible for freeing the result +*/ char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); + +/** + Base64 decode a buffer + + This function decodes a base64 encoded string in place. + + \param s the string to decode. + + \return the length of the returned (decoded) string. + + \note the string is null terminated, but the null terminator is not + included in the length. +*/ int ldb_base64_decode(char *s); + int ldb_attrib_add_handlers(struct ldb_context *ldb, const struct ldb_attrib_handler *handlers, unsigned num_handlers); @@ -486,28 +860,67 @@ 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); + +/** + Compare two attributes + + This function compares to attribute names. Note that this is a + case-insensitive comparison. + + \param attr1 the first attribute name to compare + \param attr2 the second attribute name to compare + + \return 0 if the attribute names are the same, or only differ in + case; non-zero if there are any differences +*/ int ldb_attr_cmp(const char *attr1, const char *attr2); int ldb_attr_dn(const char *attr); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); -/* create an empty message */ +/** + Create an empty message + + \param mem_ctx the memory context to create in. You can pass NULL + to get the top level context, however the ldb context (from + ldb_init()) may be a better choice +*/ struct ldb_message *ldb_msg_new(void *mem_ctx); -/* find an element within an message */ +/** + Find an element within an message +*/ struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, const char *attr_name); -/* compare two ldb_val values - return 0 on match */ +/** + Compare two ldb_val values + + \param v1 first ldb_val structure to be tested + \param v2 second ldb_val structure to be tested + + \return 1 for a match, 0 if there is any difference +*/ int ldb_val_equal_exact(const struct ldb_val *v1, const struct ldb_val *v2); -/* find a value within an ldb_message_element */ +/** + find a value within an ldb_message_element + + \param el the element to search + \param val the value to search for + + \note This search is case sensitive +*/ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, struct ldb_val *val); -/* add a new empty element to a ldb_message */ +/** + add a new empty element to a ldb_message +*/ int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags); -/* add a element to a ldb_message */ +/** + add a element to a ldb_message +*/ int ldb_msg_add(struct ldb_message *msg, const struct ldb_message_element *el, int flags); @@ -519,13 +932,19 @@ int ldb_msg_add_string(struct ldb_message *msg, int ldb_msg_add_fmt(struct ldb_message *msg, const char *attr_name, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); -/* compare two message elements - return 0 on match */ +/** + compare two message elements - return 0 on match +*/ int ldb_msg_element_compare(struct ldb_message_element *el1, struct ldb_message_element *el2); -/* find elements in a message and convert to a specific type, with +/** + Find elements in a message. + + This function finds elements and converts to a specific type, with a give default value if not found. Assumes that elements are - single valued */ + single valued. +*/ const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, const char *attr_name); int ldb_msg_find_int(const struct ldb_message *msg, const char *attr_name, @@ -561,11 +980,35 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, struct ldb_message *msg1, struct ldb_message *msg2); +/** + Integrity check an ldb_message + + This function performs basic sanity / integrity checks on an + ldb_message. + + \param msg the message to check + + \return LDB_SUCCESS if the message is OK, or a non-zero error code + (one of LDB_ERR_INVALID_DN_SYNTAX, LDB_ERR_ENTRY_ALREADY_EXISTS or + LDB_ERR_INVALID_ATTRIBUTE_SYNTAX) if there is a problem with a + message. +*/ int ldb_msg_sanity_check(const struct ldb_message *msg); +/** + Duplicate an ldb_val structure + + This function copies an ldb value structure. + + \param mem_ctx the memory context that the duplicated value will be + allocated from + \param v the ldb_val to be duplicated. + + \return the duplicated ldb_val structure. +*/ struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); -/* +/** this allows the user to set a debug function for error reporting */ int ldb_set_debug(struct ldb_context *ldb, @@ -573,7 +1016,9 @@ int ldb_set_debug(struct ldb_context *ldb, const char *fmt, va_list ap), void *context); -/* this sets up debug to print messages on stderr */ +/** + this sets up debug to print messages on stderr +*/ int ldb_set_debug_stderr(struct ldb_context *ldb); /* control backend specific opaque values */ @@ -596,7 +1041,30 @@ int ldb_msg_rename_attr(struct ldb_message *msg, const char *attr, const char *r int ldb_msg_copy_attr(struct ldb_message *msg, const char *attr, const char *replace); void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); +/** + Convert a time structure to a string + + This function converts a time_t structure to an LDAP formatted time + string. + + \param mem_ctx the memory context to allocate the return string in + \param t the time structure to convert + + \return the formatted string, or NULL if the time structure could + not be converted +*/ char *ldb_timestring(void *mem_ctx, time_t t); + +/** + Convert a string to a time structure + + This function converts an LDAP formatted time string to a time_t + structure. + + \param s the string to convert + + \return the time structure, or 0 if the string cannot be converted +*/ time_t ldb_string_to_time(const char *s); char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); -- cgit From 5db0c6b3042292e0f343ced3d45f2f7a8f97de12 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jan 2006 01:06:16 +0000 Subject: r12925: implement client side of ASQ control (This used to be commit dd386bdc6ca6fe0b25705d5a375d29e6940b437f) --- source4/lib/ldb/include/ldb.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2a718334fe..569bf9d6a5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -406,6 +406,15 @@ typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); */ #define LDB_CONTROL_SORT_RESP_OID "1.2.840.113556.1.4.474" +/** + OID for LDAP Attribute Scoped Query extension. + + This control is include in SearchRequest or SearchResponse + messages as part of the controls field of the LDAPMessage. +*/ +#define LDB_CONTROL_ASQ_OID "1.2.840.113556.1.4.1504" + + struct ldb_paged_control { int size; int cookie_len; @@ -427,6 +436,13 @@ struct ldb_sort_resp_control { char *attr_desc; }; +struct ldb_asq_control { + int request; + char *source_attribute; + int src_attr_len; + int result; +}; + struct ldb_control { const char *oid; int critical; -- cgit From 3b447ab4a131509491b42a1843c52ba69bab5e11 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 17 Jan 2006 04:04:57 +0000 Subject: r12977: Some code to implement the client side of the Dirsync control Still investigating how it works. Simo. (This used to be commit bebd403523e581606505e05e7cb621efbc22fa36) --- source4/lib/ldb/include/ldb.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 569bf9d6a5..09f4723f7b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -414,6 +414,14 @@ typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); */ #define LDB_CONTROL_ASQ_OID "1.2.840.113556.1.4.1504" +/** + OID for LDAPrectory Sync extension. + + This control is include in SearchRequest or SearchResponse + messages as part of the controls field of the LDAPMessage. +*/ +#define LDB_CONTROL_DIRSYNC_OID "1.2.840.113556.1.4.841" + struct ldb_paged_control { int size; @@ -443,6 +451,13 @@ struct ldb_asq_control { int result; }; +struct ldb_dirsync_control { + int flags; + int max_attributes; + int cookie_len; + char *cookie; +}; + struct ldb_control { const char *oid; int critical; -- cgit From 828ee2bc6fa4f757c63a31054a0046fe09f8c26e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 17 Jan 2006 18:56:04 +0000 Subject: r12984: add parse code and ldbsearch cmdline code for NOTIFICATION LDAP Controls http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ldap/ldap/ldap_server_notification_oid.asp this doesn't work yet, but it shows that we need to extend ldb to correctly handle async requests... metze (This used to be commit 1fe67189490c9faf499b68a28071a6294a53db0e) --- source4/lib/ldb/include/ldb.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 09f4723f7b..770d23c638 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -374,6 +374,13 @@ typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); */ #define LDB_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319" +/** + OID for notification + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_NOTIFICATION_OID "1.2.840.113556.1.4.528" + /** OID for extended DN -- cgit From 0e7fed29ec24f5de1709a41f64998a90b51a1ec7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 24 Jan 2006 18:40:53 +0000 Subject: r13114: remove 'const' and make clear what the parameters are for metze (This used to be commit 317a3eefeef6b9da565a215ba152d829059c6f14) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 770d23c638..9a637ff9d5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -362,7 +362,7 @@ struct ldb_attrib_handler { #define LDB_SYNTAX_OBJECTCLASS "LDB_SYNTAX_OBJECTCLASS" /* sorting helpers */ -typedef int (*ldb_qsort_cmp_fn_t) (const void *, const void *, const void *); +typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); /** OID for the paged results control. This control is included in the -- cgit From d346794a8d962de209cc3a111c73e23553c9a767 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 26 Jan 2006 16:37:37 +0000 Subject: r13166: Patches form Brad Hards (This used to be commit 335050b30d832f529fb8fdd4f96e4bb3de93f38c) --- source4/lib/ldb/include/ldb.h | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9a637ff9d5..087790ac68 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -276,7 +276,37 @@ struct ldb_parse_tree { struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); + +/** + Encode a binary blob + + This function encodes a binary blob using the encoding rules in RFC + 2254 (Section 4). This function also escapes any non-printable + characters. + + \param ctx the memory context to allocate the return string in. + \param val the (potentially) binary data to be encoded + + \return the encoded data as a null terminated string + + \sa RFC 2252. +*/ char *ldb_binary_encode(void *ctx, struct ldb_val val); + +/** + Encode a string + + This function encodes a string using the encoding rules in RFC 2254 + (Section 4). This function also escapes any non-printable + characters. + + \param mem_ctx the memory context to allocate the return string in. + \param string the string to be encoded + + \return the encoded data as a null terminated string + + \sa RFC 2252. +*/ char *ldb_binary_encode_string(void *mem_ctx, const char *string); /* @@ -328,7 +358,7 @@ struct ldb_attrib_handler { This is the well-known LDAP attribute syntax for a Directory String. - See RFC 2252, Section 4.3.2 + \sa RFC 2252, Section 4.3.2 */ #define LDB_SYNTAX_DIRECTORY_STRING "1.3.6.1.4.1.1466.115.121.1.15" @@ -532,7 +562,7 @@ struct ldb_request { struct ldb_control **controls; struct ldb_credentials *creds; -}; +}; int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -- cgit From feb1c8ea82645ae361099ce992cff3c2d45abcdc Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 31 Jan 2006 23:37:56 +0000 Subject: r13268: fixed typo noticed by Aaron Seigo (This used to be commit a49d024f3d4866655d4436a5c42b3c228374594b) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 087790ac68..9139e6d2f5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -589,7 +589,7 @@ struct ldb_context *ldb_init(void *mem_ctx); - tdb://path - ldapi://path - ldap://host - - sqlite3://path + - sqlite://path \param ldb the context associated with the database (from ldb_init()) \param url the URL of the database to connect to, as noted above -- cgit From f5ebc8e404f4397c0ef2c8b838984df1767c955c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 00:38:48 +0000 Subject: r13324: From now on check attribute names obey rfc2251 Also add a way to provide utf8 compliant functions by registering them with ldb_set_utf8_fns() Next comes code to register samba internal utf8 functions. Simo. (This used to be commit ac9b8a41ffca8e06c5e849d544d3203a665b8e0d) --- source4/lib/ldb/include/ldb.h | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9139e6d2f5..a8c2d176b5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -208,6 +208,16 @@ struct ldb_debug_ops { void *context; }; +/** + The user can optionally supply a custom utf8 functions, + to handle comparisons and casefolding. +*/ +struct ldb_utf8_fns { + void *context; + int (*caseless_cmp)(void *context, const char *s1, const char *s2); + char *(*casefold)(void *context, void *mem_ctx, const char *s); +}; + /** Flag value for database connection mode. @@ -718,30 +728,48 @@ int ldb_transaction_cancel(struct ldb_context *ldb); */ const char *ldb_errstring(struct ldb_context *ldb); +/** + setup the default utf8 functions + FIXME: these functions do not yet handle utf8 +*/ +void ldb_set_utf8_default(struct ldb_context *ldb); + /** Casefold a string + \param ldb the ldb context \param mem_ctx the memory context to allocate the result string memory from. \param s the string that is to be folded \return a copy of the string, converted to upper case - \todo This function should be UTF8 aware, but currently is not. + \note The default function is not yet UTF8 aware. Provide your own + set of functions through ldb_set_utf8_fns() */ -char *ldb_casefold(void *mem_ctx, const char *s); +char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); /** Compare two strings, without regard to case. + \param ldb the ldb context \param s1 the first string to compare \param s2 the second string to compare \return 0 if the strings are the same, non-zero if there are any differences except for case. - \note This function is not UTF8 aware. + \note The default function is not yet UTF8 aware. Provide your own + set of functions through ldb_set_utf8_fns() +*/ +int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2); + +/** + Check the attribute name is valid according to rfc2251 + \param s tthe string to check + + \return 1 if the name is ok */ -int ldb_caseless_cmp(const char *s1, const char *s2); +int ldb_valid_attr_name(const char *s); /* ldif manipulation functions -- cgit From 48d8eee7522e1c1c45a9353ab77c96c20321f143 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 01:27:47 +0000 Subject: r13325: let samba register it's own utf8 aware functions in ldb (This used to be commit 12faf556833807d3f2aa4360c54e10583ac77fed) --- source4/lib/ldb/include/ldb.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index a8c2d176b5..7c39aeeeb9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1112,6 +1112,14 @@ int ldb_set_debug(struct ldb_context *ldb, const char *fmt, va_list ap), void *context); +/** + this allows the user to set custom utf8 function for error reporting +*/ +void ldb_set_utf8_fns(struct ldb_context *ldb, + void *context, + int (*cmp)(void *, const char *, const char *), + char *(*casefold)(void *, void *, const char *)); + /** this sets up debug to print messages on stderr */ -- cgit From 88279373abc07fa50a969135eb5ecf58d6c40cc7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 05:59:48 +0000 Subject: r13328: After the attribute name check cleanup it turned up ldb_caseless_cmp() was used just in one places and by mistake, as there we should have been using ldb_attr_cmp() Remove ldb_caseless_cmp() ... going on with the cleanup and utf8 compliance effort. Simo. (This used to be commit afda68d7bf655a9145648856d29e6e64b9f21aa3) --- source4/lib/ldb/include/ldb.h | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7c39aeeeb9..0e192c2e31 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -214,7 +214,6 @@ struct ldb_debug_ops { */ struct ldb_utf8_fns { void *context; - int (*caseless_cmp)(void *context, const char *s1, const char *s2); char *(*casefold)(void *context, void *mem_ctx, const char *s); }; @@ -748,21 +747,6 @@ void ldb_set_utf8_default(struct ldb_context *ldb); */ char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); -/** - Compare two strings, without regard to case. - - \param ldb the ldb context - \param s1 the first string to compare - \param s2 the second string to compare - - \return 0 if the strings are the same, non-zero if there are any - differences except for case. - - \note The default function is not yet UTF8 aware. Provide your own - set of functions through ldb_set_utf8_fns() -*/ -int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2); - /** Check the attribute name is valid according to rfc2251 \param s tthe string to check @@ -1117,7 +1101,6 @@ int ldb_set_debug(struct ldb_context *ldb, */ void ldb_set_utf8_fns(struct ldb_context *ldb, void *context, - int (*cmp)(void *, const char *, const char *), char *(*casefold)(void *, void *, const char *)); /** -- cgit From 04396c36d3ee8300b2b73ea8b43a45ea1b250828 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 06:57:28 +0000 Subject: r13333: revert previous commit I will use ldb_caseless_cmp in attrib_handlers to correctly support utf8 comparisons add an ldb_attr_Casefold function for attribute names and use it instead of casefold in the right places (This used to be commit 3b4eb2413bbce059dde69f35c03cdc3cc2ba85c5) --- source4/lib/ldb/include/ldb.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0e192c2e31..7c39aeeeb9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -214,6 +214,7 @@ struct ldb_debug_ops { */ struct ldb_utf8_fns { void *context; + int (*caseless_cmp)(void *context, const char *s1, const char *s2); char *(*casefold)(void *context, void *mem_ctx, const char *s); }; @@ -747,6 +748,21 @@ void ldb_set_utf8_default(struct ldb_context *ldb); */ char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); +/** + Compare two strings, without regard to case. + + \param ldb the ldb context + \param s1 the first string to compare + \param s2 the second string to compare + + \return 0 if the strings are the same, non-zero if there are any + differences except for case. + + \note The default function is not yet UTF8 aware. Provide your own + set of functions through ldb_set_utf8_fns() +*/ +int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2); + /** Check the attribute name is valid according to rfc2251 \param s tthe string to check @@ -1101,6 +1117,7 @@ int ldb_set_debug(struct ldb_context *ldb, */ void ldb_set_utf8_fns(struct ldb_context *ldb, void *context, + int (*cmp)(void *, const char *, const char *), char *(*casefold)(void *, void *, const char *)); /** -- cgit From 3ba24e4a35156a36f900cdbdbbef770861e9c7eb Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 07:57:57 +0000 Subject: r13335: Fix the build and add an utf8 safe ldb_hadler_fold function based on ldb_casefold (This used to be commit 6104f900863c688707809d42c5429a42d654d5fb) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7c39aeeeb9..4e457b028f 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -970,6 +970,7 @@ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); case; non-zero if there are any differences */ int ldb_attr_cmp(const char *attr1, const char *attr2); +char *ldb_attr_casefold(void *mem_ctx, const char *s); int ldb_attr_dn(const char *attr); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); -- cgit From 76036d37b42d0c77e57b288af410b931c51fea81 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 4 Feb 2006 18:30:30 +0000 Subject: r13349: In the end I could not use ldb_caseless_cmp in attrib_handler.c functions remove it again Simo (This used to be commit 513ff499071e6cb5e608a82430718021f72997bd) --- source4/lib/ldb/include/ldb.h | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4e457b028f..44f2f5840c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -214,7 +214,6 @@ struct ldb_debug_ops { */ struct ldb_utf8_fns { void *context; - int (*caseless_cmp)(void *context, const char *s1, const char *s2); char *(*casefold)(void *context, void *mem_ctx, const char *s); }; @@ -748,21 +747,6 @@ void ldb_set_utf8_default(struct ldb_context *ldb); */ char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); -/** - Compare two strings, without regard to case. - - \param ldb the ldb context - \param s1 the first string to compare - \param s2 the second string to compare - - \return 0 if the strings are the same, non-zero if there are any - differences except for case. - - \note The default function is not yet UTF8 aware. Provide your own - set of functions through ldb_set_utf8_fns() -*/ -int ldb_caseless_cmp(struct ldb_context *ldb, const char *s1, const char *s2); - /** Check the attribute name is valid according to rfc2251 \param s tthe string to check @@ -1118,7 +1102,6 @@ int ldb_set_debug(struct ldb_context *ldb, */ void ldb_set_utf8_fns(struct ldb_context *ldb, void *context, - int (*cmp)(void *, const char *, const char *), char *(*casefold)(void *, void *, const char *)); /** -- cgit From 338c410fec8dbd902485e56567f6aecf256cdba2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 6 Feb 2006 01:21:17 +0000 Subject: r13361: initial implementation of the vlv control seem still buggy, can't make w2k3 to like it yet (This used to be commit e1318383e91f6f6db39e3e3c9946fbb089753947) --- source4/lib/ldb/include/ldb.h | 48 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 44f2f5840c..a6cec7f774 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -455,20 +455,36 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); /** OID for LDAP Attribute Scoped Query extension. - This control is include in SearchRequest or SearchResponse + This control is included in SearchRequest or SearchResponse messages as part of the controls field of the LDAPMessage. */ #define LDB_CONTROL_ASQ_OID "1.2.840.113556.1.4.1504" /** - OID for LDAPrectory Sync extension. + OID for LDAP Directory Sync extension. - This control is include in SearchRequest or SearchResponse + This control is included in SearchRequest or SearchResponse messages as part of the controls field of the LDAPMessage. */ #define LDB_CONTROL_DIRSYNC_OID "1.2.840.113556.1.4.841" +/** + OID for LDAP Virtual List View Request extension. + + This control is included in SearchRequest messages + as part of the controls field of the LDAPMessage. +*/ +#define LDB_CONTROL_VLV_REQ_OID "2.16.840.1.113730.3.4.9" + +/** + OID for LDAP Virtual List View Response extension. + + This control is included in SearchResponse messages + as part of the controls field of the LDAPMessage. +*/ +#define LDB_CONTROL_VLV_RESP_OID "2.16.840.1.113730.3.4.10" + struct ldb_paged_control { int size; int cookie_len; @@ -504,6 +520,32 @@ struct ldb_dirsync_control { char *cookie; }; +struct ldb_vlv_req_control { + int beforeCount; + int afterCount; + int type; + union { + struct { + int offset; + int contentCount; + } byOffset; + struct { + int value_len; + char *value; + } gtOrEq; + } match; + int ctxid_len; + char *contextId; +}; + +struct ldb_vlv_resp_control { + int targetPosition; + int contentCount; + int vlv_result; + int ctxid_len; + char *contextId; +}; + struct ldb_control { const char *oid; int critical; -- cgit From 00fe70e5b917769418f68eaa255d3a06a9a08ce7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Feb 2006 01:31:35 +0000 Subject: r13609: Get in the initial work on making ldb async Currently only ldb_ildap is async, the plan is to first make all backend support the async calls, and then remove the sync functions from backends and keep the only in the API. Modules will need to be transformed along the way. Simo (This used to be commit 1e2c13b2d52de7c534493dd79a2c0596a3e8c1f5) --- source4/lib/ldb/include/ldb.h | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index a6cec7f774..4a40e34363 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -560,15 +560,51 @@ enum ldb_request_type { LDB_REQ_MODIFY, LDB_REQ_DELETE, LDB_REQ_RENAME, + LDB_ASYNC_SEARCH, + LDB_ASYNC_ADD, + LDB_ASYNC_MODIFY, + LDB_ASYNC_DELETE, + LDB_ASYNC_RENAME, + LDB_REQ_REGISTER }; +enum ldb_reply_type { + LDB_REPLY_ENTRY, + LDB_REPLY_REFERRAL, + LDB_REPLY_DONE +}; + +enum ldb_async_wait_type { + LDB_WAIT_ALL, + LDB_WAIT_NONE +}; + +enum ldb_async_state { + LDB_ASYNC_PENDING, + LDB_ASYNC_DONE +}; + struct ldb_result { unsigned int count; struct ldb_message **msgs; + char **refs; struct ldb_control **controls; }; +struct ldb_async_result { + enum ldb_reply_type type; + struct ldb_message *message; + char *referral; + struct ldb_control **controls; +}; + +struct ldb_async_handle { + int status; + enum ldb_async_state state; + void *private_data; +}; + struct ldb_search { const struct ldb_dn *base; enum ldb_scope scope; @@ -613,10 +649,20 @@ struct ldb_request { struct ldb_control **controls; struct ldb_credentials *creds; + + struct { + void *context; + int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); + + time_t timeout; + struct ldb_async_handle *handle; + } async; }; int ldb_request(struct ldb_context *ldb, struct ldb_request *request); +int ldb_async_wait(struct ldb_context *ldb, struct ldb_async_handle *handle, enum ldb_async_wait_type type); + /** Initialise an ldb context -- cgit From d590dea10b3abf93fcc8138189291e8b66bae7d7 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Feb 2006 05:21:43 +0000 Subject: r13615: Make ldb_set_errstring get ldb instead of module as parameter. The module was just used to get to the ldb so it was meningless. Also add LDB_WAIT_ONCE e relative code in ldb_ildap.c (This used to be commit d5b467b7c132b0bd4d23918ba7bf3370b1afcce8) --- source4/lib/ldb/include/ldb.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4a40e34363..8a9e8bea76 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -577,10 +577,12 @@ enum ldb_reply_type { enum ldb_async_wait_type { LDB_WAIT_ALL, + LDB_WAIT_ONCE, LDB_WAIT_NONE }; enum ldb_async_state { + LDB_ASYNC_INIT, LDB_ASYNC_PENDING, LDB_ASYNC_DONE }; -- cgit From 98c0767677156ff31791bd93f473ac11f856c75a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 22 Feb 2006 09:28:58 +0000 Subject: r13616: Add new ldb functions: ldb_msg_add_steal_string() and ldb_msg_add_steal_value(). These try to maintain the talloc heirachy, which must be correct otherwise talloc_steal operations of entire attribute lists fails. This fixes the currentTime value, found by using Microsoft's dcdiag tool (before this commit, it pointed to invalid memory, due to the changes in -r 13606) Andrew Bartlett (This used to be commit 424df1bb369fddcfd358cf26dd0da9d3851d181e) --- source4/lib/ldb/include/ldb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8a9e8bea76..488f782c9b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1098,6 +1098,11 @@ int ldb_msg_add(struct ldb_message *msg, int ldb_msg_add_value(struct ldb_message *msg, const char *attr_name, const struct ldb_val *val); +int ldb_msg_add_steal_value(struct ldb_message *msg, + const char *attr_name, + struct ldb_val *val); +int ldb_msg_add_steal_string(struct ldb_message *msg, + const char *attr_name, char *str); int ldb_msg_add_string(struct ldb_message *msg, const char *attr_name, const char *str); int ldb_msg_add_fmt(struct ldb_message *msg, -- cgit From e1380d63a0d85120ebf25d228b1bf6f8c6604d99 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 28 Feb 2006 04:38:53 +0000 Subject: r13744: Make ldb_ldap async (This used to be commit ec833b409c1fff4ab908fe194579e701d2e950b0) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 488f782c9b..f5bca965ad 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -656,7 +656,7 @@ struct ldb_request { void *context; int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); - time_t timeout; + int timeout; struct ldb_async_handle *handle; } async; }; -- cgit From 26af14c39b88b0e7eb53657b89be65d865804688 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 2 Mar 2006 16:32:53 +0000 Subject: r13786: [merge] Add registration functions for LDB modules Applications that use LDB modules will now have to run ldb_global_init() before they can use LDB. The next step will be adding support for loading LDB modules from .so files. This will also allow us to use one LDB without difference between the standalone and the Samba-specific build (This used to be commit 52a235650514039bf8ffee99a784bbc1b6ae6b92) --- source4/lib/ldb/include/ldb.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index f5bca965ad..13e69282ca 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -665,6 +665,15 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *request); int ldb_async_wait(struct ldb_context *ldb, struct ldb_async_handle *handle, enum ldb_async_wait_type type); +/** + Initialise ldbs' global information + + This is required before any other LDB call + + \return 0 if initialisation succeeded, -1 otherwise +*/ +int ldb_global_init(void); + /** Initialise an ldb context -- cgit From 7b82c4beb93375f79b6c06fc86bb31873baa187b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 7 Mar 2006 21:08:09 +0000 Subject: r13992: change the way ldb_async_wait() works. I think I should change the name of this function to ldb_async_process(), any opinions ? (This used to be commit 3347322d1327cfa975ee9dccd4f2774e6e14fbcb) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 13e69282ca..b3ea17d85d 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -605,6 +605,7 @@ struct ldb_async_handle { int status; enum ldb_async_state state; void *private_data; + struct ldb_module *module; }; struct ldb_search { -- cgit From 257598424e63c2cfa118b5ea84b7dc719d1dc5aa Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 7 Mar 2006 21:16:35 +0000 Subject: r13996: simplify ldb_async_wait() some more (This used to be commit ef1b3e6368179fe86ae07b8d00e4668090175551) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index b3ea17d85d..dbe929246b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -664,7 +664,7 @@ struct ldb_request { int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -int ldb_async_wait(struct ldb_context *ldb, struct ldb_async_handle *handle, enum ldb_async_wait_type type); +int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type); /** Initialise ldbs' global information -- cgit From 6e74d8356578c42c8081498094f2c834c6d439b4 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 10 Mar 2006 15:50:47 +0000 Subject: r14163: Remove LDB_WAIT_ONCE, we can hardly guarante we get anything if not waiting for all, keeping this value may just lead to false expectations. You either make blocking call waiting for ALL results transforming this in a sync call, or either you loop expecting from 0 to all results being returned at any time on any of these loops. It should be clear also that when you may receive results at any time as soon as you call ldb_request. Your callback may have received all results even before calling ldb_async_wait the first time. Simo. (This used to be commit 6f041068b50caf919cd971812bdb8e3e810565fb) --- source4/lib/ldb/include/ldb.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index dbe929246b..6abce5d9b9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -577,7 +577,6 @@ enum ldb_reply_type { enum ldb_async_wait_type { LDB_WAIT_ALL, - LDB_WAIT_ONCE, LDB_WAIT_NONE }; -- cgit From 7dbbc960a05ec0cbf3c3a655c08858acaf6bf499 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 13 Apr 2006 04:19:27 +0000 Subject: r15065: Remove duplicate prototype. (This used to be commit 9d9df34d94842ea9f4be3fa51b197fb4bb918488) --- source4/lib/ldb/include/ldb.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6abce5d9b9..589bb4b6a1 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1055,7 +1055,6 @@ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); int ldb_attr_cmp(const char *attr1, const char *attr2); char *ldb_attr_casefold(void *mem_ctx, const char *s); int ldb_attr_dn(const char *attr); -char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); /** Create an empty message -- cgit From 859817e30ff809bda972e208e89191f53e097674 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Mon, 17 Apr 2006 23:25:25 +0000 Subject: r15113: Add a ldb_strerror() function. (This used to be commit 456a1de2b9cd54337066c9ba24ad1c46aafcd072) --- source4/lib/ldb/include/ldb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 589bb4b6a1..a6a13fc39c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -826,6 +826,11 @@ int ldb_transaction_cancel(struct ldb_context *ldb); */ const char *ldb_errstring(struct ldb_context *ldb); +/** + return a string explaining what a ldb error constant meancs +*/ +const char *ldb_strerror(int ldb_err); + /** setup the default utf8 functions FIXME: these functions do not yet handle utf8 -- cgit From 8c653b5b54514f1f5e2279ed05f863c4578f1f5a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 25 Apr 2006 16:08:55 +0000 Subject: r15245: forgot one header (This used to be commit 32da3f5d22cc38f72961ca65c85c49d03f64b05c) --- source4/lib/ldb/include/ldb.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index a6a13fc39c..43dde8675b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -233,6 +233,15 @@ struct ldb_utf8_fns { */ #define LDB_FLG_NOSYNC 2 +/** + Flag value to specify autoreconnect mode. + + If LDB_FLG_RECONNECT is used in ldb_connect, then the backend will + be opened in a way that makes it try to auto reconnect if the + connection is dropped (actually make sense only with ldap). +*/ +#define LDB_FLG_RECONNECT 3 + /*! \cond DOXYGEN_IGNORE */ #ifndef PRINTF_ATTRIBUTE #define PRINTF_ATTRIBUTE(a,b) -- cgit From d562cac5c4a54cc4efe8a6c876faba5274730948 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 25 Apr 2006 16:21:56 +0000 Subject: r15246: flags need to represented as bits 0x01,0x02,0x04,0x08,0x10,... metze (This used to be commit 96da29263b5b7a78e75b46ab9cf6e6e1729e05d4) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 43dde8675b..af3aed24c6 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -240,7 +240,7 @@ struct ldb_utf8_fns { be opened in a way that makes it try to auto reconnect if the connection is dropped (actually make sense only with ldap). */ -#define LDB_FLG_RECONNECT 3 +#define LDB_FLG_RECONNECT 4 /*! \cond DOXYGEN_IGNORE */ #ifndef PRINTF_ATTRIBUTE -- cgit From aa7a02d45fefad3640f273b1d3bfe535a1e6b88c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 13 May 2006 21:08:37 +0000 Subject: r15582: Commit some forgotten stuff that have been setting on my private tree fro long (This used to be commit 7c050b541e98cd442a0c9ed0ddadb3e573cd1304) --- source4/lib/ldb/include/ldb.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index af3aed24c6..866b062d06 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -625,11 +625,11 @@ struct ldb_search { }; struct ldb_add { - const struct ldb_message *message; + struct ldb_message *message; }; struct ldb_modify { - const struct ldb_message *message; + struct ldb_message *message; }; struct ldb_delete { @@ -1178,6 +1178,10 @@ struct ldb_message *ldb_msg_diff(struct ldb_context *ldb, struct ldb_message *msg1, struct ldb_message *msg2); +int ldb_msg_check_string_attribute(const struct ldb_message *msg, + const char *name, + const char *value); + /** Integrity check an ldb_message -- cgit From 6d0969aa1adff4c7f134bd6e3e42997e72b41cf6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 20 May 2006 19:37:21 +0000 Subject: r15761: Fix-as-you-go ... Testing various async paths and uncovering bugs (This used to be commit 099d873ea596ece18efe63b06bc64e7f97a96f82) --- source4/lib/ldb/include/ldb.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 866b062d06..9f0613feaa 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -619,17 +619,17 @@ struct ldb_async_handle { struct ldb_search { const struct ldb_dn *base; enum ldb_scope scope; - struct ldb_parse_tree *tree; + const struct ldb_parse_tree *tree; const char * const *attrs; struct ldb_result *res; }; struct ldb_add { - struct ldb_message *message; + const struct ldb_message *message; }; struct ldb_modify { - struct ldb_message *message; + const struct ldb_message *message; }; struct ldb_delete { @@ -647,7 +647,7 @@ struct ldb_register_control { struct ldb_request { - int operation; + enum ldb_request_type operation; union { struct ldb_search search; -- cgit From 03703a58d7fe441ec5dcbe1814cea3f55544de55 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 29 May 2006 11:57:09 +0000 Subject: r15932: Remove per request creds They have never benn used and make little sense too imo (This used to be commit f0c1d08d50f8a3e25650ac85b178ec7a43e433d9) --- source4/lib/ldb/include/ldb.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9f0613feaa..8f21aec046 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -561,8 +561,6 @@ struct ldb_control { void *data; }; -struct ldb_credentials; - enum ldb_request_type { LDB_REQ_SEARCH, LDB_REQ_ADD, @@ -659,7 +657,6 @@ struct ldb_request { } op; struct ldb_control **controls; - struct ldb_credentials *creds; struct { void *context; -- cgit From 0c7b82e5f6063de4114de21cf854ac67346e31f6 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 29 May 2006 23:46:43 +0000 Subject: r15942: Remove the sync internal ldb calls altogether. This means that some modules have been disabled as well as they have not been ported to the async interface One of them is the ugly objectclass module. I hope that the change in samldb module will make the MMC happy without the need of this crappy module, we need proper handling in a decent schema module. proxy and ldb_map have also been disabled ldb_sqlite3 need to be ported as well (currenlty just broken). (This used to be commit 51083de795bdcbf649de926e86969adc20239b6d) --- source4/lib/ldb/include/ldb.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8f21aec046..8e61ccd73c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -562,11 +562,6 @@ struct ldb_control { }; enum ldb_request_type { - LDB_REQ_SEARCH, - LDB_REQ_ADD, - LDB_REQ_MODIFY, - LDB_REQ_DELETE, - LDB_REQ_RENAME, LDB_ASYNC_SEARCH, LDB_ASYNC_ADD, LDB_ASYNC_MODIFY, -- cgit From 2d19dca9c80a5e3990296dde67163fce36ac883d Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 30 May 2006 00:33:52 +0000 Subject: r15944: rename LDB_ASYNC_ADD -> LDB_ADD, LDB_ASYNC_MODIFY -> LDB_MODIFY, etc... (This used to be commit 55d97ef88f377ef1dbf7b1774a15cf9035e2f320) --- source4/lib/ldb/include/ldb.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8e61ccd73c..56eed3ab24 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -562,11 +562,11 @@ struct ldb_control { }; enum ldb_request_type { - LDB_ASYNC_SEARCH, - LDB_ASYNC_ADD, - LDB_ASYNC_MODIFY, - LDB_ASYNC_DELETE, - LDB_ASYNC_RENAME, + LDB_SEARCH, + LDB_ADD, + LDB_MODIFY, + LDB_DELETE, + LDB_RENAME, LDB_REQ_REGISTER }; -- cgit From ca5accf224dc3ef998235603797b519866b57b1c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 4 Jun 2006 05:28:13 +0000 Subject: r16036: Add a couple of new functions to corretly deal with timeouts. Check timeouts are correctly verified. Some minor fixed and removal of unused code. (This used to be commit b52e5d6a0cb1a32e62759eaa49ce3e4cc804cc92) --- source4/lib/ldb/include/ldb.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 56eed3ab24..644f74385f 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -658,6 +658,7 @@ struct ldb_request { int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); int timeout; + time_t starttime; struct ldb_async_handle *handle; } async; }; @@ -666,6 +667,9 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *request); int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type); +int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout); +int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); + /** Initialise ldbs' global information -- cgit From 247af0d569594512a24e83156e257b8d4d356883 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 7 Jun 2006 21:03:38 +0000 Subject: r16083: Make it possible to initialise a backend module, without it setting up the whole ldb structure. Because the sequence number was a fn pointer on the main ldb context, turn it into a full request (currently sync). Andrew Bartlett (This used to be commit fbe7d0ca9031e292b2d2fae263233c973982980a) --- source4/lib/ldb/include/ldb.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 644f74385f..033a9c1f39 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -567,8 +567,8 @@ enum ldb_request_type { LDB_MODIFY, LDB_DELETE, LDB_RENAME, - - LDB_REQ_REGISTER + LDB_REQ_REGISTER, + LDB_SEQUENCE_NUMBER }; enum ldb_reply_type { @@ -638,6 +638,10 @@ struct ldb_register_control { const char *oid; }; +struct ldb_sequence_number { + uint64_t seq_num; +}; + struct ldb_request { enum ldb_request_type operation; @@ -649,6 +653,7 @@ struct ldb_request { struct ldb_delete del; struct ldb_rename rename; struct ldb_register_control reg; + struct ldb_sequence_number seq_num; } op; struct ldb_control **controls; @@ -810,6 +815,11 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct */ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); +/** + Obtain current database sequence number +*/ +int ldb_sequence_number(struct ldb_context *ldb, uint64_t *seq_num); + /** start a transaction */ -- cgit From f77c4100842f8c5357fa90822e04319810a04b8d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 15 Jun 2006 18:04:24 +0000 Subject: r16264: Add, but do not yet enable, the partitions module. This required changes to the rootDSE module, to allow registration of partitions. In doing so I renamed the 'register' operation to 'register_control' and 'register_partition', which changed a few more modules. Due to the behaviour of certain LDAP servers, we create the baseDN entry in two parts: Firstly, we allow the admin to export a simple LDIF file to add to their server. Then we perform a modify to add the remaining attributes. To delete all users in partitions, we must now search and delete all objects in the partition, rather than a simple search from the root. Against LDAP, this might not delete all objects, so we allow this to fail. In testing, we found that the 'Domain Controllers' container was misnamed, and should be 'CN=', rather than 'OU='. To avoid the Templates being found in default searches, they have been moved to CN=Templates from CN=Templates,${BASEDN}. Andrew Bartlett (This used to be commit b49a4fbb57f10726bd288fdc9fc95c0cbbe9094a) --- source4/lib/ldb/include/ldb.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 033a9c1f39..b684b03ef4 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -567,7 +567,8 @@ enum ldb_request_type { LDB_MODIFY, LDB_DELETE, LDB_RENAME, - LDB_REQ_REGISTER, + LDB_REQ_REGISTER_CONTROL, + LDB_REQ_REGISTER_PARTITION, LDB_SEQUENCE_NUMBER }; @@ -638,6 +639,10 @@ struct ldb_register_control { const char *oid; }; +struct ldb_register_partition { + const struct ldb_dn *dn; +}; + struct ldb_sequence_number { uint64_t seq_num; }; @@ -652,7 +657,8 @@ struct ldb_request { struct ldb_modify mod; struct ldb_delete del; struct ldb_rename rename; - struct ldb_register_control reg; + struct ldb_register_control reg_control; + struct ldb_register_partition reg_partition; struct ldb_sequence_number seq_num; } op; @@ -1245,6 +1251,7 @@ const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, const char **ldb_attr_list_copy(void *mem_ctx, const char * const *attrs); +const char **ldb_attr_list_copy_add(void *mem_ctx, const char * const *attrs, const char *new_attr); int ldb_attr_in_list(const char * const *attrs, const char *attr); -- cgit From 44e6f21393ea6f2531c6d1e789a0a01582bc6dca Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 6 Jul 2006 05:08:30 +0000 Subject: r16825: Make ldb_sainity_check() set an error string. This makes it much easier to chase down what modules or application code gets wrong. Ensure not to leave memory allocated on failure in ldb_search() Andrew Bartlett (This used to be commit 0828739951ed879640f8ed6e4700d8ca6b8221b8) --- source4/lib/ldb/include/ldb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index b684b03ef4..2f0464b953 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1207,7 +1207,8 @@ int ldb_msg_check_string_attribute(const struct ldb_message *msg, LDB_ERR_INVALID_ATTRIBUTE_SYNTAX) if there is a problem with a message. */ -int ldb_msg_sanity_check(const struct ldb_message *msg); +int ldb_msg_sanity_check(struct ldb_context *ldb, + const struct ldb_message *msg); /** Duplicate an ldb_val structure -- cgit From c93817b36d3ff7f44cb7b3e1d1a29e37ec12affe Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 22 Jul 2006 16:56:33 +0000 Subject: r17185: Oh, I wanted to do this for sooo long time. Finally acknowledge that ldb is inherently async and does not have a dual personality anymore Rename all ldb_async_XXX functions to ldb_XXX except for ldb_async_result, it is now ldb_reply to reflect the real function of this structure. Simo. (This used to be commit 25fc7354049d62efeba17681ef1cdd326bc3f2ef) --- source4/lib/ldb/include/ldb.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2f0464b953..885842ff9c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -578,12 +578,12 @@ enum ldb_reply_type { LDB_REPLY_DONE }; -enum ldb_async_wait_type { +enum ldb_wait_type { LDB_WAIT_ALL, LDB_WAIT_NONE }; -enum ldb_async_state { +enum ldb_state { LDB_ASYNC_INIT, LDB_ASYNC_PENDING, LDB_ASYNC_DONE @@ -596,16 +596,16 @@ struct ldb_result { struct ldb_control **controls; }; -struct ldb_async_result { +struct ldb_reply { enum ldb_reply_type type; struct ldb_message *message; char *referral; struct ldb_control **controls; }; -struct ldb_async_handle { +struct ldb_handle { int status; - enum ldb_async_state state; + enum ldb_state state; void *private_data; struct ldb_module *module; }; @@ -666,17 +666,17 @@ struct ldb_request { struct { void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_async_result *); + int (*callback)(struct ldb_context *, void *, struct ldb_reply *); int timeout; time_t starttime; - struct ldb_async_handle *handle; + struct ldb_handle *handle; } async; }; int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -int ldb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type); +int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type); int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout); int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); -- cgit From 49f68caed20d2a7d1850e493005bdf85929d6365 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 22 Jul 2006 17:21:59 +0000 Subject: r17186: "async" word abuse clean-up part 2 (This used to be commit c6aa60c7e69abf1f83efc150b1c3ed02751c45fc) --- source4/lib/ldb/include/ldb.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 885842ff9c..68c2272adf 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -664,14 +664,12 @@ struct ldb_request { struct ldb_control **controls; - struct { - void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_reply *); - - int timeout; - time_t starttime; - struct ldb_handle *handle; - } async; + void *context; + int (*callback)(struct ldb_context *, void *, struct ldb_reply *); + + int timeout; + time_t starttime; + struct ldb_handle *handle; }; int ldb_request(struct ldb_context *ldb, struct ldb_request *request); -- cgit From e248caed12f5d20d3abedfaf84aa18cdff46c95c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 22 Jul 2006 21:16:01 +0000 Subject: r17195: Start thinking how to implement extended operations. Ad supports three extended operations: - start tls - dynamic objects - fast binds none of these are a priority. (This used to be commit 523e8f3ed4bf5fcf9dc0c9e2100e4ac3b8032be7) --- source4/lib/ldb/include/ldb.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 68c2272adf..6e3f69f607 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -494,6 +494,14 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_VLV_RESP_OID "2.16.840.1.113730.3.4.10" +/** + OID for LDAP Extended Operation START_TLS. + + This Extended operation is used to start a new TLS + channel on top of a clear text channel. +*/ +#define LDB_EXTENDED_STATRT_TLS_OID "1.3.6.1.4.1.1466.20037" + struct ldb_paged_control { int size; int cookie_len; @@ -567,6 +575,7 @@ enum ldb_request_type { LDB_MODIFY, LDB_DELETE, LDB_RENAME, + LDB_EXTENDED, LDB_REQ_REGISTER_CONTROL, LDB_REQ_REGISTER_PARTITION, LDB_SEQUENCE_NUMBER @@ -575,6 +584,7 @@ enum ldb_request_type { enum ldb_reply_type { LDB_REPLY_ENTRY, LDB_REPLY_REFERRAL, + LDB_REPLY_EXTENDED, LDB_REPLY_DONE }; @@ -596,9 +606,16 @@ struct ldb_result { struct ldb_control **controls; }; +struct ldb_extended { + const char *oid; + const char *value; + int value_len; +}; + struct ldb_reply { enum ldb_reply_type type; struct ldb_message *message; + struct ldb_extended *response; char *referral; struct ldb_control **controls; }; -- cgit From e3df3cd55ffd03a337ac769540d1cd80e25a7ef6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 25 Jul 2006 03:41:32 +0000 Subject: r17225: Fix the build by fixing the spelling of START-TLS. Andrew Bartlett (This used to be commit 4827a6b171d7b007f1641ef422d23449fb5a1606) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6e3f69f607..d017861b05 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -500,7 +500,7 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); This Extended operation is used to start a new TLS channel on top of a clear text channel. */ -#define LDB_EXTENDED_STATRT_TLS_OID "1.3.6.1.4.1.1466.20037" +#define LDB_EXTENDED_START_TLS_OID "1.3.6.1.4.1.1466.20037" struct ldb_paged_control { int size; -- cgit From b1b9617d1c1833da2efa93b011733060c6670976 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 1 Aug 2006 03:22:02 +0000 Subject: r17350: Avoid a couple of memleaks, unnecessary code and use a more linear style (This used to be commit 97c4d41a30a5d85145abb781cb7001b502bc7dcb) --- source4/lib/ldb/include/ldb.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index d017861b05..08bb2dd2f6 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -502,6 +502,22 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_EXTENDED_START_TLS_OID "1.3.6.1.4.1.1466.20037" +/** + OID for LDAP Extended Operation START_TLS. + + This Extended operation is used to start a new TLS + channel on top of a clear text channel. +*/ +#define LDB_EXTENDED_DYNAMIC_OID "1.3.6.1.4.1.1466.101.119.1" + +/** + OID for LDAP Extended Operation START_TLS. + + This Extended operation is used to start a new TLS + channel on top of a clear text channel. +*/ +#define LDB_EXTENDED_FAST_BIND_OID "1.2.840.113556.1.4.1781" + struct ldb_paged_control { int size; int cookie_len; -- cgit From b4028ca1041fc8e0266de2f5c858dd40e660aafb Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 10:26:23 +0000 Subject: r17418: add client support for the LDAP_SERVER_SD_FLAGS control metze (This used to be commit 23759a1e9b05c4fde475a9016cb0b7447656d7e7) --- source4/lib/ldb/include/ldb.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 08bb2dd2f6..6730824fdd 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -422,6 +422,13 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_PAGED_RESULTS_OID "1.2.840.113556.1.4.319" +/** + OID for specifying the returned elements of the ntSecurityDescriptor + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_SD_FLAGS_OID "1.2.840.113556.1.4.801" + /** OID for notification @@ -518,6 +525,16 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_EXTENDED_FAST_BIND_OID "1.2.840.113556.1.4.1781" +struct ldb_sd_flags_control { + /* + * request the owner 0x00000001 + * request the group 0x00000002 + * request the DACL 0x00000004 + * request the SACL 0x00000008 + */ + unsigned secinfo_flags; +}; + struct ldb_paged_control { int size; int cookie_len; -- cgit From 817610f38540fb99595f6e3b77b9f6696f9e3b3f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 11:18:14 +0000 Subject: r17419: add client support for the LDAP_SERVER_SEARCH_OPTIONS support. with this you can limit a search to a specific partitions or a search over all partitions without getting referrals. (Witch is the default behavior on the Global Catalog Port) metze (This used to be commit 4ccd0f8171f3748ee6efe1abd3f894d2cdf46bf4) --- source4/lib/ldb/include/ldb.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 6730824fdd..4a04c3df44 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -429,6 +429,13 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_SD_FLAGS_OID "1.2.840.113556.1.4.801" +/** + OID for specifying an advanced scope for a search + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_SEARCH_OPTIONS_OID "1.2.840.113556.1.4.1340" + /** OID for notification @@ -535,6 +542,23 @@ struct ldb_sd_flags_control { unsigned secinfo_flags; }; +struct ldb_search_options_control { + /* + * DOMAIN_SCOPE 0x00000001 + * this limits the search to one partition, + * and no referrals will be returned. + * (Note this doesn't limit the entries by there + * objectSid belonging to a domain! Builtin and Foreign Sids + * are still returned) + * + * PHANTOM_ROOT 0x00000002 + * this search on the whole tree on a domain controller + * over multiple partitions without referrals. + * (This is the default behavior on the Global Catalog Port) + */ + unsigned search_options; +}; + struct ldb_paged_control { int size; int cookie_len; -- cgit From 8ac0237eba1831c8ba6d01c2b9d8402636a21bb2 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 11:38:50 +0000 Subject: r17420: add client support for the LDAP_SERVER_DOMAIN_SCOPE control metze (This used to be commit 84e74a759cfa49ebc8b4ba1b8e729d6d920fc55a) --- source4/lib/ldb/include/ldb.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4a04c3df44..13ad473b0b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -429,6 +429,13 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_SD_FLAGS_OID "1.2.840.113556.1.4.801" +/** + OID for specifying an advanced scope for the search (one partition) + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_DOMAIN_SCOPE_OID "1.2.840.113556.1.4.1339" + /** OID for specifying an advanced scope for a search -- cgit From 12050962f6dd37819e58e1e0b572c159f0406f7a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 19:35:00 +0000 Subject: r17429: implement the LDAP_SERVER_SHOW_DELETED control in the client metze (This used to be commit 40dc7c1787c16bfc15ac87fee81d2d2d1f3d2fde) --- source4/lib/ldb/include/ldb.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 13ad473b0b..05cc1e3494 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -450,6 +450,13 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_NOTIFICATION_OID "1.2.840.113556.1.4.528" +/** + OID for getting deleted objects + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_SHOW_DELETED_OID "1.2.840.113556.1.4.417" + /** OID for extended DN -- cgit From 3a083f8f53b998b6aabf69e845fd0fbdf86b6499 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 5 Aug 2006 19:50:58 +0000 Subject: r17430: implement the LDAP_SERVER_PERMISSIVE_MODIFY control in the client metze (This used to be commit 96259f0f24b114e505241c9d2deb702a8b40f1b6) --- source4/lib/ldb/include/ldb.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 05cc1e3494..5a49ae357f 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -522,6 +522,14 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); */ #define LDB_CONTROL_VLV_RESP_OID "2.16.840.1.113730.3.4.10" +/** + OID to let modifies don't give an error when adding an existing + attribute with the same value or deleting an nonexisting one attribute + + \sa Microsoft documentation of this OID +*/ +#define LDB_CONTROL_PERMISSIVE_MODIFY_OID "1.2.840.113556.1.4.1413" + /** OID for LDAP Extended Operation START_TLS. -- cgit From 39018ab9022d8bd2cc58a52cf4834c5ce7c5455f Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 12 Aug 2006 15:20:06 +0000 Subject: r17503: Add a useful function to search for a DN (This used to be commit 8c6efd7b55e4ad45e1bd10519a1b91285a4e0347) --- source4/lib/ldb/include/ldb.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 5a49ae357f..e560068d0c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1269,6 +1269,10 @@ const char *ldb_msg_find_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); +struct ldb_dn *ldb_msg_find_dn(void *mem_ctx, + const struct ldb_message *msg, + const char *attr_name); + void ldb_msg_sort_elements(struct ldb_message *msg); struct ldb_message *ldb_msg_copy_shallow(void *mem_ctx, -- cgit From a23b63a8e54db7d0ec98ad95cdca11dd4d039e17 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 13 Aug 2006 08:00:36 +0000 Subject: r17516: Change helper function names to make more clear what they are meant to do (This used to be commit ad75cf869550af66119d0293503024d41d834e02) --- source4/lib/ldb/include/ldb.h | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e560068d0c..e756a9b00b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1250,28 +1250,28 @@ int ldb_msg_element_compare(struct ldb_message_element *el1, single valued. */ const struct ldb_val *ldb_msg_find_ldb_val(const struct ldb_message *msg, const char *attr_name); -int ldb_msg_find_int(const struct ldb_message *msg, - const char *attr_name, - int default_value); -unsigned int ldb_msg_find_uint(const struct ldb_message *msg, - const char *attr_name, - unsigned int default_value); -int64_t ldb_msg_find_int64(const struct ldb_message *msg, - const char *attr_name, - int64_t default_value); -uint64_t ldb_msg_find_uint64(const struct ldb_message *msg, +int ldb_msg_find_attr_as_int(const struct ldb_message *msg, const char *attr_name, - uint64_t default_value); -double ldb_msg_find_double(const struct ldb_message *msg, - const char *attr_name, - double default_value); -const char *ldb_msg_find_string(const struct ldb_message *msg, - const char *attr_name, - const char *default_value); - -struct ldb_dn *ldb_msg_find_dn(void *mem_ctx, - const struct ldb_message *msg, - const char *attr_name); + int default_value); +unsigned int ldb_msg_find_attr_as_uint(const struct ldb_message *msg, + const char *attr_name, + unsigned int default_value); +int64_t ldb_msg_find_attr_as_int64(const struct ldb_message *msg, + const char *attr_name, + int64_t default_value); +uint64_t ldb_msg_find_attr_as_uint64(const struct ldb_message *msg, + const char *attr_name, + uint64_t default_value); +double ldb_msg_find_attr_as_double(const struct ldb_message *msg, + const char *attr_name, + double default_value); +const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg, + const char *attr_name, + const char *default_value); + +struct ldb_dn *ldb_msg_find_attr_as_dn(void *mem_ctx, + const struct ldb_message *msg, + const char *attr_name); void ldb_msg_sort_elements(struct ldb_message *msg); -- cgit From 7de75a991bda653497a0989de93608310b55894a Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 17 Aug 2006 08:31:19 +0000 Subject: r17580: Add a new tools to convert back from AD-like schema to OpenLDAP. Add attribute syntax mapping to the existing OpenLDAP -> AD tool. Andrew Bartlett (This used to be commit ba1c652bae700a82acde166e70035d61c320e233) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e756a9b00b..2e659b5307 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1265,6 +1265,9 @@ uint64_t ldb_msg_find_attr_as_uint64(const struct ldb_message *msg, double ldb_msg_find_attr_as_double(const struct ldb_message *msg, const char *attr_name, double default_value); +int ldb_msg_find_attr_as_bool(const struct ldb_message *msg, + const char *attr_name, + int default_value); const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); -- cgit From 0749ab04002f2288cddd994b830163c107230f31 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 23 Aug 2006 09:19:19 +0000 Subject: r17743: fix compiler warnings metze (This used to be commit 694a56b0ae0125594d6a23d8465249f011b6284e) --- source4/lib/ldb/include/ldb.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2e659b5307..b07cdd964c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -80,6 +80,12 @@ struct ldb_val { }; #endif +/*! \cond DOXYGEN_IGNORE */ +#ifndef PRINTF_ATTRIBUTE +#define PRINTF_ATTRIBUTE(a,b) +#endif +/*! \endcond */ + /** internal ldb exploded dn structures */ @@ -204,7 +210,7 @@ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, */ struct ldb_debug_ops { void (*debug)(void *context, enum ldb_debug_level level, - const char *fmt, va_list ap); + const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0); void *context; }; @@ -242,12 +248,6 @@ struct ldb_utf8_fns { */ #define LDB_FLG_RECONNECT 4 -/*! \cond DOXYGEN_IGNORE */ -#ifndef PRINTF_ATTRIBUTE -#define PRINTF_ATTRIBUTE(a,b) -#endif -/*! \endcond */ - /* structures for ldb_parse_tree handling code */ @@ -1000,7 +1000,7 @@ int ldb_valid_attr_name(const char *s); \sa ldb_ldif_read for the reader equivalent to this function. */ int ldb_ldif_write(struct ldb_context *ldb, - int (*fprintf_fn)(void *, const char *, ...), + int (*fprintf_fn)(void *, const char *, ...) PRINTF_ATTRIBUTE(2,3), void *private_data, const struct ldb_ldif *ldif); @@ -1329,7 +1329,7 @@ struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); */ int ldb_set_debug(struct ldb_context *ldb, void (*debug)(void *context, enum ldb_debug_level level, - const char *fmt, va_list ap), + const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0), void *context); /** -- cgit From a2ca0b5e3cf2e1ac485f7046d67de9fc4e5171f9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 25 Aug 2006 06:41:37 +0000 Subject: r17821: changed ldb_search() and the ldbsearch command line utility to automatically work out the basedn when basedn==NULL. The basedn is fetched from the rootDSE defaultNamingContext value (if there is one) This means we don't have to have the defaultNamingContext logic in lots of places. It makes a lot of sense to me to have basedn==NULL mean "use the default, as given by the database" Note that explicitly specifing a basedn of '' is not the same thing, and will not trigger this code The baseDN is cached in a ldb opaque, so we only have to fetch it once (This used to be commit 5d1b66b68fc517ce684f75e466ed5f25e46857d5) --- source4/lib/ldb/include/ldb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index b07cdd964c..415eacbf61 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -822,6 +822,11 @@ struct ldb_context *ldb_init(void *mem_ctx); */ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); +/* + return an automatic baseDN from the defaultNamingContext of the rootDSE +*/ +const struct ldb_dn *ldb_auto_basedn(struct ldb_context *ldb); + /** Search the database -- cgit From 88b04ab6e65137079b2dad76d1cea07e7ea9ab80 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Fri, 25 Aug 2006 12:59:03 +0000 Subject: r17830: Set the default_basedn (hey, it comes from the "default" naming contex :-) once at connection time, after modules have been loaded. Introduce a function to retrieve the value where needed. (This used to be commit 0caf6a44e03393c645030a9288e7dfd31e97c98b) --- source4/lib/ldb/include/ldb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 415eacbf61..124cba9b66 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -824,8 +824,9 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co /* return an automatic baseDN from the defaultNamingContext of the rootDSE + This value have been set in an opaque pointer at connection time */ -const struct ldb_dn *ldb_auto_basedn(struct ldb_context *ldb); +const struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); /** Search the database -- cgit From 8d1b32083eb9f35b5e3de3354480aa5e0e8a76d1 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 21 Sep 2006 06:14:32 +0000 Subject: r18777: add helper functions to create an ldb_request structure (This used to be commit bcbe82873f2f0a4e2552ed27eb171028de4560a7) --- source4/lib/ldb/include/ldb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 124cba9b66..78d701689d 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -743,6 +743,7 @@ struct ldb_sequence_number { uint64_t seq_num; }; +typedef int (*ldb_request_callback_t)(struct ldb_context *, void *, struct ldb_reply *); struct ldb_request { enum ldb_request_type operation; @@ -761,7 +762,7 @@ struct ldb_request { struct ldb_control **controls; void *context; - int (*callback)(struct ldb_context *, void *, struct ldb_reply *); + ldb_request_callback_t callback; int timeout; time_t starttime; -- cgit From 77db3973c417cc934485dbd6bf1a8a1c84c1b30b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 21 Sep 2006 06:44:12 +0000 Subject: r18781: Move the usnCreated and usnChanged handling around again. This moves these attributes from objectguid into an optional backend (objectguid), used by ltdb. For OpenLDAP, the entryUUID module converts entryCSN into usnChanged. This also changes the sequence number API, and uses 'time based' sequence numbers, when an LDAP or similar backend is detected. To assist this, we also store the last modified time in the TDB, whenever we change a value. Andrew Bartlett (This used to be commit 72858f859483c0c532dddb2c146d6bd7b9be5072) --- source4/lib/ldb/include/ldb.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 78d701689d..cf4a1f282b 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -740,7 +740,13 @@ struct ldb_register_partition { }; struct ldb_sequence_number { + enum ldb_sequence_type { + LDB_SEQ_HIGHEST_SEQ, + LDB_SEQ_HIGHEST_TIMESTAMP, + LDB_SEQ_NEXT + } type; uint64_t seq_num; + uint32_t flags; }; typedef int (*ldb_request_callback_t)(struct ldb_context *, void *, struct ldb_reply *); @@ -922,11 +928,6 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct */ int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); -/** - Obtain current database sequence number -*/ -int ldb_sequence_number(struct ldb_context *ldb, uint64_t *seq_num); - /** start a transaction */ -- cgit From 4c3b07b654f4eb9041da0e9a84bc60d667901fe5 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 27 Sep 2006 05:57:41 +0000 Subject: r18942: add a ldb_set_create_perms() function in ldb. I didn't call it ldb_set_umask() (which is what we had discussed) as it doesn't actually set the umask (in effect it sets the inverse of the umask - the perms to be used for the file) (This used to be commit 7e2ec875908c112d5c3b0f6d18f9a8bbacf33539) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index cf4a1f282b..82da9df0dd 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -781,6 +781,7 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type); int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout); int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); +void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms); /** Initialise ldbs' global information -- cgit From bbc056e067e1b721dc2ef6958ab653c1eddec3a1 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 9 Oct 2006 09:56:13 +0000 Subject: r19196: merge from samba3: pass always a mem_ctx to functions and a ldb_context where needed metze (This used to be commit 67a6a41ba3af840cd8226de73576a90ecf602caa) --- source4/lib/ldb/include/ldb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 82da9df0dd..d2f3bd53d3 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1146,11 +1146,11 @@ struct ldb_dn *ldb_dn_new(void *mem_ctx); struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); struct ldb_dn *ldb_dn_explode_or_special(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); +char *ldb_dn_linearize_casefold(struct ldb_context *ldb, 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); +struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const struct ldb_dn *edn); +struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, void *mem_ctx, 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); -- cgit From 0cf42c464ea240c4e57cc5b0c31227a0c5f684d4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 17 Oct 2006 05:50:01 +0000 Subject: r19365: fixed a memory leak in the ldb attribute handling (This used to be commit d7e07685164141f8fb2c2a6258e1fcb46ff9d06c) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index d2f3bd53d3..0af734eb13 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -357,6 +357,9 @@ struct ldb_attrib_handler { */ #define LDB_ATTR_FLAG_HIDDEN (1<<0) +/* the attribute handler name should be freed when released */ +#define LDB_ATTR_FLAG_ALLOCATED (1<<1) + /** The attribute is constructed from other attributes */ -- cgit From 21e63dca9b6503d377c5605384341cd7079b868b Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 22 Oct 2006 21:16:22 +0000 Subject: r19453: Expose helper functions (This used to be commit ee86e88e4f523d67900b52b5a4d4040a76360c61) --- source4/lib/ldb/include/ldb.h | 141 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0af734eb13..62e8039a2c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -839,6 +839,145 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co */ const struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); + +/** + The Default iasync search callback function + + \param ldb the context associated with the database (from ldb_init()) + \param context the callback context + \param ares a single reply from the async core + + \return result code (LDB_SUCCESS on success, or a failure code) + + \note this function expects the context to always be an struct ldb_result pointer + AND a talloc context, this function will steal on the context each message + from the ares reply passed on by the async core so that in the end all the + messages will be in the context (ldb_result) memory tree. + Freeing the passed context (ldb_result tree) will free all the resources + (the request need to be freed separately and the result doe not depend on the + request that can be freed as sson as the search request is finished) +*/ + +int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares); + +/** + Helper function to build a search request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one) + \param scope the search scope for the query + \param expression the search expression to use for this query + \param attrs the search attributes for the query (pass NULL if none required) + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ + +int ldb_build_search_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const struct ldb_dn *base, + enum ldb_scope scope, + const char *expression, + const char * const *attrs, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + +/** + Helper function to build an add request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param message contains the entry to be added + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ + +int ldb_build_add_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const struct ldb_message *message, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + +/** + Helper function to build a modify request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param message contains the entry to be modified + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ + +int ldb_build_mod_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const struct ldb_message *message, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + +/** + Helper function to build a delete request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param dn the DN to be deleted + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ + +int ldb_build_del_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const struct ldb_dn *dn, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + +/** + Helper function to build a rename request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param olddn the old DN + \param newdn the new DN + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ + +int ldb_build_rename_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const struct ldb_dn *olddn, + const struct ldb_dn *newdn, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + /** Search the database @@ -846,7 +985,7 @@ const struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); records that match an LDAP-like search expression \param ldb the context associated with the database (from ldb_init()) - \param base the Base Distinguished Name for the query (pass NULL for root DN) + \param base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one) \param scope the search scope for the query \param expression the search expression to use for this query \param attrs the search attributes for the query (pass NULL if none required) -- cgit From 7f833458ca0083654e34cbfde1c6c6510cab1826 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 25 Oct 2006 01:42:59 +0000 Subject: r19489: Change ldb_msg_add_value and ldb_msg_add_empty to take a foruth argument. This is a pointer to an element pointer. If it is not null it will be filled with the pointer of the manipulated element. Will avoid double searches on the elements list in some cases. (This used to be commit 0fa5d4bc225b83e9f63ac6d75bffc4c08eb6b620) --- source4/lib/ldb/include/ldb.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 62e8039a2c..aa8b9447b2 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1366,7 +1366,10 @@ struct ldb_val *ldb_msg_find_val(const struct ldb_message_element *el, /** add a new empty element to a ldb_message */ -int ldb_msg_add_empty(struct ldb_message *msg, const char *attr_name, int flags); +int ldb_msg_add_empty(struct ldb_message *msg, + const char *attr_name, + int flags, + struct ldb_message_element **return_el); /** add a element to a ldb_message @@ -1375,8 +1378,9 @@ int ldb_msg_add(struct ldb_message *msg, const struct ldb_message_element *el, int flags); int ldb_msg_add_value(struct ldb_message *msg, - const char *attr_name, - const struct ldb_val *val); + const char *attr_name, + const struct ldb_val *val, + struct ldb_message_element **return_el); int ldb_msg_add_steal_value(struct ldb_message *msg, const char *attr_name, struct ldb_val *val); -- cgit From b7774527faf095f612eb1de48efacec6bd710a87 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 1 Nov 2006 23:31:26 +0000 Subject: r19531: Make struct ldb_dn opaque and local to ldb_dn.c (This used to be commit 889fb983ba1cf8a11424a8b3dc3a5ef76e780082) --- source4/lib/ldb/include/ldb.h | 62 +++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 35 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index aa8b9447b2..17a2ec7556 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -3,7 +3,7 @@ Copyright (C) Andrew Tridgell 2004 Copyright (C) Stefan Metzmacher 2004 - Copyright (C) Simo Sorce 2005 + Copyright (C) Simo Sorce 2005-2006 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -86,18 +86,9 @@ struct ldb_val { #endif /*! \endcond */ -/** - 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; -}; +/* opaque ldb_dn structures, see ldb_dn.c for internals */ +struct ldb_dn_component; +struct ldb_dn; /** There are a number of flags that are used with ldap_modify() in @@ -193,12 +184,6 @@ enum ldb_scope {LDB_SCOPE_DEFAULT=-1, struct ldb_context; -/* - the fuction type for the callback used in traversing the database -*/ -typedef int (*ldb_traverse_fn)(struct ldb_context *, const struct ldb_message *); - - /* debugging uses one of the following levels */ enum ldb_debug_level {LDB_DEBUG_FATAL, LDB_DEBUG_ERROR, LDB_DEBUG_WARNING, LDB_DEBUG_TRACE}; @@ -333,22 +318,25 @@ char *ldb_binary_encode_string(void *mem_ctx, const char *string); typedef int (*ldb_attr_handler_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, struct ldb_val *); typedef int (*ldb_attr_comparison_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, const struct ldb_val *); +/* + attribute handler structure + + attr -> The attribute name + flags -> LDB_ATTR_FLAG_* + ldif_read_fn -> convert from ldif to binary format + ldif_write_fn -> convert from binary to ldif format + canonicalise_fn -> canonicalise a value, for use by indexing and dn construction + comparison_fn -> compare two values +*/ + struct ldb_attrib_handler { - const char *attr; - /* LDB_ATTR_FLAG_* */ + const char *attr; 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; }; @@ -1295,18 +1283,25 @@ struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const str struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, void *mem_ctx, 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_copy_rebase(void *mem_ctx, const struct ldb_dn *old, const struct ldb_dn *old_base, const struct ldb_dn *new_base); 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_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...) PRINTF_ATTRIBUTE(3,4); -struct ldb_dn_component *ldb_dn_get_rdn(void *mem_ctx, const struct ldb_dn *dn); +char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); +char *ldb_dn_canonical_ex_string(void *mem_ctx, const struct ldb_dn *dn); +int ldb_dn_get_comp_num(const struct ldb_dn *dn); +const char *ldb_dn_get_component_name(const struct ldb_dn *dn, unsigned int num); +const struct ldb_val *ldb_dn_get_component_val(const struct ldb_dn *dn, unsigned int num); +const char *ldb_dn_get_rdn_name(const struct ldb_dn *dn); +const struct ldb_val *ldb_dn_get_rdn_val(const struct ldb_dn *dn); +int ldb_dn_set_component(struct ldb_dn *dn, int num, const char *name, const struct ldb_val val); + + /* useful functions for ldb_message structure manipulation */ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); @@ -1546,9 +1541,6 @@ char *ldb_timestring(void *mem_ctx, time_t t); */ time_t ldb_string_to_time(const char *s); -char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); -char *ldb_dn_canonical_ex_string(void *mem_ctx, const struct ldb_dn *dn); - void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp); #endif -- cgit From 4889eb9f7aae9349e426d0f6d2217adff67eaebd Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Nov 2006 00:59:34 +0000 Subject: r19831: Big ldb_dn optimization and interfaces enhancement patch This patch changes a lot of the code in ldb_dn.c, and also removes and add a number of manipulation functions around. The aim is to avoid validating a dn if not necessary as the validation code is necessarily slow. This is mainly to speed up internal operations where input is not user generated and so we can assume the DNs need no validation. The code is designed to keep the data as a string if possible. The code is not yet 100% perfect, but pass all the tests so far. A memleak is certainly present, I'll work on that next. Simo. (This used to be commit a580c871d3784602a9cce32d33419e63c8236e63) --- source4/lib/ldb/include/ldb.h | 94 ++++++++++++++++++++++--------------------- 1 file changed, 49 insertions(+), 45 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 17a2ec7556..46894cd3c0 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -698,7 +698,7 @@ struct ldb_handle { }; struct ldb_search { - const struct ldb_dn *base; + struct ldb_dn *base; enum ldb_scope scope; const struct ldb_parse_tree *tree; const char * const *attrs; @@ -714,12 +714,12 @@ struct ldb_modify { }; struct ldb_delete { - const struct ldb_dn *dn; + struct ldb_dn *dn; }; struct ldb_rename { - const struct ldb_dn *olddn; - const struct ldb_dn *newdn; + struct ldb_dn *olddn; + struct ldb_dn *newdn; }; struct ldb_register_control { @@ -727,7 +727,7 @@ struct ldb_register_control { }; struct ldb_register_partition { - const struct ldb_dn *dn; + struct ldb_dn *dn; }; struct ldb_sequence_number { @@ -825,7 +825,7 @@ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, co return an automatic baseDN from the defaultNamingContext of the rootDSE This value have been set in an opaque pointer at connection time */ -const struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); +struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); /** @@ -868,7 +868,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l int ldb_build_search_req(struct ldb_request **ret_req, struct ldb_context *ldb, void *mem_ctx, - const struct ldb_dn *base, + struct ldb_dn *base, enum ldb_scope scope, const char *expression, const char * const *attrs, @@ -937,7 +937,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req, int ldb_build_del_req(struct ldb_request **ret_req, struct ldb_context *ldb, void *mem_ctx, - const struct ldb_dn *dn, + struct ldb_dn *dn, struct ldb_control **controls, void *context, ldb_request_callback_t callback); @@ -960,8 +960,8 @@ int ldb_build_del_req(struct ldb_request **ret_req, int ldb_build_rename_req(struct ldb_request **ret_req, struct ldb_context *ldb, void *mem_ctx, - const struct ldb_dn *olddn, - const struct ldb_dn *newdn, + struct ldb_dn *olddn, + struct ldb_dn *newdn, struct ldb_control **controls, void *context, ldb_request_callback_t callback); @@ -984,7 +984,7 @@ int ldb_build_rename_req(struct ldb_request **ret_req, \note use talloc_free() to free the ldb_result returned */ int ldb_search(struct ldb_context *ldb, - const struct ldb_dn *base, + struct ldb_dn *base, enum ldb_scope scope, const char *expression, const char * const *attrs, struct ldb_result **res); @@ -993,7 +993,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 struct ldb_dn *base, + struct ldb_dn *base, enum ldb_scope scope, struct ldb_parse_tree *tree, const char * const *attrs, struct ldb_result **res); @@ -1043,7 +1043,7 @@ int ldb_modify(struct ldb_context *ldb, \return result code (LDB_SUCCESS if the record was renamed as requested, otherwise a failure code) */ -int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct ldb_dn *newdn); +int ldb_rename(struct ldb_context *ldb, struct ldb_dn *olddn, struct ldb_dn *newdn); /** Delete a record from the database @@ -1057,7 +1057,7 @@ int ldb_rename(struct ldb_context *ldb, const struct ldb_dn *olddn, const struct \return result code (LDB_SUCCESS if the record was deleted, otherwise a failure code) */ -int ldb_delete(struct ldb_context *ldb, const struct ldb_dn *dn); +int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn); /** start a transaction @@ -1269,38 +1269,41 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb, /* The following definitions come from lib/ldb/common/ldb_dn.c */ -int ldb_dn_is_special(const struct ldb_dn *dn); -int ldb_dn_check_special(const struct ldb_dn *dn, const char *check); +struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *dn); +struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...); +bool ldb_dn_validate(struct ldb_dn *dn); + 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); -struct ldb_dn *ldb_dn_explode_or_special(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, 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, void *mem_ctx, const struct ldb_dn *edn); -struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, void *mem_ctx, 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_copy_rebase(void *mem_ctx, const struct ldb_dn *old, const struct ldb_dn *old_base, const struct ldb_dn *new_base); -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_compose(void *mem_ctx, const struct ldb_dn *dn1, const struct ldb_dn *dn2); -struct ldb_dn *ldb_dn_string_compose(void *mem_ctx, const struct ldb_dn *base, const char *child_fmt, ...) PRINTF_ATTRIBUTE(3,4); -char *ldb_dn_canonical_string(void *mem_ctx, const struct ldb_dn *dn); -char *ldb_dn_canonical_ex_string(void *mem_ctx, const struct ldb_dn *dn); -int ldb_dn_get_comp_num(const struct ldb_dn *dn); -const char *ldb_dn_get_component_name(const struct ldb_dn *dn, unsigned int num); -const struct ldb_val *ldb_dn_get_component_val(const struct ldb_dn *dn, unsigned int num); -const char *ldb_dn_get_rdn_name(const struct ldb_dn *dn); -const struct ldb_val *ldb_dn_get_rdn_val(const struct ldb_dn *dn); +char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_casefold(void *mem_ctx, struct ldb_dn *dn); +const char *ldb_dn_get_linearized(struct ldb_dn *dn); +const char *ldb_dn_get_casefold(struct ldb_dn *dn); + +int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn); +int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); + +bool ldb_dn_add_base(struct ldb_dn *dn, struct ldb_dn *base); +bool ldb_dn_add_base_fmt(struct ldb_dn *dn, const char *base_fmt, ...); +bool ldb_dn_add_child(struct ldb_dn *dn, struct ldb_dn *child); +bool ldb_dn_add_child_fmt(struct ldb_dn *dn, const char *child_fmt, ...); +bool ldb_dn_remove_base_components(struct ldb_dn *dn, unsigned int num); +bool ldb_dn_remove_child_components(struct ldb_dn *dn, unsigned int num); + +struct ldb_dn *ldb_dn_copy(void *mem_ctx, struct ldb_dn *dn); +struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_canonical_string(void *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_canonical_ex_string(void *mem_ctx, struct ldb_dn *dn); +int ldb_dn_get_comp_num(struct ldb_dn *dn); +const char *ldb_dn_get_component_name(struct ldb_dn *dn, unsigned int num); +const struct ldb_val *ldb_dn_get_component_val(struct ldb_dn *dn, unsigned int num); +const char *ldb_dn_get_rdn_name(struct ldb_dn *dn); +const struct ldb_val *ldb_dn_get_rdn_val(struct ldb_dn *dn); int ldb_dn_set_component(struct ldb_dn *dn, int num, const char *name, const struct ldb_val val); +bool ldb_dn_is_valid(struct ldb_dn *dn); +bool ldb_dn_is_special(struct ldb_dn *dn); +bool ldb_dn_check_special(struct ldb_dn *dn, const char *check); +bool ldb_dn_is_null(struct ldb_dn *dn); /* useful functions for ldb_message structure manipulation */ @@ -1422,9 +1425,10 @@ const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg, const char *attr_name, const char *default_value); -struct ldb_dn *ldb_msg_find_attr_as_dn(void *mem_ctx, +struct ldb_dn *ldb_msg_find_attr_as_dn(struct ldb_context *ldb, + void *mem_ctx, const struct ldb_message *msg, - const char *attr_name); + const char *attr_name); void ldb_msg_sort_elements(struct ldb_message *msg); -- cgit From a9e31b33b55a873c2f01db5e348560176adf863d Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 22 Nov 2006 02:05:19 +0000 Subject: r19832: better prototypes for the linearization functions: - ldb_dn_get_linearized returns a const string - ldb_dn_alloc_linearized allocs astring with the linearized dn (This used to be commit 3929c086d5d0b3f08b1c4f2f3f9602c3f4a9a4bd) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 46894cd3c0..c44c1d6ee7 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1274,10 +1274,10 @@ struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char bool ldb_dn_validate(struct ldb_dn *dn); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); -char *ldb_dn_linearize(void *mem_ctx, struct ldb_dn *dn); -char *ldb_dn_casefold(void *mem_ctx, struct ldb_dn *dn); const char *ldb_dn_get_linearized(struct ldb_dn *dn); const char *ldb_dn_get_casefold(struct ldb_dn *dn); +char *ldb_dn_alloc_linearized(void *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_alloc_casefold(void *mem_ctx, struct ldb_dn *dn); int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn); int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); -- cgit From 4f8b4a8ef19da2bcbeea1ae79e9ebbdb8de08169 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sun, 26 Nov 2006 04:39:17 +0000 Subject: r19906: ldb_attr_cmp is used a lot remove unneded overhead of a function call (This used to be commit 3ca25867621af049c6cc52e919fa46dd26c31918) --- source4/lib/ldb/include/ldb.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c44c1d6ee7..9d48810078 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1320,8 +1320,12 @@ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn1, const char *dn2); \return 0 if the attribute names are the same, or only differ in case; non-zero if there are any differences + + attribute names are restricted by rfc2251 so using + strcasecmp and toupper here is ok. + return 0 for match */ -int ldb_attr_cmp(const char *attr1, const char *attr2); +#define ldb_attr_cmp(a, b) strcasecmp(a, b) char *ldb_attr_casefold(void *mem_ctx, const char *s); int ldb_attr_dn(const char *attr); -- cgit From ea212eb00fd358e7335648b9cd556227e53df367 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 5 Dec 2006 04:25:27 +0000 Subject: r20034: Start using ldb_search_exp_fmt() (This used to be commit 4f07542143ddf5066f0360d965f26a8470504047) --- source4/lib/ldb/include/ldb.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9d48810078..dfa447b534 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -989,6 +989,9 @@ int ldb_search(struct ldb_context *ldb, const char *expression, const char * const *attrs, struct ldb_result **res); +int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, + struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs, + const char *exp_fmt, ...); /* like ldb_search() but takes a parse tree */ -- cgit From dec69975f5d62d4c2d038ad22d405e5cb183d78b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 5 Dec 2006 16:20:39 +0000 Subject: r20046: Add ldb_search_exp_fmt and port comment to 4 (This used to be commit 879dfed8d8356aae6a11352b89bdc0f2d9f28970) --- source4/lib/ldb/include/ldb.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index dfa447b534..eb1f505099 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -989,9 +989,16 @@ int ldb_search(struct ldb_context *ldb, const char *expression, const char * const *attrs, struct ldb_result **res); -int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, - struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs, - const char *exp_fmt, ...); +/* + * a useful search function where you can easily define the expression and + * that takes a memory context where results are allocated +*/ + +int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, + struct ldb_result **result, struct ldb_dn *base, + enum ldb_scope scope, const char * const *attrs, + const char *exp_fmt, ...); + /* like ldb_search() but takes a parse tree */ -- cgit From e55ff42229d67c1447f2c811191b79137b1ce8cc Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 14 Dec 2006 10:03:21 +0000 Subject: r20168: start separating attributes and syntaxes metze (This used to be commit 8dda4342f648aa71878ac9eeb7941710e2813aee) --- source4/lib/ldb/include/ldb.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index eb1f505099..3db334d341 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -340,6 +340,14 @@ struct ldb_attrib_handler { ldb_attr_comparison_t comparison_fn; }; +struct ldb_schema_syntax { + const char *name; + ldb_attr_handler_t ldif_read_fn; + ldb_attr_handler_t ldif_write_fn; + ldb_attr_handler_t canonicalise_fn; + ldb_attr_comparison_t comparison_fn; +}; + /** The attribute is not returned by default */ -- cgit From c69717755abeaf8bf93e76255d0912e3a24b7cb0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Dec 2006 13:08:57 +0000 Subject: r20184: change ldb_attrib_handler into ldb_schema_attribute, which has a pointer to a ldb_schema_syntax struct. the default attribute handler is now registered dynamicly as "*" attribute, instead of having its own code path. ldb_schema_attribute's can be added to the ldb_schema given a ldb_schema_syntax struct or the syntax name we may also need to introduce a ldb_schema_matching_rule, and add a pointer to a default ldb_schema_matching_rule in the ldb_schema_syntax. metze (This used to be commit b97b8f5dcbce006f005e53ca79df3330e62f117b) --- source4/lib/ldb/include/ldb.h | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3db334d341..853adb82c6 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -329,25 +329,23 @@ typedef int (*ldb_attr_comparison_t)(struct ldb_context *, void *mem_ctx, const comparison_fn -> compare two values */ -struct ldb_attrib_handler { - - const char *attr; - unsigned flags; - +struct ldb_schema_syntax { + const char *name; ldb_attr_handler_t ldif_read_fn; ldb_attr_handler_t ldif_write_fn; ldb_attr_handler_t canonicalise_fn; ldb_attr_comparison_t comparison_fn; }; -struct ldb_schema_syntax { +struct ldb_schema_attribute { const char *name; - ldb_attr_handler_t ldif_read_fn; - ldb_attr_handler_t ldif_write_fn; - ldb_attr_handler_t canonicalise_fn; - ldb_attr_comparison_t comparison_fn; + unsigned flags; + const struct ldb_schema_syntax *syntax; }; +const struct ldb_schema_attribute *ldb_schema_attribute_by_name(struct ldb_context *ldb, + const char *name); + /** The attribute is not returned by default */ @@ -1281,10 +1279,6 @@ char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); */ int ldb_base64_decode(char *s); -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 */ struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *dn); @@ -1524,10 +1518,6 @@ int ldb_set_debug_stderr(struct ldb_context *ldb); int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value); void *ldb_get_opaque(struct ldb_context *ldb, const char *name); -const struct ldb_attrib_handler *ldb_attrib_handler(struct ldb_context *ldb, - const char *attrib); - - const char **ldb_attr_list_copy(void *mem_ctx, const char * const *attrs); const char **ldb_attr_list_copy_add(void *mem_ctx, const char * const *attrs, const char *new_attr); int ldb_attr_in_list(const char * const *attrs, const char *attr); -- cgit From a3c0f3035d338b5bf00ecd436cb0ebfcbdc7345d Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 15 Dec 2006 20:22:17 +0000 Subject: r20189: remove unused struct element metze (This used to be commit d20d1872d5ed1176928b85ef9811c6a5177d0148) --- source4/lib/ldb/include/ldb.h | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 853adb82c6..b00bb0fd46 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -156,7 +156,6 @@ struct ldb_message { struct ldb_dn *dn; unsigned int num_elements; struct ldb_message_element *elements; - void *private_data; /* private to the backend */ }; enum ldb_changetype { -- cgit From 525447821e70e089d03713ff92d0ad0f2860b38f Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Dec 2006 16:53:12 +0000 Subject: r20316: fix compiler warning metze (This used to be commit 58cbbaa4b49bfed6d4e9c5802af988864e06675f) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index b00bb0fd46..3f9ba67170 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1002,7 +1002,7 @@ int ldb_search(struct ldb_context *ldb, int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs, - const char *exp_fmt, ...); + const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8); /* like ldb_search() but takes a parse tree -- cgit From c65b5a6f87dd1f859a8ccbdc709565ac7841006b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Dec 2006 17:26:09 +0000 Subject: r20319: fix compiler warnings metze (This used to be commit 3769270a6a22dd29845e889b0601fcdf7c46acb5) --- source4/lib/ldb/include/ldb.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3f9ba67170..0438b88bbb 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1281,7 +1281,7 @@ int ldb_base64_decode(char *s); /* The following definitions come from lib/ldb/common/ldb_dn.c */ struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *dn); -struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...); +struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...) PRINTF_ATTRIBUTE(3,4); bool ldb_dn_validate(struct ldb_dn *dn); char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); @@ -1294,9 +1294,9 @@ int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn); int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); bool ldb_dn_add_base(struct ldb_dn *dn, struct ldb_dn *base); -bool ldb_dn_add_base_fmt(struct ldb_dn *dn, const char *base_fmt, ...); +bool ldb_dn_add_base_fmt(struct ldb_dn *dn, const char *base_fmt, ...) PRINTF_ATTRIBUTE(2,3); bool ldb_dn_add_child(struct ldb_dn *dn, struct ldb_dn *child); -bool ldb_dn_add_child_fmt(struct ldb_dn *dn, const char *child_fmt, ...); +bool ldb_dn_add_child_fmt(struct ldb_dn *dn, const char *child_fmt, ...) PRINTF_ATTRIBUTE(2,3); bool ldb_dn_remove_base_components(struct ldb_dn *dn, unsigned int num); bool ldb_dn_remove_child_components(struct ldb_dn *dn, unsigned int num); -- cgit From 6f68945f7dc88814a5ed587512c7d29d18de5f34 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 22 Dec 2006 17:27:07 +0000 Subject: r20320: add missing prototypes metze (This used to be commit b9d0ea3954e3f76436e976555540dd29dacd621d) --- source4/lib/ldb/include/ldb.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0438b88bbb..1e2a6b0bbd 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -826,13 +826,30 @@ struct ldb_context *ldb_init(void *mem_ctx); */ int ldb_connect(struct ldb_context *ldb, const char *url, unsigned int flags, const char *options[]); +/* + return an automatic basedn from the rootDomainNamingContext of the rootDSE + This value have been set in an opaque pointer at connection time +*/ +struct ldb_dn *ldb_get_root_basedn(struct ldb_context *ldb); + +/* + return an automatic basedn from the configurationNamingContext of the rootDSE + This value have been set in an opaque pointer at connection time +*/ +struct ldb_dn *ldb_get_config_basedn(struct ldb_context *ldb); + +/* + return an automatic basedn from the schemaNamingContext of the rootDSE + This value have been set in an opaque pointer at connection time +*/ +struct ldb_dn *ldb_get_schema_basedn(struct ldb_context *ldb); + /* return an automatic baseDN from the defaultNamingContext of the rootDSE This value have been set in an opaque pointer at connection time */ struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); - /** The Default iasync search callback function -- cgit From 71bc79caab7f9510151b31846755cc4db7b81ec0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 2 Jan 2007 10:59:38 +0000 Subject: r20462: add functions to handle UTCTime strings metze (This used to be commit 49c7da812c290e23bb65b98a2710fb90c4a0ece2) --- source4/lib/ldb/include/ldb.h | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 1e2a6b0bbd..4f8ee1f941 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1550,9 +1550,9 @@ void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); /** Convert a time structure to a string - This function converts a time_t structure to an LDAP formatted time - string. - + This function converts a time_t structure to an LDAP formatted + GeneralizedTime string. + \param mem_ctx the memory context to allocate the return string in \param t the time structure to convert @@ -1564,8 +1564,8 @@ char *ldb_timestring(void *mem_ctx, time_t t); /** Convert a string to a time structure - This function converts an LDAP formatted time string to a time_t - structure. + This function converts an LDAP formatted GeneralizedTime string + to a time_t structure. \param s the string to convert @@ -1573,6 +1573,32 @@ char *ldb_timestring(void *mem_ctx, time_t t); */ time_t ldb_string_to_time(const char *s); +/** + Convert a time structure to a string + + This function converts a time_t structure to an LDAP formatted + UTCTime string. + + \param mem_ctx the memory context to allocate the return string in + \param t the time structure to convert + + \return the formatted string, or NULL if the time structure could + not be converted +*/ +char *ldb_timestring_utc(void *mem_ctx, time_t t); + +/** + Convert a string to a time structure + + This function converts an LDAP formatted UTCTime string + to a time_t structure. + + \param s the string to convert + + \return the time structure, or 0 if the string cannot be converted +*/ +time_t ldb_string_utc_to_time(const char *s); + void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp); #endif -- cgit From f29ea516f99a250765c8a718d7212577167f7931 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Jan 2007 09:03:28 +0000 Subject: r20581: - the ldb modules have explicit hooks for extended operations so call them - reorder the request operations first all with explixit hooks metze (This used to be commit aababcbb05ad476507bba35723eaef01d18b4d4e) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 4f8ee1f941..8a31720eea 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -651,9 +651,9 @@ enum ldb_request_type { LDB_DELETE, LDB_RENAME, LDB_EXTENDED, + LDB_SEQUENCE_NUMBER, LDB_REQ_REGISTER_CONTROL, - LDB_REQ_REGISTER_PARTITION, - LDB_SEQUENCE_NUMBER + LDB_REQ_REGISTER_PARTITION }; enum ldb_reply_type { -- cgit From bc4821a4ce06317219a6c801f99f3fe9a470f1ce Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Jan 2007 09:25:54 +0000 Subject: r20582: use void *data in the ldb_extended struct to match what we have in ldb_control add a request element for extended requests metze (This used to be commit 530b3cd2501efb7763cbb7d3301ff0550689effe) --- source4/lib/ldb/include/ldb.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8a31720eea..63cfb04fdd 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -683,8 +683,7 @@ struct ldb_result { struct ldb_extended { const char *oid; - const char *value; - int value_len; + void *data; }; struct ldb_reply { @@ -714,7 +713,7 @@ struct ldb_add { const struct ldb_message *message; }; -struct ldb_modify { +struct ldb_modify { const struct ldb_message *message; }; @@ -756,9 +755,10 @@ struct ldb_request { struct ldb_modify mod; struct ldb_delete del; struct ldb_rename rename; + struct ldb_extended extended; + struct ldb_sequence_number seq_num; struct ldb_register_control reg_control; struct ldb_register_partition reg_partition; - struct ldb_sequence_number seq_num; } op; struct ldb_control **controls; -- cgit From b5eb73280e82905bafbe827e781481386c98cc82 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 6 Jan 2007 09:49:29 +0000 Subject: r20583: implement the frontend calls for extended operations metze (This used to be commit cfcd05adc03effeaf85dc776c2d5bb5244f0d6d4) --- source4/lib/ldb/include/ldb.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 63cfb04fdd..78d5bba06e 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -674,18 +674,19 @@ enum ldb_state { LDB_ASYNC_DONE }; +struct ldb_extended { + const char *oid; + void *data; +}; + struct ldb_result { unsigned int count; struct ldb_message **msgs; char **refs; + struct ldb_extended *extended; struct ldb_control **controls; }; -struct ldb_extended { - const char *oid; - void *data; -}; - struct ldb_reply { enum ldb_reply_type type; struct ldb_message *message; -- cgit From b931e6683508ddbd77a34725913f706870ed8eb7 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 7 Jan 2007 15:26:35 +0000 Subject: r20596: add prototypes for the ldb_extended functions metze (This used to be commit 8d3a3117c313c2950381e8d21eb92469a82c3afe) --- source4/lib/ldb/include/ldb.h | 64 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 78d5bba06e..7b37b50468 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -852,10 +852,10 @@ struct ldb_dn *ldb_get_schema_basedn(struct ldb_context *ldb); struct ldb_dn *ldb_get_default_basedn(struct ldb_context *ldb); /** - The Default iasync search callback function + The default async search callback function \param ldb the context associated with the database (from ldb_init()) - \param context the callback context + \param context the callback context (struct ldb_result *) \param ares a single reply from the async core \return result code (LDB_SUCCESS on success, or a failure code) @@ -1092,6 +1092,66 @@ int ldb_rename(struct ldb_context *ldb, struct ldb_dn *olddn, struct ldb_dn *new */ int ldb_delete(struct ldb_context *ldb, struct ldb_dn *dn); +/** + The default async extended operation callback function + + \param ldb the context associated with the database (from ldb_init()) + \param context the callback context (struct ldb_result *) + \param ares a single reply from the async core + + \return result code (LDB_SUCCESS on success, or a failure code) + + \note this function expects the context to always be an struct ldb_result pointer + AND a talloc context, this function will steal on the context each message + from the ares reply passed on by the async core so that in the end all the + messages will be in the context (ldb_result) memory tree. + Freeing the passed context (ldb_result tree) will free all the resources + (the request need to be freed separately and the result doe not depend on the + request that can be freed as sson as the search request is finished) +*/ +int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares); + +/** + Helper function to build a extended request + + \param ret_req the request structure is returned here (talloced on mem_ctx) + \param ldb the context associated with the database (from ldb_init()) + \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param oid the OID of the extended operation. + \param data void pointer a the extended operation specific parameters + \param controls an array of controls + \param context the callback function context + \param the callback function to handle the async replies + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ +int ldb_build_extended_req(struct ldb_request **ret_req, + struct ldb_context *ldb, + void *mem_ctx, + const char *oid, + void *data, + struct ldb_control **controls, + void *context, + ldb_request_callback_t callback); + +/** + call an extended operation + + This function deletes a record from the database. + + \param ldb the context associated with the database (from ldb_init()) + \param oid the OID of the extended operation. + \param data void pointer a the extended operation specific parameters + \param res the result of the extended operation + + \return result code (LDB_SUCCESS if the extended operation returned fine, + otherwise a failure code) +*/ +int ldb_extended(struct ldb_context *ldb, + const char *oid, + void *data, + struct ldb_result **res); + /** start a transaction */ -- cgit From 22f473b22bc2b2aae2b53a180b78c2e891ab956e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sun, 7 Jan 2007 19:04:40 +0000 Subject: r20598: add comments and make clear that the void *data element for extended operations needs to be NULL or a valid talloc pointer as talloc_get_type() will be called on it. metze (This used to be commit 5731617ea9103eaaef2c5591aab89d59ded35fd8) --- source4/lib/ldb/include/ldb.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7b37b50468..62afbfb609 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -676,7 +676,7 @@ enum ldb_state { struct ldb_extended { const char *oid; - void *data; + void *data; /* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ }; struct ldb_result { @@ -1118,7 +1118,8 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct \param ldb the context associated with the database (from ldb_init()) \param mem_ctx a talloc emmory context (used as parent of ret_req) \param oid the OID of the extended operation. - \param data void pointer a the extended operation specific parameters + \param data a void pointer a the extended operation specific parameters, + it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it \param controls an array of controls \param context the callback function context \param the callback function to handle the async replies @@ -1129,7 +1130,7 @@ int ldb_build_extended_req(struct ldb_request **ret_req, struct ldb_context *ldb, void *mem_ctx, const char *oid, - void *data, + void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ struct ldb_control **controls, void *context, ldb_request_callback_t callback); @@ -1141,7 +1142,8 @@ int ldb_build_extended_req(struct ldb_request **ret_req, \param ldb the context associated with the database (from ldb_init()) \param oid the OID of the extended operation. - \param data void pointer a the extended operation specific parameters + \param data a void pointer a the extended operation specific parameters, + it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it \param res the result of the extended operation \return result code (LDB_SUCCESS if the extended operation returned fine, @@ -1149,7 +1151,7 @@ int ldb_build_extended_req(struct ldb_request **ret_req, */ int ldb_extended(struct ldb_context *ldb, const char *oid, - void *data, + void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ struct ldb_result **res); /** -- cgit From fb9dabe39e18ff9cfd3abb4160ba19971ca33795 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 17 Jan 2007 16:10:33 +0000 Subject: r20852: add a function to add a ldb control to a ldb_request metze (This used to be commit f0bf86ed66f7f9995df35db55f2f3875e7dbacbe) --- source4/lib/ldb/include/ldb.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 62afbfb609..9cc5904348 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -989,6 +989,18 @@ int ldb_build_rename_req(struct ldb_request **ret_req, void *context, ldb_request_callback_t callback); +/** + Add a ldb_control to a ldb_request + + \param req the request struct where to add the control + \param oid the object identifier of the control as string + \param ciritical whether the control should be critical or not + \param data a talloc pointer to the control specific data + + \return result code (LDB_SUCCESS on success, or a failure code) +*/ +int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data); + /** Search the database -- cgit From 7dc7156bd76425df129102a42dd29a85fd8c7ebc Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Feb 2007 01:54:40 +0000 Subject: r21496: A number of ldb control and LDAP changes, surrounding the 'phantom_root' flag in the search_options control - Add in support for LDB controls to the js layer - Test the behaviour - Implement support for the 'phantom_root' flag in the partitions module - Make the LDAP server set the 'phantom_root' flag in the search_options control - This replaces the global_catalog flag passed down as an opaque pointer - Rework the string-format control parsing function into ldb_parse_control_strings(), returning errors by ldb_errorstring() method, rather than with printf to stderr - Rework some of the ldb_control handling logic Andrew Bartlett (This used to be commit 2b3df7f38d7790358dbb4de1b8609bf794a351fb) --- source4/lib/ldb/include/ldb.h | 60 ++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 21 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 9cc5904348..3e09cf1506 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -535,18 +535,10 @@ typedef int (*ldb_qsort_cmp_fn_t) (void *v1, void *v2, void *opaque); #define LDB_EXTENDED_START_TLS_OID "1.3.6.1.4.1.1466.20037" /** - OID for LDAP Extended Operation START_TLS. - - This Extended operation is used to start a new TLS - channel on top of a clear text channel. */ #define LDB_EXTENDED_DYNAMIC_OID "1.3.6.1.4.1.1466.101.119.1" /** - OID for LDAP Extended Operation START_TLS. - - This Extended operation is used to start a new TLS - channel on top of a clear text channel. */ #define LDB_EXTENDED_FAST_BIND_OID "1.2.840.113556.1.4.1781" @@ -560,20 +552,24 @@ struct ldb_sd_flags_control { unsigned secinfo_flags; }; +/* + * DOMAIN_SCOPE 0x00000001 + * this limits the search to one partition, + * and no referrals will be returned. + * (Note this doesn't limit the entries by there + * objectSid belonging to a domain! Builtin and Foreign Sids + * are still returned) + * + * PHANTOM_ROOT 0x00000002 + * this search on the whole tree on a domain controller + * over multiple partitions without referrals. + * (This is the default behavior on the Global Catalog Port) + */ + +#define LDB_SEARCH_OPTION_DOMAIN_SCOPE 0x00000001 +#define LDB_SEARCH_OPTION_PHANTOM_ROOT 0x00000002 + struct ldb_search_options_control { - /* - * DOMAIN_SCOPE 0x00000001 - * this limits the search to one partition, - * and no referrals will be returned. - * (Note this doesn't limit the entries by there - * objectSid belonging to a domain! Builtin and Foreign Sids - * are still returned) - * - * PHANTOM_ROOT 0x00000002 - * this search on the whole tree on a domain controller - * over multiple partitions without referrals. - * (This is the default behavior on the Global Catalog Port) - */ unsigned search_options; }; @@ -1001,6 +997,15 @@ int ldb_build_rename_req(struct ldb_request **ret_req, */ int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data); +/** + check if a control with the specified "oid" exist and return it + \param req the request struct where to add the control + \param oid the object identifier of the control as string + + \return the control, NULL if not found +*/ +struct ldb_control *ldb_request_get_control(struct ldb_request *req, const char *oid); + /** Search the database @@ -1676,4 +1681,17 @@ time_t ldb_string_utc_to_time(const char *s); void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque, ldb_qsort_cmp_fn_t cmp); + + +/** + Convert an array of string represention of a control into an array of ldb_control structures + + \param ldb LDB context + \param mem_ctx TALLOC context to return result on, and to allocate error_string on + \param control_strings Array of string-formatted controls + + \return array of ldb_control elements +*/ +struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, void *mem_ctx, const char **control_strings); + #endif -- cgit From d89e6c774bbf6738183459c52acbd3220482d58a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 6 Jun 2007 12:44:04 +0000 Subject: r23364: add LDB_FLG_NOMMAP flag (This used to be commit 0c3442c68b01b6804f3fd966fc1fe9097eb863aa) --- source4/lib/ldb/include/ldb.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 3e09cf1506..10b9b4c8ce 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -232,6 +232,11 @@ struct ldb_utf8_fns { */ #define LDB_FLG_RECONNECT 4 +/** + Flag to tell backends not to use mmap +*/ +#define LDB_FLG_NOMMAP 8 + /* structures for ldb_parse_tree handling code */ -- cgit From b8d69a7ea2505b706ff7c74d7c97bc89d82dfa07 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:46:15 +0000 Subject: r23795: more v2->v3 conversion (This used to be commit 84b468b2f8f2dffda89593f816e8bc6a8b6d42ac) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 10b9b4c8ce..295fb3af4c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -12,7 +12,7 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. + version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- cgit From 6c973f4e8ccbcb6c9275f8a54e26abb19df7e15a Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 03:42:26 +0000 Subject: r23798: updated old Temple Place FSF addresses to new URL (This used to be commit 40c0919aaa9c1b14bbaebb95ecce53eb0380fdbb) --- source4/lib/ldb/include/ldb.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 295fb3af4c..8f693309c5 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -20,8 +20,7 @@ Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . */ /* -- cgit From ed2a1c718ae4fb56fdfe73da6f63ddb7fb15d9fd Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 11 Sep 2007 15:42:19 +0000 Subject: r25081: Add modules_dir member to ldb_context that is used rather than a global modulesdir setting. Samba always sets this to lp_modulesdir()/ldb (This used to be commit e672380d2156cf0421108a9c34f04f096c2afeed) --- source4/lib/ldb/include/ldb.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 8f693309c5..e4c43b45e7 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -779,6 +779,7 @@ int ldb_wait(struct ldb_handle *handle, enum ldb_wait_type type); int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeout); int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms); +void ldb_set_modules_dir(struct ldb_context *ldb, const char *path); /** Initialise ldbs' global information @@ -876,7 +877,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param base the Base Distinguished Name for the query (use ldb_dn_new() for an empty one) \param scope the search scope for the query \param expression the search expression to use for this query @@ -904,7 +905,7 @@ int ldb_build_search_req(struct ldb_request **ret_req, \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param message contains the entry to be added \param controls an array of controls \param context the callback function context @@ -926,7 +927,7 @@ int ldb_build_add_req(struct ldb_request **ret_req, \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param message contains the entry to be modified \param controls an array of controls \param context the callback function context @@ -948,7 +949,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req, \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param dn the DN to be deleted \param controls an array of controls \param context the callback function context @@ -970,7 +971,7 @@ int ldb_build_del_req(struct ldb_request **ret_req, \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param olddn the old DN \param newdn the new DN \param controls an array of controls @@ -1137,7 +1138,7 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct \param ret_req the request structure is returned here (talloced on mem_ctx) \param ldb the context associated with the database (from ldb_init()) - \param mem_ctx a talloc emmory context (used as parent of ret_req) + \param mem_ctx a talloc memory context (used as parent of ret_req) \param oid the OID of the extended operation. \param data a void pointer a the extended operation specific parameters, it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it -- cgit From 68a9ab6b012b69a97f2ffa13d2db0f822e51694d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 5 Oct 2007 23:02:07 +0000 Subject: r25540: Remove prototypes for already removed functions. (This used to be commit 042dff55b4cd42b9bedbf574168cc52de3d1dda4) --- source4/lib/ldb/include/ldb.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e4c43b45e7..41d23b5d10 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1044,15 +1044,6 @@ int ldb_search_exp_fmt(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, enum ldb_scope scope, const char * const *attrs, const char *exp_fmt, ...) PRINTF_ATTRIBUTE(7,8); -/* - like ldb_search() but takes a parse tree -*/ -int ldb_search_bytree(struct ldb_context *ldb, - struct ldb_dn *base, - enum ldb_scope scope, - struct ldb_parse_tree *tree, - const char * const *attrs, struct ldb_result **res); - /** Add a record to the database. @@ -1419,9 +1410,6 @@ bool ldb_dn_check_special(struct ldb_dn *dn, const char *check); bool ldb_dn_is_null(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); - /** Compare two attributes -- cgit From b09047b78e981af8ade6a72d426bfcb0e742995b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 13 Oct 2007 20:24:37 +0200 Subject: r25624: Remove ipv4_addr hack. Only causes 4 extra includes of system/network.h because we stripped down includes. (This used to be commit 262c1c23a61f1f4fae13e0a61179fe98b682cecf) --- source4/lib/ldb/include/ldb.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 41d23b5d10..301db4dadc 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -735,12 +735,14 @@ struct ldb_register_partition { struct ldb_dn *dn; }; +enum ldb_sequence_type { + LDB_SEQ_HIGHEST_SEQ, + LDB_SEQ_HIGHEST_TIMESTAMP, + LDB_SEQ_NEXT +}; + struct ldb_sequence_number { - enum ldb_sequence_type { - LDB_SEQ_HIGHEST_SEQ, - LDB_SEQ_HIGHEST_TIMESTAMP, - LDB_SEQ_NEXT - } type; + enum ldb_sequence_type type; uint64_t seq_num; uint32_t flags; }; -- cgit From 6b62805ce7db000420752f56b0544d2aecc51833 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 20 Nov 2007 15:50:08 +0100 Subject: r26066: Use TALLOC_CTX consistently for talloc contexts rather than void \* (it was already being used for some). (This used to be commit d8b175016570d628bb075008149d32a0d538ce95) --- source4/lib/ldb/include/ldb.h | 72 +++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 301db4dadc..59f5f67fd2 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -203,7 +203,7 @@ struct ldb_debug_ops { */ struct ldb_utf8_fns { void *context; - char *(*casefold)(void *context, void *mem_ctx, const char *s); + char *(*casefold)(void *context, TALLOC_CTX *mem_ctx, const char *s); }; /** @@ -280,8 +280,8 @@ struct ldb_parse_tree { } u; }; -struct ldb_parse_tree *ldb_parse_tree(void *mem_ctx, const char *s); -char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); +struct ldb_parse_tree *ldb_parse_tree(TALLOC_CTX *mem_ctx, const char *s); +char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, struct ldb_parse_tree *tree); /** Encode a binary blob @@ -297,7 +297,7 @@ char *ldb_filter_from_tree(void *mem_ctx, struct ldb_parse_tree *tree); \sa RFC 2252. */ -char *ldb_binary_encode(void *ctx, struct ldb_val val); +char *ldb_binary_encode(TALLOC_CTX *mem_ctx, struct ldb_val val); /** Encode a string @@ -313,13 +313,13 @@ char *ldb_binary_encode(void *ctx, struct ldb_val val); \sa RFC 2252. */ -char *ldb_binary_encode_string(void *mem_ctx, const char *string); +char *ldb_binary_encode_string(TALLOC_CTX *mem_ctx, const char *string); /* functions for controlling attribute handling */ -typedef int (*ldb_attr_handler_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, struct ldb_val *); -typedef int (*ldb_attr_comparison_t)(struct ldb_context *, void *mem_ctx, const struct ldb_val *, const struct ldb_val *); +typedef int (*ldb_attr_handler_t)(struct ldb_context *, TALLOC_CTX *mem_ctx, const struct ldb_val *, struct ldb_val *); +typedef int (*ldb_attr_comparison_t)(struct ldb_context *, TALLOC_CTX *mem_ctx, const struct ldb_val *, const struct ldb_val *); /* attribute handler structure @@ -803,7 +803,7 @@ int ldb_global_init(void); \return pointer to ldb_context that should be free'd (using talloc_free()) at the end of the program. */ -struct ldb_context *ldb_init(void *mem_ctx); +struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx); /** Connect to a database. @@ -893,7 +893,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l int ldb_build_search_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, struct ldb_dn *base, enum ldb_scope scope, const char *expression, @@ -918,7 +918,7 @@ int ldb_build_search_req(struct ldb_request **ret_req, int ldb_build_add_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, const struct ldb_message *message, struct ldb_control **controls, void *context, @@ -940,7 +940,7 @@ int ldb_build_add_req(struct ldb_request **ret_req, int ldb_build_mod_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, const struct ldb_message *message, struct ldb_control **controls, void *context, @@ -962,7 +962,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req, int ldb_build_del_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, struct ldb_dn *dn, struct ldb_control **controls, void *context, @@ -985,7 +985,7 @@ int ldb_build_del_req(struct ldb_request **ret_req, int ldb_build_rename_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, struct ldb_dn *olddn, struct ldb_dn *newdn, struct ldb_control **controls, @@ -1143,7 +1143,7 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct */ int ldb_build_extended_req(struct ldb_request **ret_req, struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, const char *oid, void *data,/* NULL or a valid talloc pointer! talloc_get_type() will be used on it */ struct ldb_control **controls, @@ -1213,7 +1213,7 @@ void ldb_set_utf8_default(struct ldb_context *ldb); \note The default function is not yet UTF8 aware. Provide your own set of functions through ldb_set_utf8_fns() */ -char *ldb_casefold(struct ldb_context *ldb, void *mem_ctx, const char *s); +char *ldb_casefold(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *s); /** Check the attribute name is valid according to rfc2251 @@ -1357,7 +1357,7 @@ int ldb_ldif_write_file(struct ldb_context *ldb, FILE *f, const struct ldb_ldif \note The caller is responsible for freeing the result */ -char *ldb_base64_encode(void *mem_ctx, const char *buf, int len); +char *ldb_base64_encode(TALLOC_CTX *mem_ctx, const char *buf, int len); /** Base64 decode a buffer @@ -1375,15 +1375,15 @@ int ldb_base64_decode(char *s); /* The following definitions come from lib/ldb/common/ldb_dn.c */ -struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *dn); -struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...) PRINTF_ATTRIBUTE(3,4); +struct ldb_dn *ldb_dn_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *dn); +struct ldb_dn *ldb_dn_new_fmt(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...) PRINTF_ATTRIBUTE(3,4); bool ldb_dn_validate(struct ldb_dn *dn); -char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value); +char *ldb_dn_escape_value(TALLOC_CTX *mem_ctx, struct ldb_val value); const char *ldb_dn_get_linearized(struct ldb_dn *dn); const char *ldb_dn_get_casefold(struct ldb_dn *dn); -char *ldb_dn_alloc_linearized(void *mem_ctx, struct ldb_dn *dn); -char *ldb_dn_alloc_casefold(void *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_alloc_linearized(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_alloc_casefold(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn); int ldb_dn_compare(struct ldb_dn *edn0, struct ldb_dn *edn1); @@ -1395,10 +1395,10 @@ bool ldb_dn_add_child_fmt(struct ldb_dn *dn, const char *child_fmt, ...) PRINTF_ bool ldb_dn_remove_base_components(struct ldb_dn *dn, unsigned int num); bool ldb_dn_remove_child_components(struct ldb_dn *dn, unsigned int num); -struct ldb_dn *ldb_dn_copy(void *mem_ctx, struct ldb_dn *dn); -struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, struct ldb_dn *dn); -char *ldb_dn_canonical_string(void *mem_ctx, struct ldb_dn *dn); -char *ldb_dn_canonical_ex_string(void *mem_ctx, struct ldb_dn *dn); +struct ldb_dn *ldb_dn_copy(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); +struct ldb_dn *ldb_dn_get_parent(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_canonical_string(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); +char *ldb_dn_canonical_ex_string(TALLOC_CTX *mem_ctx, struct ldb_dn *dn); int ldb_dn_get_comp_num(struct ldb_dn *dn); const char *ldb_dn_get_component_name(struct ldb_dn *dn, unsigned int num); const struct ldb_val *ldb_dn_get_component_val(struct ldb_dn *dn, unsigned int num); @@ -1429,7 +1429,7 @@ bool ldb_dn_is_null(struct ldb_dn *dn); return 0 for match */ #define ldb_attr_cmp(a, b) strcasecmp(a, b) -char *ldb_attr_casefold(void *mem_ctx, const char *s); +char *ldb_attr_casefold(TALLOC_CTX *mem_ctx, const char *s); int ldb_attr_dn(const char *attr); /** @@ -1439,7 +1439,7 @@ int ldb_attr_dn(const char *attr); to get the top level context, however the ldb context (from ldb_init()) may be a better choice */ -struct ldb_message *ldb_msg_new(void *mem_ctx); +struct ldb_message *ldb_msg_new(TALLOC_CTX *mem_ctx); /** Find an element within an message @@ -1533,15 +1533,15 @@ const char *ldb_msg_find_attr_as_string(const struct ldb_message *msg, const char *default_value); struct ldb_dn *ldb_msg_find_attr_as_dn(struct ldb_context *ldb, - void *mem_ctx, + TALLOC_CTX *mem_ctx, const struct ldb_message *msg, const char *attr_name); void ldb_msg_sort_elements(struct ldb_message *msg); -struct ldb_message *ldb_msg_copy_shallow(void *mem_ctx, +struct ldb_message *ldb_msg_copy_shallow(TALLOC_CTX *mem_ctx, const struct ldb_message *msg); -struct ldb_message *ldb_msg_copy(void *mem_ctx, +struct ldb_message *ldb_msg_copy(TALLOC_CTX *mem_ctx, const struct ldb_message *msg); struct ldb_message *ldb_msg_canonicalize(struct ldb_context *ldb, @@ -1583,7 +1583,7 @@ int ldb_msg_sanity_check(struct ldb_context *ldb, \return the duplicated ldb_val structure. */ -struct ldb_val ldb_val_dup(void *mem_ctx, const struct ldb_val *v); +struct ldb_val ldb_val_dup(TALLOC_CTX *mem_ctx, const struct ldb_val *v); /** this allows the user to set a debug function for error reporting @@ -1609,8 +1609,8 @@ int ldb_set_debug_stderr(struct ldb_context *ldb); int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value); void *ldb_get_opaque(struct ldb_context *ldb, const char *name); -const char **ldb_attr_list_copy(void *mem_ctx, const char * const *attrs); -const char **ldb_attr_list_copy_add(void *mem_ctx, const char * const *attrs, const char *new_attr); +const char **ldb_attr_list_copy(TALLOC_CTX *mem_ctx, const char * const *attrs); +const char **ldb_attr_list_copy_add(TALLOC_CTX *mem_ctx, const char * const *attrs, const char *new_attr); int ldb_attr_in_list(const char * const *attrs, const char *attr); @@ -1634,7 +1634,7 @@ void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr); \return the formatted string, or NULL if the time structure could not be converted */ -char *ldb_timestring(void *mem_ctx, time_t t); +char *ldb_timestring(TALLOC_CTX *mem_ctx, time_t t); /** Convert a string to a time structure @@ -1660,7 +1660,7 @@ time_t ldb_string_to_time(const char *s); \return the formatted string, or NULL if the time structure could not be converted */ -char *ldb_timestring_utc(void *mem_ctx, time_t t); +char *ldb_timestring_utc(TALLOC_CTX *mem_ctx, time_t t); /** Convert a string to a time structure @@ -1687,6 +1687,6 @@ void ldb_qsort (void *const pbase, size_t total_elems, size_t size, void *opaque \return array of ldb_control elements */ -struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, void *mem_ctx, const char **control_strings); +struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char **control_strings); #endif -- cgit From 6ee987ffa14fb44ddfd2908ecc5931f3ee10e597 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 10 Dec 2007 10:29:32 +0100 Subject: r26371: Fix typo. (This used to be commit dcbacd9adb1ded14cbea3513f3db351e5b7bbe87) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 59f5f67fd2..e2ff8c6f98 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1217,7 +1217,7 @@ char *ldb_casefold(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *s); /** Check the attribute name is valid according to rfc2251 - \param s tthe string to check + \param s the string to check \return 1 if the name is ok */ -- cgit From 28a06a1b2592bc45f554c2179f4e0596725fd693 Mon Sep 17 00:00:00 2001 From: Kai Blin Date: Wed, 26 Dec 2007 00:10:34 +0100 Subject: ldb: Get rid of a warning. (This used to be commit 37ed9fbeee37a1d86d6f6841eac5c1a0a85c1fcc) --- source4/lib/ldb/include/ldb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index e2ff8c6f98..2e54920c17 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -705,7 +705,7 @@ struct ldb_handle { struct ldb_search { struct ldb_dn *base; enum ldb_scope scope; - const struct ldb_parse_tree *tree; + struct ldb_parse_tree *tree; const char * const *attrs; struct ldb_result *res; }; -- cgit From 85d53f7b603f7c15b007f8c3fdde1989f07a6eb2 Mon Sep 17 00:00:00 2001 From: Brad Hards Date: Sun, 2 Mar 2008 10:46:47 +0100 Subject: Some cleanups for the ldb doxygen docs. (This used to be commit 5972308add8b1078e190beab204c1ba4b3a25747) --- source4/lib/ldb/include/ldb.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2e54920c17..2e13a774b9 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -290,7 +290,7 @@ char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, struct ldb_parse_tree *tree); 2254 (Section 4). This function also escapes any non-printable characters. - \param ctx the memory context to allocate the return string in. + \param mem_ctx the memory context to allocate the return string in. \param val the (potentially) binary data to be encoded \return the encoded data as a null terminated string @@ -886,7 +886,7 @@ int ldb_search_default_callback(struct ldb_context *ldb, void *context, struct l \param attrs the search attributes for the query (pass NULL if none required) \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -911,7 +911,7 @@ int ldb_build_search_req(struct ldb_request **ret_req, \param message contains the entry to be added \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -933,7 +933,7 @@ int ldb_build_add_req(struct ldb_request **ret_req, \param message contains the entry to be modified \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -955,7 +955,7 @@ int ldb_build_mod_req(struct ldb_request **ret_req, \param dn the DN to be deleted \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -978,7 +978,7 @@ int ldb_build_del_req(struct ldb_request **ret_req, \param newdn the new DN \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -997,7 +997,7 @@ int ldb_build_rename_req(struct ldb_request **ret_req, \param req the request struct where to add the control \param oid the object identifier of the control as string - \param ciritical whether the control should be critical or not + \param critical whether the control should be critical or not \param data a talloc pointer to the control specific data \return result code (LDB_SUCCESS on success, or a failure code) @@ -1137,7 +1137,7 @@ int ldb_extended_default_callback(struct ldb_context *ldb, void *context, struct it needs to be NULL or a valid talloc pointer! talloc_get_type() will be used on it \param controls an array of controls \param context the callback function context - \param the callback function to handle the async replies + \param callback the callback function to handle the async replies \return result code (LDB_SUCCESS on success, or a failure code) */ @@ -1226,6 +1226,7 @@ int ldb_valid_attr_name(const char *s); /* ldif manipulation functions */ + /** Write an LDIF message @@ -1418,8 +1419,8 @@ bool ldb_dn_is_null(struct ldb_dn *dn); This function compares to attribute names. Note that this is a case-insensitive comparison. - \param attr1 the first attribute name to compare - \param attr2 the second attribute name to compare + \param a the first attribute name to compare + \param b the second attribute name to compare \return 0 if the attribute names are the same, or only differ in case; non-zero if there are any differences @@ -1562,6 +1563,7 @@ int ldb_msg_check_string_attribute(const struct ldb_message *msg, This function performs basic sanity / integrity checks on an ldb_message. + \param ldb context in which to perform the checks \param msg the message to check \return LDB_SUCCESS if the message is OK, or a non-zero error code -- cgit From 929adc9efa5cf985f0585214d30d18521aa1a821 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Sat, 14 Jun 2008 11:24:17 -0400 Subject: Make up the right dependencies now that ldb depends on libevents (This used to be commit 3b8eec7ca334528cad3cdcd5e3fc5ee555d8d0e0) --- source4/lib/ldb/include/ldb.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 2e13a774b9..c43d425585 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -782,6 +782,8 @@ int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeou int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms); void ldb_set_modules_dir(struct ldb_context *ldb, const char *path); +void ldb_set_event_context(struct ldb_context *ldb, struct event_context *ev); +struct event_context * ldb_get_event_context(struct ldb_context *ldb); /** Initialise ldbs' global information @@ -803,7 +805,7 @@ int ldb_global_init(void); \return pointer to ldb_context that should be free'd (using talloc_free()) at the end of the program. */ -struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx); +struct ldb_context *ldb_init(TALLOC_CTX *mem_ctx, struct event_context *ev_ctx); /** Connect to a database. -- cgit From 1cea7ebe2e193e48f396d280f1253f64a3a4498b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 27 Jun 2008 09:39:30 +0200 Subject: lib/ldb: add forward declaration for struct event_context metze (This used to be commit 9bbdc682a985f210874c008a0abc25645e7fbd50) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index c43d425585..0338ae1d93 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -782,6 +782,7 @@ int ldb_set_timeout(struct ldb_context *ldb, struct ldb_request *req, int timeou int ldb_set_timeout_from_prev_req(struct ldb_context *ldb, struct ldb_request *oldreq, struct ldb_request *newreq); void ldb_set_create_perms(struct ldb_context *ldb, unsigned int perms); void ldb_set_modules_dir(struct ldb_context *ldb, const char *path); +struct event_context; void ldb_set_event_context(struct ldb_context *ldb, struct event_context *ev); struct event_context * ldb_get_event_context(struct ldb_context *ldb); -- cgit From 7e1c62f8b64c9e42018bea33557af31fb7fa7414 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 20 Aug 2008 15:46:58 +1000 Subject: added a LDB_ATTR_FLAG_FIXED so the schema module can mark attributes as never to be removed. (This used to be commit 9dce558206a2ce70c69b9b6c5c3c9c58ee165b1d) --- source4/lib/ldb/include/ldb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 0338ae1d93..7ce6103422 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -358,9 +358,9 @@ const struct ldb_schema_attribute *ldb_schema_attribute_by_name(struct ldb_conte #define LDB_ATTR_FLAG_ALLOCATED (1<<1) /** - The attribute is constructed from other attributes + The attribute is supplied by the application and should not be removed */ -#define LDB_ATTR_FLAG_CONSTRUCTED (1<<1) +#define LDB_ATTR_FLAG_FIXED (1<<2) /** LDAP attribute syntax for a DN -- cgit From 4ad97a1d0593b3401a352407009a99ead23f21f2 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 21 Aug 2008 19:24:58 +1000 Subject: Don't walk past the end of ldb values. This is a partial fix towards bugs due to us walking past the end of what we think are strings in ldb. There is much more work to do in this area. Andrew Bartlett (This used to be commit 5805a9a8f35fd90fa4f718f73534817fa3bbdfd2) --- source4/lib/ldb/include/ldb.h | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 7ce6103422..5dbf99e5bf 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -1381,6 +1381,7 @@ int ldb_base64_decode(char *s); struct ldb_dn *ldb_dn_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *dn); struct ldb_dn *ldb_dn_new_fmt(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...) PRINTF_ATTRIBUTE(3,4); +struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx, struct ldb_context *ldb, const struct ldb_val *strdn); bool ldb_dn_validate(struct ldb_dn *dn); char *ldb_dn_escape_value(TALLOC_CTX *mem_ctx, struct ldb_val value); -- cgit From cc43037f19056ed24d7fffa54456d597c63ad105 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Aug 2008 17:36:56 +1000 Subject: fixed a problem with length limited ldap values The core ldb code for string matching assumed NULL terminated strings, whereas the anr module used data_blob_const() to effectively truncate a ldb_val by changing its length. The ldb code is supposed to be based around length limited blobs, not NULL terminated strings, so the correct fix was to change the string comparison functions to be length limited (This used to be commit 26c6aa5a80ffaf06fc33f30a6533f8f16ef538bc) --- source4/lib/ldb/include/ldb.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/lib/ldb/include/ldb.h') diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h index 5dbf99e5bf..937029f52c 100644 --- a/source4/lib/ldb/include/ldb.h +++ b/source4/lib/ldb/include/ldb.h @@ -203,7 +203,7 @@ struct ldb_debug_ops { */ struct ldb_utf8_fns { void *context; - char *(*casefold)(void *context, TALLOC_CTX *mem_ctx, const char *s); + char *(*casefold)(void *context, TALLOC_CTX *mem_ctx, const char *s, size_t n); }; /** @@ -1216,7 +1216,7 @@ void ldb_set_utf8_default(struct ldb_context *ldb); \note The default function is not yet UTF8 aware. Provide your own set of functions through ldb_set_utf8_fns() */ -char *ldb_casefold(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *s); +char *ldb_casefold(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *s, size_t n); /** Check the attribute name is valid according to rfc2251 @@ -1603,8 +1603,8 @@ int ldb_set_debug(struct ldb_context *ldb, this allows the user to set custom utf8 function for error reporting */ void ldb_set_utf8_fns(struct ldb_context *ldb, - void *context, - char *(*casefold)(void *, void *, const char *)); + void *context, + char *(*casefold)(void *, void *, const char *, size_t n)); /** this sets up debug to print messages on stderr -- cgit