summaryrefslogtreecommitdiff
path: root/source3/passdb
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-07 14:17:09 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-07 14:57:33 +1000
commite658421fe1f724da0e627c0ae407804993c2521e (patch)
tree1c3f728a4eed1b20464e4457b678d205ab064da6 /source3/passdb
parent227d490477230cfdd6b912b6f6a63314fa64ca88 (diff)
downloadsamba-e658421fe1f724da0e627c0ae407804993c2521e.tar.gz
samba-e658421fe1f724da0e627c0ae407804993c2521e.tar.bz2
samba-e658421fe1f724da0e627c0ae407804993c2521e.zip
s3-passdb: Simplify idmap wrapper in pdb_samba4
The source3 consumers of this API are now quite happy to be given an answer of ID_TYPE_BOTH, so we do not need this extra code to try and force the answer to UID or GID. Andrew Bartlett
Diffstat (limited to 'source3/passdb')
-rw-r--r--source3/passdb/pdb_samba4.c59
1 files changed, 9 insertions, 50 deletions
diff --git a/source3/passdb/pdb_samba4.c b/source3/passdb/pdb_samba4.c
index 40827df4ef..01eb4baad7 100644
--- a/source3/passdb/pdb_samba4.c
+++ b/source3/passdb/pdb_samba4.c
@@ -2058,67 +2058,26 @@ static bool pdb_samba4_sid_to_id(struct pdb_methods *m, const struct dom_sid *si
m->private_data, struct pdb_samba4_state);
struct id_map id_map;
struct id_map *id_maps[2];
- const char *attrs[] = { "objectClass", NULL };
- struct ldb_message *msg;
- struct ldb_dn *dn;
NTSTATUS status;
- int rc;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
if (!tmp_ctx) {
return false;
}
ZERO_STRUCT(id_map);
+ id_map.sid = sid;
+ id_maps[0] = &id_map;
+ id_maps[1] = NULL;
- dn = ldb_dn_new_fmt(tmp_ctx, state->ldb, "<SID=%s>", dom_sid_string(tmp_ctx, sid));
- if (!dn || !ldb_dn_validate(dn)) {
- talloc_free(tmp_ctx);
+ status = idmap_sids_to_xids(state->idmap_ctx, tmp_ctx, id_maps);
+ talloc_free(tmp_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
- rc = dsdb_search_one(state->ldb, tmp_ctx, &msg, dn, LDB_SCOPE_BASE, attrs, 0, NULL);
- if (rc == LDB_ERR_NO_SUCH_OBJECT) {
- DEBUG(5, (__location__ "SID to Unix ID lookup failed because SID %s could not be found in the samdb\n", dom_sid_string(tmp_ctx, sid)));
- talloc_free(tmp_ctx);
- return false;
+ if (id_map.xid.type != ID_TYPE_NOT_SPECIFIED) {
+ *id = id_map.xid;
+ return true;
}
- if (samdb_find_attribute(state->ldb, msg, "objectClass", "group")) {
- id->type = ID_TYPE_GID;
-
- ZERO_STRUCT(id_map);
- id_map.sid = sid;
- id_maps[0] = &id_map;
- id_maps[1] = NULL;
-
- status = idmap_sids_to_xids(state->idmap_ctx, tmp_ctx, id_maps);
- talloc_free(tmp_ctx);
- if (!NT_STATUS_IS_OK(status)) {
- return false;
- }
- if (id_map.xid.type == ID_TYPE_GID || id_map.xid.type == ID_TYPE_BOTH) {
- id->id = id_map.xid.id;
- return true;
- }
- return false;
- } else if (samdb_find_attribute(state->ldb, msg, "objectClass", "user")) {
- id->type = ID_TYPE_UID;
- ZERO_STRUCT(id_map);
- id_map.sid = sid;
- id_maps[0] = &id_map;
- id_maps[1] = NULL;
-
- status = idmap_sids_to_xids(state->idmap_ctx, tmp_ctx, id_maps);
- talloc_free(tmp_ctx);
- if (!NT_STATUS_IS_OK(status)) {
- return false;
- }
- if (id_map.xid.type == ID_TYPE_UID || id_map.xid.type == ID_TYPE_BOTH) {
- id->id = id_map.xid.id;
- return true;
- }
- return false;
- }
- DEBUG(5, (__location__ "SID to Unix ID lookup failed because SID %s was found, but was not a user or group\n", dom_sid_string(tmp_ctx, sid)));
- talloc_free(tmp_ctx);
return false;
}