summaryrefslogtreecommitdiffstats
path: root/src/ldb_modules/memberof.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ldb_modules/memberof.c')
-rw-r--r--src/ldb_modules/memberof.c80
1 files changed, 42 insertions, 38 deletions
diff --git a/src/ldb_modules/memberof.c b/src/ldb_modules/memberof.c
index e5580f26b..690b37b17 100644
--- a/src/ldb_modules/memberof.c
+++ b/src/ldb_modules/memberof.c
@@ -27,7 +27,7 @@
#define DB_GHOST "ghost"
#define DB_MEMBEROF "memberof"
#define DB_MEMBERUID "memberuid"
-#define DB_NAME "name"
+#define DB_FQNAME "fqname"
#define DB_USER_CLASS "user"
#define DB_GROUP_CLASS "group"
#define DB_CACHE_EXPIRE "dataExpireTimestamp"
@@ -230,7 +230,7 @@ static int mbof_append_muop(TALLOC_CTX *memctx,
int *_num_muops,
int flags,
struct ldb_dn *parent,
- const char *name,
+ const char *element_value,
const char *element_name)
{
struct mbof_memberuid_op *muops = *_muops;
@@ -277,7 +277,7 @@ static int mbof_append_muop(TALLOC_CTX *memctx,
}
for (i = 0; i < op->el->num_values; i++) {
- if (strcmp((char *)op->el->values[i].data, name) == 0) {
+ if (strcmp((char *)op->el->values[i].data, element_value) == 0) {
/* we already have this value, get out*/
return LDB_SUCCESS;
}
@@ -288,11 +288,12 @@ static int mbof_append_muop(TALLOC_CTX *memctx,
if (!val) {
return LDB_ERR_OPERATIONS_ERROR;
}
- val[op->el->num_values].data = (uint8_t *)talloc_strdup(val, name);
+ val[op->el->num_values].data = (uint8_t *)talloc_strdup(val,
+ element_value);
if (!val[op->el->num_values].data) {
return LDB_ERR_OPERATIONS_ERROR;
}
- val[op->el->num_values].length = strlen(name);
+ val[op->el->num_values].length = strlen(element_value);
op->el->values = val;
op->el->num_values++;
@@ -639,7 +640,8 @@ static int mbof_add_callback(struct ldb_request *req,
static int mbof_next_add(struct mbof_add_operation *addop)
{
- static const char *attrs[] = { DB_OC, DB_NAME,
+ static const char *attrs[] = { DB_OC,
+ DB_FQNAME,
DB_MEMBER, DB_GHOST,
DB_MEMBEROF, NULL };
struct ldb_context *ldb;
@@ -779,7 +781,7 @@ static int mbof_add_operation(struct mbof_add_operation *addop)
struct mbof_dn_array *parents;
int i, j, ret;
const char *val;
- const char *name;
+ const char *fqname;
add_ctx = addop->add_ctx;
ctx = add_ctx->ctx;
@@ -886,9 +888,9 @@ static int mbof_add_operation(struct mbof_add_operation *addop)
ret = entry_is_user_object(addop->entry);
switch (ret) {
case LDB_SUCCESS:
- /* it's a user object */
- name = ldb_msg_find_attr_as_string(addop->entry, DB_NAME, NULL);
- if (!name) {
+ /* it's a user object. Use fully qualified name for memberUid value */
+ fqname = ldb_msg_find_attr_as_string(addop->entry, DB_FQNAME, NULL);
+ if (!fqname) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -896,7 +898,8 @@ static int mbof_add_operation(struct mbof_add_operation *addop)
ret = mbof_append_muop(add_ctx, &add_ctx->muops,
&add_ctx->num_muops,
LDB_FLAG_MOD_ADD,
- parents->dns[i], name,
+ parents->dns[i],
+ fqname,
DB_MEMBERUID);
if (ret != LDB_SUCCESS) {
return ret;
@@ -1314,7 +1317,8 @@ static void free_delop_contents(struct mbof_del_operation *delop);
static int memberof_del(struct ldb_module *module, struct ldb_request *req)
{
- static const char *attrs[] = { DB_OC, DB_NAME,
+ static const char *attrs[] = { DB_OC,
+ DB_FQNAME,
DB_MEMBER, DB_MEMBEROF,
DB_GHOST, NULL };
struct ldb_context *ldb = ldb_module_get_ctx(module);
@@ -1467,7 +1471,7 @@ static int mbof_del_search_callback(struct ldb_request *req,
}
/* now perform the requested delete, before proceeding further */
- ret = mbof_orig_del(del_ctx);
+ ret = mbof_orig_del(del_ctx);
if (ret != LDB_SUCCESS) {
talloc_zfree(ares);
return ldb_module_done(ctx->req, NULL, NULL, ret);
@@ -1767,8 +1771,7 @@ static int mbof_del_execute_op(struct mbof_del_operation *delop)
char *expression;
const char *dn;
char *clean_dn;
- static const char *attrs[] = { DB_OC, DB_NAME,
- DB_MEMBER, DB_MEMBEROF, NULL };
+ static const char *attrs[] = { DB_OC, DB_MEMBER, DB_MEMBEROF, NULL };
int ret;
del_ctx = delop->del_ctx;
@@ -2107,7 +2110,7 @@ static int mbof_del_mod_entry(struct mbof_del_operation *delop)
struct ldb_message *msg;
struct ldb_message_element *el;
struct ldb_dn **diff = NULL;
- const char *name;
+ const char *fqname;
const char *val;
int i, j, k;
bool is_user;
@@ -2226,8 +2229,8 @@ static int mbof_del_mod_entry(struct mbof_del_operation *delop)
if (is_user && diff[0]) {
/* file memberuid removal operations */
- name = ldb_msg_find_attr_as_string(delop->entry, DB_NAME, NULL);
- if (!name) {
+ fqname = ldb_msg_find_attr_as_string(delop->entry, DB_FQNAME, NULL);
+ if (!fqname) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -2235,7 +2238,7 @@ static int mbof_del_mod_entry(struct mbof_del_operation *delop)
ret = mbof_append_muop(del_ctx, &del_ctx->muops,
&del_ctx->num_muops,
LDB_FLAG_MOD_DELETE,
- diff[i], name,
+ diff[i], fqname,
DB_MEMBERUID);
if (ret != LDB_SUCCESS) {
return ret;
@@ -2435,7 +2438,7 @@ static int mbof_del_fill_muop(struct mbof_del_ctx *del_ctx,
struct ldb_message *entry)
{
struct ldb_message_element *el;
- char *name;
+ char *fqname;
int ret;
int i;
@@ -2460,9 +2463,9 @@ static int mbof_del_fill_muop(struct mbof_del_ctx *del_ctx,
return ret;
}
- name = talloc_strdup(del_ctx,
- ldb_msg_find_attr_as_string(entry, DB_NAME, NULL));
- if (!name) {
+ fqname = talloc_strdup(del_ctx,
+ ldb_msg_find_attr_as_string(entry, DB_FQNAME, NULL));
+ if (!fqname) {
return LDB_ERR_OPERATIONS_ERROR;
}
@@ -2482,7 +2485,7 @@ static int mbof_del_fill_muop(struct mbof_del_ctx *del_ctx,
ret = mbof_append_muop(del_ctx, &del_ctx->muops,
&del_ctx->num_muops,
LDB_FLAG_MOD_DELETE,
- valdn, name,
+ valdn, fqname,
DB_MEMBERUID);
if (ret != LDB_SUCCESS) {
return ret;
@@ -3847,7 +3850,7 @@ struct mbof_member {
struct mbof_member *next;
struct ldb_dn *dn;
- const char *name;
+ const char *fqname;
bool orig_has_memberof;
bool orig_has_memberuid;
struct ldb_message_element *orig_members;
@@ -3919,7 +3922,7 @@ static int memberof_recompute_task(struct ldb_module *module,
struct ldb_request *req)
{
struct ldb_context *ldb = ldb_module_get_ctx(module);
- static const char *attrs[] = { DB_NAME, DB_MEMBEROF, NULL };
+ static const char *attrs[] = { DB_FQNAME, DB_MEMBEROF, NULL };
static const char *filter = "(objectclass=user)";
struct mbof_rcmp_context *ctx;
struct ldb_request *src_req;
@@ -3956,7 +3959,7 @@ static int mbof_rcmp_usr_callback(struct ldb_request *req,
struct mbof_member *usr;
hash_value_t value;
hash_key_t key;
- const char *name;
+ const char *fqname;
int ret;
ctx = talloc_get_type(req->context, struct mbof_rcmp_context);
@@ -3983,9 +3986,9 @@ static int mbof_rcmp_usr_callback(struct ldb_request *req,
usr->status = MBOF_USER;
usr->dn = talloc_steal(usr, ares->message->dn);
- name = ldb_msg_find_attr_as_string(ares->message, DB_NAME, NULL);
- if (name) {
- usr->name = talloc_steal(usr, name);
+ fqname = ldb_msg_find_attr_as_string(ares->message, DB_FQNAME, NULL);
+ if (fqname) {
+ usr->fqname = talloc_steal(usr, fqname);
}
if (ldb_msg_find_element(ares->message, DB_MEMBEROF)) {
@@ -4026,7 +4029,7 @@ static int mbof_rcmp_search_groups(struct mbof_rcmp_context *ctx)
{
struct ldb_context *ldb = ldb_module_get_ctx(ctx->module);
static const char *attrs[] = { DB_MEMBEROF, DB_MEMBERUID,
- DB_NAME, DB_MEMBER, NULL };
+ DB_MEMBER, NULL };
static const char *filter = "(objectclass=group)";
struct ldb_request *req;
int ret;
@@ -4059,7 +4062,7 @@ static int mbof_rcmp_grp_callback(struct ldb_request *req,
struct mbof_member *grp;
hash_value_t value;
hash_key_t key;
- const char *name;
+ const char *fqname;
int i, j;
int ret;
@@ -4088,10 +4091,11 @@ static int mbof_rcmp_grp_callback(struct ldb_request *req,
grp->status = MBOF_GROUP_TO_DO;
grp->dn = talloc_steal(grp, ares->message->dn);
- grp->name = ldb_msg_find_attr_as_string(ares->message, DB_NAME, NULL);
- name = ldb_msg_find_attr_as_string(ares->message, DB_NAME, NULL);
- if (name) {
- grp->name = talloc_steal(grp, name);
+ grp->fqname = ldb_msg_find_attr_as_string(ares->message,
+ DB_FQNAME, NULL);
+ fqname = ldb_msg_find_attr_as_string(ares->message, DB_FQNAME, NULL);
+ if (fqname) {
+ grp->fqname = talloc_steal(grp, fqname);
}
if (ldb_msg_find_element(ares->message, DB_MEMBEROF)) {
@@ -4276,7 +4280,7 @@ static int mbof_member_update(struct mbof_rcmp_context *ctx,
if (mem->status == MBOF_USER) {
/* add corresponding memuid to the group */
- ret = mbof_add_memuid(parent, mem->name);
+ ret = mbof_add_memuid(parent, mem->fqname);
if (ret != LDB_SUCCESS) {
return ret;
}
@@ -4343,7 +4347,7 @@ static bool mbof_member_iter(hash_entry_t *item, void *user_data)
if (mem->status == MBOF_USER) {
/* add corresponding memuid to the group */
parent = (struct mbof_member *)item->value.ptr;
- ret = mbof_add_memuid(parent, mem->name);
+ ret = mbof_add_memuid(parent, mem->fqname);
if (ret != LDB_SUCCESS) {
mem->status = MBOF_ITER_ERROR;
return false;