summaryrefslogtreecommitdiff
path: root/source4/dsdb/samdb/ldb_modules
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-11-16 09:16:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:28:15 -0500
commitadae413042e15e7228bcc25321913b38ae61358a (patch)
tree25d26514a6a716ac07e2df4547a677b770eefcb5 /source4/dsdb/samdb/ldb_modules
parent72ce2ab2ee51b67eaf85544d207316a45198cc1c (diff)
downloadsamba-adae413042e15e7228bcc25321913b38ae61358a.tar.gz
samba-adae413042e15e7228bcc25321913b38ae61358a.tar.bz2
samba-adae413042e15e7228bcc25321913b38ae61358a.zip
r19731: Modify the ldb_map infrustructure to always map from requested
attributes to backend (remote) attributes. We can't do a reverse mapping safely where the remote attribute may be a source for multiple local attributes. (We end up with the wrong attributes returned). In doing this, I've modified the samba3sam.js test to be more realistic, and fixed some failures in the handling of primaryGroupID. I've added a new (private) helper function ldb_msg_remove_element() to avoid a double lookup of the element name. I've also re-formatted many of the function headers, to fit into standard editor widths. Andrew Bartlett (This used to be commit 186766e3095e71ba716c69e681592e217a3bc420)
Diffstat (limited to 'source4/dsdb/samdb/ldb_modules')
-rw-r--r--source4/dsdb/samdb/ldb_modules/samba3sam.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/samba3sam.c b/source4/dsdb/samdb/ldb_modules/samba3sam.c
index 341fad4bd9..6c7c3c7066 100644
--- a/source4/dsdb/samdb/ldb_modules/samba3sam.c
+++ b/source4/dsdb/samdb/ldb_modules/samba3sam.c
@@ -52,22 +52,25 @@
/* In Samba4 but not in Samba3:
*/
-static struct ldb_message_element *generate_primaryGroupID(struct ldb_module *module, TALLOC_CTX *ctx, const char *attr, const struct ldb_message *remote)
+/* From a sambaPrimaryGroupSID, generate a primaryGroupID (integer) attribute */
+static struct ldb_message_element *generate_primaryGroupID(struct ldb_module *module, TALLOC_CTX *ctx, const char *local_attr, const struct ldb_message *remote)
{
struct ldb_message_element *el;
- const char *sid = ldb_msg_find_attr_as_string(remote, attr, NULL);
-
+ const char *sid = ldb_msg_find_attr_as_string(remote, "sambaPrimaryGroupSID", NULL);
+ const char *p;
+
if (!sid)
return NULL;
- if (strchr(sid, '-') == NULL)
+ p = strrchr(sid, '-');
+ if (!p)
return NULL;
el = talloc_zero(ctx, struct ldb_message_element);
el->name = talloc_strdup(ctx, "primaryGroupID");
el->num_values = 1;
el->values = talloc_array(ctx, struct ldb_val, 1);
- el->values[0].data = (uint8_t *)talloc_strdup(el->values, strchr(sid, '-')+1);
+ el->values[0].data = (uint8_t *)talloc_strdup(el->values, strrchr(sid, '-')+1);
el->values[0].length = strlen((char *)el->values[0].data);
return el;
@@ -80,6 +83,7 @@ static void generate_sambaPrimaryGroupSID(struct ldb_module *module, const char
struct dom_sid *sid;
NTSTATUS status;
+ /* We need the domain, so we get it from the objectSid that we hope is here... */
sidval = ldb_msg_find_ldb_val(local, "objectSid");
if (!sidval)