summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/config.mk11
-rw-r--r--source4/lib/ldb/include/ldb.h22
-rw-r--r--source4/lib/ldb/ldb.i84
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c4
-rw-r--r--source4/lib/ldb/ldb_wrap.c158
-rw-r--r--source4/lib/ldb/modules/rdn_name.c3
-rw-r--r--source4/lib/ldb/tools/config.mk18
7 files changed, 116 insertions, 184 deletions
diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk
index d6980f341a..81fd1e9b95 100644
--- a/source4/lib/ldb/config.mk
+++ b/source4/lib/ldb/config.mk
@@ -147,12 +147,14 @@ PUBLIC_DEPENDENCIES = \
LIBTALLOC
PRIVATE_DEPENDENCIES = \
SOCKET_WRAPPER
-MANPAGE = man/ldb.3
-PUBLIC_HEADERS = include/ldb.h include/ldb_errors.h
#
# End SUBSYSTEM ldb
################################################
+PUBLIC_HEADERS += $(ldbdir)/include/ldb.h $(ldbdir)/include/ldb_errors.h
+
+MANPAGES += $(ldbdir)/man/ldb.3
+
################################################
# Start BINARY ldbtest
[BINARY::ldbtest]
@@ -167,7 +169,6 @@ PRIVATE_DEPENDENCIES = \
# Start BINARY oLschema2ldif
[BINARY::oLschema2ldif]
INSTALLDIR = BINDIR
-MANPAGE = man/oLschema2ldif.1
OBJ_FILES= \
tools/convert.o \
tools/oLschema2ldif.o
@@ -176,11 +177,12 @@ PRIVATE_DEPENDENCIES = \
# End BINARY oLschema2ldif
################################################
+MANPAGES += $(ldbdir)/man/oLschema2ldif.1
+
################################################
# Start BINARY ad2oLschema
[BINARY::ad2oLschema]
INSTALLDIR = BINDIR
-MANPAGE = man/ad2oLschema.1
OBJ_FILES= \
tools/convert.o \
tools/ad2oLschema.o
@@ -189,6 +191,7 @@ PRIVATE_DEPENDENCIES = \
# End BINARY ad2oLschema
################################################
+MANPAGES += $(ldbdir)/man/ad2oLschema.1
mkinclude tools/config.mk
mkinclude ldb_ildap/config.mk
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
diff --git a/source4/lib/ldb/ldb.i b/source4/lib/ldb/ldb.i
index 336100c4f0..da4c52f778 100644
--- a/source4/lib/ldb/ldb.i
+++ b/source4/lib/ldb/ldb.i
@@ -547,6 +547,43 @@ PyObject *PyExc_LdbError;
talloc_free($1);
};
+%typemap(in,numinputs=1) ldb_msg *add_msg {
+ int dict_pos, msg_pos;
+ PyObject *key, *value;
+ ldb_msg_element *msgel;
+
+ if (PyDict_Check($input)) {
+ $1 = ldb_msg_new(NULL);
+ $1->elements = talloc_zero_array($1, struct ldb_message_element, PyDict_Size($input));
+ msg_pos = dict_pos = 0;
+ while (PyDict_Next($input, &dict_pos, &key, &value)) {
+ if (!strcmp(PyString_AsString(key), "dn")) {
+ /* using argp0 (magic SWIG value) here is a hack */
+ if (ldb_dn_from_pyobject($1, value, argp1, &$1->dn) != 0) {
+ SWIG_exception(SWIG_TypeError, "unable to import dn object");
+ }
+ } else {
+ msgel = ldb_msg_element_from_pyobject($1->elements, value, 0, PyString_AsString(key));
+ if (msgel == NULL) {
+ SWIG_exception(SWIG_TypeError, "unable to import element");
+ }
+ memcpy(&$1->elements[msg_pos], msgel, sizeof(*msgel));
+ msg_pos++;
+ }
+ }
+
+ if ($1->dn == NULL) {
+ SWIG_exception(SWIG_TypeError, "no dn set");
+ }
+
+ $1->num_elements = msg_pos;
+ } else {
+ if (SWIG_ConvertPtr($input, (void **)&$1, SWIGTYPE_p_ldb_message, 0) != 0) {
+ SWIG_exception(SWIG_TypeError, "unable to convert ldb message");
+ }
+ }
+}
+
/* Top-level ldb operations */
typedef struct ldb_context {
%extend {
@@ -604,53 +641,6 @@ typedef struct ldb_context {
struct ldb_control **parse_control_strings(TALLOC_CTX *mem_ctx,
const char * const*control_strings);
ldb_error add(ldb_msg *add_msg);
- ldb_error add(PyObject *py_msg)
- {
- ldb_error ret;
- int dict_pos, msg_pos;
- PyObject *key, *value;
- ldb_msg_element *msgel;
- ldb_msg *msg = NULL;
-
- if (PyDict_Check(py_msg)) {
- msg = ldb_msg_new(NULL);
- msg->elements = talloc_zero_array(msg, struct ldb_message_element, PyDict_Size(py_msg));
- msg_pos = dict_pos = 0;
- while (PyDict_Next(py_msg, &dict_pos, &key, &value)) {
- if (!strcmp(PyString_AsString(key), "dn")) {
- if (ldb_dn_from_pyobject(msg, value, $self, &msg->dn) != 0) {
- return LDB_ERR_OTHER;
- }
- } else {
- msgel = ldb_msg_element_from_pyobject(msg->elements, value, 0, PyString_AsString(key));
- if (msgel == NULL) {
- SWIG_exception(SWIG_TypeError, "unable to import element");
- return LDB_ERR_OTHER;
- }
- memcpy(&msg->elements[msg_pos], msgel, sizeof(*msgel));
- msg_pos++;
- }
- }
-
- if (msg->dn == NULL) {
- SWIG_exception(SWIG_TypeError, "no dn set");
- return LDB_ERR_OTHER;
- }
-
- msg->num_elements = msg_pos;
- } else {
- if (SWIG_ConvertPtr(py_msg, (void **)&msg, SWIGTYPE_p_ldb_message, 0) != 0)
- return LDB_ERR_OTHER;
- }
-
- ret = ldb_add($self, msg);
-
- talloc_free(msg);
- return ret;
-
- fail:
- return LDB_ERR_OTHER;
- }
ldb_error modify(ldb_msg *message);
ldb_dn *get_config_basedn();
ldb_dn *get_root_basedn();
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index 995b584f51..79958a86eb 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -816,8 +816,8 @@ _PUBLIC_ const struct ldb_backend_ops ldb_ldap_backend_ops = {
.connect_fn = ildb_connect
};
-_PUBLIC_ const struct ldb_backend_ops ldb_ildap_backend_ops = {
- .name = "ildap",
+_PUBLIC_ const struct ldb_backend_ops ldb_ldapi_backend_ops = {
+ .name = "ldapi",
.connect_fn = ildb_connect
};
diff --git a/source4/lib/ldb/ldb_wrap.c b/source4/lib/ldb/ldb_wrap.c
index 51022e5930..7886778b3a 100644
--- a/source4/lib/ldb/ldb_wrap.c
+++ b/source4/lib/ldb/ldb_wrap.c
@@ -3113,52 +3113,6 @@ SWIGINTERN ldb_error ldb_search_ex(ldb *self,TALLOC_CTX *mem_ctx,ldb_dn *base,en
*OUT = res;
return ret;
}
-SWIGINTERN ldb_error ldb_add__SWIG_1(ldb *self,PyObject *py_msg){
- ldb_error ret;
- int dict_pos, msg_pos;
- PyObject *key, *value;
- ldb_msg_element *msgel;
- ldb_msg *msg = NULL;
-
- if (PyDict_Check(py_msg)) {
- msg = ldb_msg_new(NULL);
- msg->elements = talloc_zero_array(msg, struct ldb_message_element, PyDict_Size(py_msg));
- msg_pos = dict_pos = 0;
- while (PyDict_Next(py_msg, &dict_pos, &key, &value)) {
- if (!strcmp(PyString_AsString(key), "dn")) {
- if (ldb_dn_from_pyobject(msg, value, self, &msg->dn) != 0) {
- return 80;
- }
- } else {
- msgel = ldb_msg_element_from_pyobject(msg->elements, value, 0, PyString_AsString(key));
- if (msgel == NULL) {
- SWIG_exception(SWIG_TypeError, "unable to import element");
- return 80;
- }
- memcpy(&msg->elements[msg_pos], msgel, sizeof(*msgel));
- msg_pos++;
- }
- }
-
- if (msg->dn == NULL) {
- SWIG_exception(SWIG_TypeError, "no dn set");
- return 80;
- }
-
- msg->num_elements = msg_pos;
- } else {
- if (SWIG_ConvertPtr(py_msg, (void **)&msg, SWIGTYPE_p_ldb_message, 0) != 0)
- return 80;
- }
-
- ret = ldb_add(self, msg);
-
- talloc_free(msg);
- return ret;
-
- fail:
- return 80;
- }
SWIGINTERN PyObject *ldb_schema_format_value(ldb *self,char const *element_name,PyObject *val){
const struct ldb_schema_attribute *a;
struct ldb_val old_val;
@@ -4733,27 +4687,61 @@ fail:
}
-SWIGINTERN PyObject *_wrap_Ldb_add__SWIG_0(PyObject *SWIGUNUSEDPARM(self), int nobjs, PyObject **swig_obj) {
+SWIGINTERN PyObject *_wrap_Ldb_add(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb *arg1 = (ldb *) 0 ;
ldb_msg *arg2 = (ldb_msg *) 0 ;
ldb_error result;
void *argp1 = 0 ;
int res1 = 0 ;
- void *argp2 = 0 ;
- int res2 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "add_msg", NULL
+ };
- if ((nobjs < 2) || (nobjs > 2)) SWIG_fail;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 );
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"OO:Ldb_add",kwnames,&obj0,&obj1)) SWIG_fail;
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_ldb_context, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_add" "', argument " "1"" of type '" "ldb *""'");
}
arg1 = (ldb *)(argp1);
- res2 = SWIG_ConvertPtr(swig_obj[1], &argp2,SWIGTYPE_p_ldb_message, 0 | 0 );
- if (!SWIG_IsOK(res2)) {
- SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Ldb_add" "', argument " "2"" of type '" "ldb_msg *""'");
+ {
+ int dict_pos, msg_pos;
+ PyObject *key, *value;
+ ldb_msg_element *msgel;
+
+ if (PyDict_Check(obj1)) {
+ arg2 = ldb_msg_new(NULL);
+ arg2->elements = talloc_zero_array(arg2, struct ldb_message_element, PyDict_Size(obj1));
+ msg_pos = dict_pos = 0;
+ while (PyDict_Next(obj1, &dict_pos, &key, &value)) {
+ if (!strcmp(PyString_AsString(key), "dn")) {
+ /* using argp0 (magic SWIG value) here is a hack */
+ if (ldb_dn_from_pyobject(arg2, value, argp1, &arg2->dn) != 0) {
+ SWIG_exception(SWIG_TypeError, "unable to import dn object");
+ }
+ } else {
+ msgel = ldb_msg_element_from_pyobject(arg2->elements, value, 0, PyString_AsString(key));
+ if (msgel == NULL) {
+ SWIG_exception(SWIG_TypeError, "unable to import element");
+ }
+ memcpy(&arg2->elements[msg_pos], msgel, sizeof(*msgel));
+ msg_pos++;
+ }
+ }
+
+ if (arg2->dn == NULL) {
+ SWIG_exception(SWIG_TypeError, "no dn set");
+ }
+
+ arg2->num_elements = msg_pos;
+ } else {
+ if (SWIG_ConvertPtr(obj1, (void **)&arg2, SWIGTYPE_p_ldb_message, 0) != 0) {
+ SWIG_exception(SWIG_TypeError, "unable to convert ldb message");
+ }
+ }
}
- arg2 = (ldb_msg *)(argp2);
if (arg1 == NULL)
SWIG_exception(SWIG_ValueError,
"ldb context must be non-NULL");
@@ -4772,64 +4760,6 @@ fail:
}
-SWIGINTERN PyObject *_wrap_Ldb_add__SWIG_1(PyObject *SWIGUNUSEDPARM(self), int nobjs, PyObject **swig_obj) {
- PyObject *resultobj = 0;
- ldb *arg1 = (ldb *) 0 ;
- PyObject *arg2 = (PyObject *) 0 ;
- ldb_error result;
- void *argp1 = 0 ;
- int res1 = 0 ;
-
- if ((nobjs < 2) || (nobjs > 2)) SWIG_fail;
- res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_ldb_context, 0 | 0 );
- if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Ldb_add" "', argument " "1"" of type '" "ldb *""'");
- }
- arg1 = (ldb *)(argp1);
- arg2 = swig_obj[1];
- if (arg1 == NULL)
- SWIG_exception(SWIG_ValueError,
- "ldb context must be non-NULL");
- result = ldb_add__SWIG_1(arg1,arg2);
- if (result != 0) {
- PyErr_SetObject(PyExc_LdbError, Py_BuildValue((char *)"(i,s)", result, ldb_strerror(result)));
- SWIG_fail;
- }
- resultobj = Py_None;
- return resultobj;
-fail:
- return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_Ldb_add(PyObject *self, PyObject *args) {
- int argc;
- PyObject *argv[3];
-
- if (!(argc = SWIG_Python_UnpackTuple(args,"Ldb_add",0,2,argv))) SWIG_fail;
- --argc;
- if (argc == 2) {
- int _v = 0;
- {
- void *vptr = 0;
- int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_ldb_message, 0);
- _v = SWIG_CheckState(res);
- }
- if (!_v) goto check_1;
- return _wrap_Ldb_add__SWIG_0(self, argc, argv);
- }
-check_1:
-
- if (argc == 2) {
- return _wrap_Ldb_add__SWIG_1(self, argc, argv);
- }
-
-fail:
- SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'Ldb_add'.\n Possible C/C++ prototypes are:\n"" add(ldb *,ldb_msg *)\n"" add(ldb *,PyObject *)\n");
- return NULL;
-}
-
-
SWIGINTERN PyObject *_wrap_Ldb_modify(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
ldb *arg1 = (ldb *) 0 ;
@@ -5729,7 +5659,7 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"Ldb_delete", (PyCFunction) _wrap_Ldb_delete, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_rename", (PyCFunction) _wrap_Ldb_rename, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_parse_control_strings", (PyCFunction) _wrap_Ldb_parse_control_strings, METH_VARARGS | METH_KEYWORDS, NULL},
- { (char *)"Ldb_add", _wrap_Ldb_add, METH_VARARGS, NULL},
+ { (char *)"Ldb_add", (PyCFunction) _wrap_Ldb_add, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_modify", (PyCFunction) _wrap_Ldb_modify, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"Ldb_get_config_basedn", (PyCFunction)_wrap_Ldb_get_config_basedn, METH_O, NULL},
{ (char *)"Ldb_get_root_basedn", (PyCFunction)_wrap_Ldb_get_root_basedn, METH_O, NULL},
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index c4de8e8da8..65c044c0f4 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -119,7 +119,8 @@ static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
"RDN mismatch on %s: %s (%s)",
ldb_dn_get_linearized(msg->dn), rdn_name, rdn_val.data);
talloc_free(down_req);
- return LDB_ERR_OPERATIONS_ERROR;
+ /* Match AD's error here */
+ return LDB_ERR_INVALID_DN_SYNTAX;
}
}
diff --git a/source4/lib/ldb/tools/config.mk b/source4/lib/ldb/tools/config.mk
index bf6c5f963c..02ad84ae25 100644
--- a/source4/lib/ldb/tools/config.mk
+++ b/source4/lib/ldb/tools/config.mk
@@ -17,10 +17,11 @@ OBJ_FILES = \
ldbadd.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE LIBCLI_RESOLVE
-MANPAGE = ../man/ldbadd.1
# End BINARY ldbadd
################################################
+MANPAGES += $(ldbdir)/man/ldbadd.1
+
################################################
# Start BINARY ldbdel
[BINARY::ldbdel]
@@ -29,10 +30,11 @@ OBJ_FILES= \
ldbdel.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
-MANPAGE = ../man/ldbdel.1
# End BINARY ldbdel
################################################
+MANPAGES += $(ldbdir)/man/ldbdel.1
+
################################################
# Start BINARY ldbmodify
[BINARY::ldbmodify]
@@ -41,10 +43,11 @@ OBJ_FILES= \
ldbmodify.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
-MANPAGE = ../man/ldbmodify.1
# End BINARY ldbmodify
################################################
+MANPAGES += $(ldbdir)/man/ldbmodify.1
+
################################################
# Start BINARY ldbsearch
[BINARY::ldbsearch]
@@ -53,10 +56,11 @@ OBJ_FILES= \
ldbsearch.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
-MANPAGE = ../man/ldbsearch.1
# End BINARY ldbsearch
################################################
+MANPAGES += $(ldbdir)/man/ldbsearch.1
+
################################################
# Start BINARY ldbedit
[BINARY::ldbedit]
@@ -65,10 +69,11 @@ OBJ_FILES= \
ldbedit.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
-MANPAGE = ../man/ldbedit.1
# End BINARY ldbedit
################################################
+MANPAGES += $(ldbdir)/man/ldbedit.1
+
################################################
# Start BINARY ldbrename
[BINARY::ldbrename]
@@ -77,8 +82,9 @@ OBJ_FILES= \
ldbrename.o
PRIVATE_DEPENDENCIES = \
LIBLDB_CMDLINE
-MANPAGE = ../man/ldbrename.1
# End BINARY ldbrename
################################################
+MANPAGES += $(ldbdir)/man/ldbrename.1
+