summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-11-25 15:43:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:28:32 -0500
commitc05c41d3521e8782be01b0413f3551d10487a1ac (patch)
tree9f3e6fefd55fb8f95524480c22d8ab738c5a9791 /source4/lib/ldb
parent5b258c3b9dda634af721802916880bccffab45a2 (diff)
downloadsamba-c05c41d3521e8782be01b0413f3551d10487a1ac.tar.gz
samba-c05c41d3521e8782be01b0413f3551d10487a1ac.tar.bz2
samba-c05c41d3521e8782be01b0413f3551d10487a1ac.zip
r19888: make it possible to use default attrib handlers from extensions
list more DN attributes as part of samba attribute handlers (nCName moved here) (This used to be commit 627ed8b5165c9a1cc0e2c67329b364f9cd8a1726)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/common/attrib_handlers.c21
-rw-r--r--source4/lib/ldb/include/ldb_handlers.h68
-rw-r--r--source4/lib/ldb/samba/ldif_handlers.c115
3 files changed, 193 insertions, 11 deletions
diff --git a/source4/lib/ldb/common/attrib_handlers.c b/source4/lib/ldb/common/attrib_handlers.c
index c50f7ed7b1..f563865c03 100644
--- a/source4/lib/ldb/common/attrib_handlers.c
+++ b/source4/lib/ldb/common/attrib_handlers.c
@@ -29,6 +29,7 @@
#include "includes.h"
#include "ldb/include/includes.h"
#include "system/locale.h"
+#include "ldb/include/ldb_handlers.h"
/*
default handler that just copies a ldb_val.
@@ -51,7 +52,7 @@ int ldb_handler_copy(struct ldb_context *ldb, void *mem_ctx,
We exploit the fact that utf8 never uses the space octet except for
the space itself
*/
-static int ldb_handler_fold(struct ldb_context *ldb, void *mem_ctx,
+int ldb_handler_fold(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
char *s, *t;
@@ -105,7 +106,7 @@ static int ldb_handler_fold(struct ldb_context *ldb, void *mem_ctx,
canonicalise a ldap Integer
rfc2252 specifies it should be in decimal form
*/
-static int ldb_canonicalise_Integer(struct ldb_context *ldb, void *mem_ctx,
+int ldb_canonicalise_Integer(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
char *end;
@@ -124,7 +125,7 @@ static int ldb_canonicalise_Integer(struct ldb_context *ldb, void *mem_ctx,
/*
compare two Integers
*/
-static int ldb_comparison_Integer(struct ldb_context *ldb, void *mem_ctx,
+int ldb_comparison_Integer(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2)
{
return strtoll((char *)v1->data, NULL, 0) - strtoll((char *)v2->data, NULL, 0);
@@ -150,7 +151,7 @@ int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx,
try to optimize for the ascii case,
but if we find out an utf8 codepoint revert to slower but correct function
*/
-static int ldb_comparison_fold(struct ldb_context *ldb, void *mem_ctx,
+int ldb_comparison_fold(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2)
{
const char *s1=(const char *)v1->data, *s2=(const char *)v2->data;
@@ -225,7 +226,7 @@ utf8str:
/*
canonicalise a attribute in DN format
*/
-static int ldb_canonicalise_dn(struct ldb_context *ldb, void *mem_ctx,
+int ldb_canonicalise_dn(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
struct ldb_dn *dn;
@@ -239,7 +240,7 @@ static int ldb_canonicalise_dn(struct ldb_context *ldb, void *mem_ctx,
return -1;
}
- out->data = (uint8_t *)ldb_dn_alloc_linearized(mem_ctx, dn);
+ out->data = (uint8_t *)ldb_dn_alloc_casefold(mem_ctx, dn);
if (out->data == NULL) {
goto done;
}
@@ -256,7 +257,7 @@ done:
/*
compare two dns
*/
-static int ldb_comparison_dn(struct ldb_context *ldb, void *mem_ctx,
+int ldb_comparison_dn(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2)
{
struct ldb_dn *dn1 = NULL, *dn2 = NULL;
@@ -281,7 +282,7 @@ static int ldb_comparison_dn(struct ldb_context *ldb, void *mem_ctx,
/*
compare two objectclasses, looking at subclasses
*/
-static int ldb_comparison_objectclass(struct ldb_context *ldb, void *mem_ctx,
+int ldb_comparison_objectclass(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2)
{
int ret, i;
@@ -308,7 +309,7 @@ static int ldb_comparison_objectclass(struct ldb_context *ldb, void *mem_ctx,
/*
compare two utc time values. 1 second resolution
*/
-static int ldb_comparison_utctime(struct ldb_context *ldb, void *mem_ctx,
+int ldb_comparison_utctime(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2)
{
time_t t1, t2;
@@ -320,7 +321,7 @@ static int ldb_comparison_utctime(struct ldb_context *ldb, void *mem_ctx,
/*
canonicalise a utc time
*/
-static int ldb_canonicalise_utctime(struct ldb_context *ldb, void *mem_ctx,
+int ldb_canonicalise_utctime(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *in, struct ldb_val *out)
{
time_t t = ldb_string_to_time((char *)in->data);
diff --git a/source4/lib/ldb/include/ldb_handlers.h b/source4/lib/ldb/include/ldb_handlers.h
new file mode 100644
index 0000000000..e340fe7367
--- /dev/null
+++ b/source4/lib/ldb/include/ldb_handlers.h
@@ -0,0 +1,68 @@
+/*
+ ldb database library
+
+ 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
+ ** 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 attribute handlers
+ *
+ * Author: Simo Sorce
+ */
+
+
+int ldb_handler_copy( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *in, struct ldb_val *out);
+
+int ldb_handler_fold( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *in, struct ldb_val *out);
+
+int ldb_canonicalise_Integer( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *in, struct ldb_val *out);
+
+int ldb_comparison_Integer( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *v1, const struct ldb_val *v2);
+
+int ldb_comparison_binary( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *v1, const struct ldb_val *v2);
+
+int ldb_comparison_fold( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *v1, const struct ldb_val *v2);
+
+int ldb_canonicalise_dn( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *in, struct ldb_val *out);
+
+int ldb_comparison_dn( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *v1, const struct ldb_val *v2);
+
+int ldb_comparison_objectclass( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *v1, const struct ldb_val *v2);
+
+int ldb_comparison_utctime( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *v1, const struct ldb_val *v2);
+
+int ldb_canonicalise_utctime( struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *in, struct ldb_val *out);
+
diff --git a/source4/lib/ldb/samba/ldif_handlers.c b/source4/lib/ldb/samba/ldif_handlers.c
index d017306176..573107f40d 100644
--- a/source4/lib/ldb/samba/ldif_handlers.c
+++ b/source4/lib/ldb/samba/ldif_handlers.c
@@ -24,6 +24,7 @@
#include "includes.h"
#include "ldb/include/includes.h"
+#include "ldb/include/ldb_handlers.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "librpc/gen_ndr/ndr_misc.h"
@@ -377,7 +378,7 @@ static const struct ldb_attrib_handler samba_handlers[] = {
.canonicalise_fn = ldb_canonicalise_objectSid,
.comparison_fn = ldb_comparison_objectSid
},
- {
+ {
.attr = "ntSecurityDescriptor",
.flags = 0,
.ldif_read_fn = ldif_read_ntSecurityDescriptor,
@@ -472,6 +473,118 @@ static const struct ldb_attrib_handler samba_handlers[] = {
.ldif_write_fn = ldb_handler_copy,
.canonicalise_fn = ldif_canonicalise_objectCategory,
.comparison_fn = ldif_comparison_objectCategory,
+ },
+ {
+ .attr = "member",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "memberOf",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "nCName",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "schemaNamingContext",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "configurationNamingContext",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "rootDomainNamingContext",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "defaultNamingContext",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "subRefs",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "dMDLocation",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "serverReference",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "masteredBy",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "msDs-masteredBy",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "subRefs",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
+ },
+ {
+ .attr = "fSMORoleOwner",
+ .flags = 0,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_dn,
+ .comparison_fn = ldb_comparison_dn,
}
};