mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
r26137: Rename the entryUUID module to better match it's purpose: being a
simple ldap mapping (a complex mapping will follow).
Fix the module to handle 'name' better, rather than using the 'name'
attribute built into OpenLDAP, rename to samba4RDN. We need to see if
this can be handled in the backend.
Also rename the functions and inernal module name to entryuuid for
consistancy.
Andrew Bartlett
(This used to be commit a7be80766f
)
This commit is contained in:
parent
0ac6bffdf4
commit
adef944c43
@ -97,17 +97,18 @@ OBJ_FILES = \
|
||||
################################################
|
||||
|
||||
################################################
|
||||
# Start MODULE ldb_entryUUID
|
||||
[MODULE::ldb_entryUUID]
|
||||
# Start MODULE ldb_simple_ldap_map
|
||||
[MODULE::ldb_simple_ldap_map]
|
||||
SUBSYSTEM = LIBLDB
|
||||
OUTPUT_TYPE = SHARED_LIBRARY
|
||||
INIT_FUNCTION = ldb_entryUUID_module_init
|
||||
PRIVATE_DEPENDENCIES = LIBTALLOC
|
||||
INIT_FUNCTION = ldb_simple_ldap_map_module_init
|
||||
PRIVATE_DEPENDENCIES = LIBTALLOC ldb_map
|
||||
ENABLE = YES
|
||||
ALIASES = entryuuid nsuniqueid
|
||||
OBJ_FILES = \
|
||||
entryUUID.o
|
||||
simple_ldap_map.o
|
||||
#
|
||||
# End MODULE ldb_entryUUID
|
||||
# End MODULE ldb_entryuuid
|
||||
################################################
|
||||
|
||||
# ################################################
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "librpc/gen_ndr/ndr_misc.h"
|
||||
#include "librpc/ndr/libndr.h"
|
||||
|
||||
struct entryUUID_private {
|
||||
struct entryuuid_private {
|
||||
struct ldb_dn **base_dns;
|
||||
};
|
||||
|
||||
@ -254,7 +254,7 @@ static struct ldb_val timestamp_to_usn(struct ldb_module *module, TALLOC_CTX *ct
|
||||
}
|
||||
|
||||
|
||||
static const struct ldb_map_attribute entryUUID_attributes[] =
|
||||
static const struct ldb_map_attribute entryuuid_attributes[] =
|
||||
{
|
||||
/* objectGUID */
|
||||
{
|
||||
@ -292,6 +292,15 @@ static const struct ldb_map_attribute entryUUID_attributes[] =
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
.local_name = "name",
|
||||
.type = MAP_RENAME,
|
||||
.u = {
|
||||
.rename = {
|
||||
.remote_name = "samba4RDN"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
.local_name = "whenCreated",
|
||||
.type = MAP_RENAME,
|
||||
@ -420,7 +429,7 @@ static const struct ldb_map_attribute entryUUID_attributes[] =
|
||||
};
|
||||
|
||||
/* This objectClass conflicts with builtin classes on OpenLDAP */
|
||||
const struct ldb_map_objectclass entryUUID_objectclasses[] =
|
||||
const struct ldb_map_objectclass entryuuid_objectclasses[] =
|
||||
{
|
||||
{
|
||||
.local_name = "subSchema",
|
||||
@ -433,7 +442,7 @@ const struct ldb_map_objectclass entryUUID_objectclasses[] =
|
||||
|
||||
/* These things do not show up in wildcard searches in OpenLDAP, but
|
||||
* we need them to show up in the AD-like view */
|
||||
static const char * const entryUUID_wildcard_attributes[] = {
|
||||
static const char * const entryuuid_wildcard_attributes[] = {
|
||||
"objectGUID",
|
||||
"whenCreated",
|
||||
"whenChanged",
|
||||
@ -582,31 +591,31 @@ static const char * const nsuniqueid_wildcard_attributes[] = {
|
||||
static int get_remote_rootdse(struct ldb_context *ldb, void *context,
|
||||
struct ldb_reply *ares)
|
||||
{
|
||||
struct entryUUID_private *entryUUID_private;
|
||||
entryUUID_private = talloc_get_type(context,
|
||||
struct entryUUID_private);
|
||||
struct entryuuid_private *entryuuid_private;
|
||||
entryuuid_private = talloc_get_type(context,
|
||||
struct entryuuid_private);
|
||||
if (ares->type == LDB_REPLY_ENTRY) {
|
||||
int i;
|
||||
struct ldb_message_element *el = ldb_msg_find_element(ares->message, "namingContexts");
|
||||
entryUUID_private->base_dns = talloc_realloc(entryUUID_private, entryUUID_private->base_dns, struct ldb_dn *,
|
||||
entryuuid_private->base_dns = talloc_realloc(entryuuid_private, entryuuid_private->base_dns, struct ldb_dn *,
|
||||
el->num_values + 1);
|
||||
for (i=0; i < el->num_values; i++) {
|
||||
if (!entryUUID_private->base_dns) {
|
||||
if (!entryuuid_private->base_dns) {
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
entryUUID_private->base_dns[i] = ldb_dn_new(entryUUID_private->base_dns, ldb, (const char *)el->values[i].data);
|
||||
if ( ! ldb_dn_validate(entryUUID_private->base_dns[i])) {
|
||||
entryuuid_private->base_dns[i] = ldb_dn_new(entryuuid_private->base_dns, ldb, (const char *)el->values[i].data);
|
||||
if ( ! ldb_dn_validate(entryuuid_private->base_dns[i])) {
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
}
|
||||
}
|
||||
entryUUID_private->base_dns[i] = NULL;
|
||||
entryuuid_private->base_dns[i] = NULL;
|
||||
}
|
||||
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int find_base_dns(struct ldb_module *module,
|
||||
struct entryUUID_private *entryUUID_private)
|
||||
struct entryuuid_private *entryuuid_private)
|
||||
{
|
||||
int ret;
|
||||
struct ldb_request *req;
|
||||
@ -614,7 +623,7 @@ static int find_base_dns(struct ldb_module *module,
|
||||
"namingContexts",
|
||||
NULL
|
||||
};
|
||||
req = talloc(entryUUID_private, struct ldb_request);
|
||||
req = talloc(entryuuid_private, struct ldb_request);
|
||||
if (req == NULL) {
|
||||
ldb_set_errstring(module->ldb, "Out of Memory");
|
||||
return LDB_ERR_OPERATIONS_ERROR;
|
||||
@ -633,7 +642,7 @@ static int find_base_dns(struct ldb_module *module,
|
||||
|
||||
req->op.search.attrs = naming_context_attr;
|
||||
req->controls = NULL;
|
||||
req->context = entryUUID_private;
|
||||
req->context = entryuuid_private;
|
||||
req->callback = get_remote_rootdse;
|
||||
ldb_set_timeout(module->ldb, req, 0); /* use default timeout */
|
||||
|
||||
@ -652,22 +661,22 @@ static int find_base_dns(struct ldb_module *module,
|
||||
}
|
||||
|
||||
/* the context init function */
|
||||
static int entryUUID_init(struct ldb_module *module)
|
||||
static int entryuuid_init(struct ldb_module *module)
|
||||
{
|
||||
int ret;
|
||||
struct map_private *map_private;
|
||||
struct entryUUID_private *entryUUID_private;
|
||||
struct entryuuid_private *entryuuid_private;
|
||||
|
||||
ret = ldb_map_init(module, entryUUID_attributes, entryUUID_objectclasses, entryUUID_wildcard_attributes, NULL);
|
||||
ret = ldb_map_init(module, entryuuid_attributes, entryuuid_objectclasses, entryuuid_wildcard_attributes, NULL);
|
||||
if (ret != LDB_SUCCESS)
|
||||
return ret;
|
||||
|
||||
map_private = talloc_get_type(module->private_data, struct map_private);
|
||||
|
||||
entryUUID_private = talloc_zero(map_private, struct entryUUID_private);
|
||||
map_private->caller_private = entryUUID_private;
|
||||
entryuuid_private = talloc_zero(map_private, struct entryuuid_private);
|
||||
map_private->caller_private = entryuuid_private;
|
||||
|
||||
ret = find_base_dns(module, entryUUID_private);
|
||||
ret = find_base_dns(module, entryuuid_private);
|
||||
|
||||
return ldb_next_init(module);
|
||||
}
|
||||
@ -677,7 +686,7 @@ static int nsuniqueid_init(struct ldb_module *module)
|
||||
{
|
||||
int ret;
|
||||
struct map_private *map_private;
|
||||
struct entryUUID_private *entryUUID_private;
|
||||
struct entryuuid_private *entryuuid_private;
|
||||
|
||||
ret = ldb_map_init(module, nsuniqueid_attributes, NULL, nsuniqueid_wildcard_attributes, NULL);
|
||||
if (ret != LDB_SUCCESS)
|
||||
@ -685,10 +694,10 @@ static int nsuniqueid_init(struct ldb_module *module)
|
||||
|
||||
map_private = talloc_get_type(module->private_data, struct map_private);
|
||||
|
||||
entryUUID_private = talloc_zero(map_private, struct entryUUID_private);
|
||||
map_private->caller_private = entryUUID_private;
|
||||
entryuuid_private = talloc_zero(map_private, struct entryuuid_private);
|
||||
map_private->caller_private = entryuuid_private;
|
||||
|
||||
ret = find_base_dns(module, entryUUID_private);
|
||||
ret = find_base_dns(module, entryuuid_private);
|
||||
|
||||
return ldb_next_init(module);
|
||||
}
|
||||
@ -709,21 +718,21 @@ static int get_seq(struct ldb_context *ldb, void *context,
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static int entryUUID_sequence_number(struct ldb_module *module, struct ldb_request *req)
|
||||
static int entryuuid_sequence_number(struct ldb_module *module, struct ldb_request *req)
|
||||
{
|
||||
int i, ret;
|
||||
struct map_private *map_private;
|
||||
struct entryUUID_private *entryUUID_private;
|
||||
struct entryuuid_private *entryuuid_private;
|
||||
unsigned long long max_seq = 0;
|
||||
struct ldb_request *search_req;
|
||||
map_private = talloc_get_type(module->private_data, struct map_private);
|
||||
|
||||
entryUUID_private = talloc_get_type(map_private->caller_private, struct entryUUID_private);
|
||||
entryuuid_private = talloc_get_type(map_private->caller_private, struct entryuuid_private);
|
||||
|
||||
/* Search the baseDNs for a sequence number */
|
||||
for (i=0; entryUUID_private &&
|
||||
entryUUID_private->base_dns &&
|
||||
entryUUID_private->base_dns[i];
|
||||
for (i=0; entryuuid_private &&
|
||||
entryuuid_private->base_dns &&
|
||||
entryuuid_private->base_dns[i];
|
||||
i++) {
|
||||
static const char *contextCSN_attr[] = {
|
||||
"contextCSN", NULL
|
||||
@ -735,7 +744,7 @@ static int entryUUID_sequence_number(struct ldb_module *module, struct ldb_reque
|
||||
}
|
||||
|
||||
search_req->operation = LDB_SEARCH;
|
||||
search_req->op.search.base = entryUUID_private->base_dns[i];
|
||||
search_req->op.search.base = entryuuid_private->base_dns[i];
|
||||
search_req->op.search.scope = LDB_SCOPE_BASE;
|
||||
|
||||
search_req->op.search.tree = ldb_parse_tree(search_req, "objectClass=*");
|
||||
@ -783,30 +792,30 @@ static int entryUUID_sequence_number(struct ldb_module *module, struct ldb_reque
|
||||
return LDB_SUCCESS;
|
||||
}
|
||||
|
||||
static struct ldb_module_ops entryUUID_ops = {
|
||||
.name = "entryUUID",
|
||||
.init_context = entryUUID_init,
|
||||
.sequence_number = entryUUID_sequence_number
|
||||
static struct ldb_module_ops entryuuid_ops = {
|
||||
.name = "entryuuid",
|
||||
.init_context = entryuuid_init,
|
||||
.sequence_number = entryuuid_sequence_number
|
||||
};
|
||||
|
||||
static struct ldb_module_ops nsuniqueid_ops = {
|
||||
.name = "nsuniqueid",
|
||||
.init_context = nsuniqueid_init,
|
||||
.sequence_number = entryUUID_sequence_number
|
||||
.sequence_number = entryuuid_sequence_number
|
||||
};
|
||||
|
||||
/* the init function */
|
||||
int ldb_entryUUID_module_init(void)
|
||||
int ldb_simple_ldap_map_module_init(void)
|
||||
{
|
||||
int ret;
|
||||
struct ldb_module_ops ops = ldb_map_get_ops();
|
||||
entryUUID_ops.add = ops.add;
|
||||
entryUUID_ops.modify = ops.modify;
|
||||
entryUUID_ops.del = ops.del;
|
||||
entryUUID_ops.rename = ops.rename;
|
||||
entryUUID_ops.search = ops.search;
|
||||
entryUUID_ops.wait = ops.wait;
|
||||
ret = ldb_register_module(&entryUUID_ops);
|
||||
entryuuid_ops.add = ops.add;
|
||||
entryuuid_ops.modify = ops.modify;
|
||||
entryuuid_ops.del = ops.del;
|
||||
entryuuid_ops.rename = ops.rename;
|
||||
entryuuid_ops.search = ops.search;
|
||||
entryuuid_ops.wait = ops.wait;
|
||||
ret = ldb_register_module(&entryuuid_ops);
|
||||
|
||||
if (ret) {
|
||||
return ret;
|
6
source4/selftest/env/Samba4.pm
vendored
6
source4/selftest/env/Samba4.pm
vendored
@ -220,7 +220,11 @@ sub mk_openldap($$$)
|
||||
system("$self->{bindir}/ad2oLschema $configuration --option=convert:target=openldap -H $ldapdir/schema-tmp.ldb -I $self->{setupdir}/schema-map-openldap-2.3 -O $ldapdir/backend-schema.schema >&2") == 0 or die("schema conversion for OpenLDAP failed");
|
||||
|
||||
my $oldpath = $ENV{PATH};
|
||||
$ENV{PATH} = "$ENV{OPENLDAP_PATH}/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}";
|
||||
my $olpath = "";
|
||||
if (defined $ENV{OPENLDAP_PATH}) {
|
||||
$olpath = "$ENV{OPENLDAP_PATH}:"
|
||||
}
|
||||
$ENV{PATH} = "$olpath/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}";
|
||||
|
||||
unlink($modconf);
|
||||
open(CONF, ">$modconf"); close(CONF);
|
||||
|
@ -141,7 +141,7 @@ if (ldapbackend) {
|
||||
subobj.LDAPBACKEND = subobj.LDAPI_URI;
|
||||
}
|
||||
if (!ldapmodule) {
|
||||
subobj.LDAPMODULE = "entryUUID";
|
||||
subobj.LDAPMODULE = "entryuuid";
|
||||
}
|
||||
subobj.DOMAINDN_LDB = subobj.LDAPBACKEND;
|
||||
subobj.DOMAINDN_MOD2 = "," + subobj.LDAPMODULE + ",paged_searches";
|
||||
|
@ -1,5 +1,4 @@
|
||||
#Standard OpenLDAP attributes
|
||||
name
|
||||
labeledURI
|
||||
createTimeStamp
|
||||
objectClass
|
||||
@ -23,6 +22,8 @@ objectClasses:samba4ObjectClasses
|
||||
2.5.21.6:1.3.6.1.4.1.7165.4.255.5
|
||||
subSchema:samba4SubSchema
|
||||
2.5.20.1:1.3.6.1.4.1.7165.4.255.4
|
||||
#'name' is the RDN in AD, but something else in OpenLDAP
|
||||
name:samba4RDN
|
||||
#Remap these so that we don't put operational attributes in a schema MAY
|
||||
modifyTimeStamp:samba4ModifyTimestamp
|
||||
2.5.18.2:1.3.6.1.4.1.7165.4.255.3
|
||||
|
Loading…
Reference in New Issue
Block a user