summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-07-14 12:32:18 +0200
committerVolker Lendecke <vl@samba.org>2008-08-12 11:28:28 +0200
commit0c1e27abf69855abef396e4c93989964b70fcf1f (patch)
tree3d541583df6ecc789fb7c9028dee8eca47ba58ef /source3
parent1bdbe772ada5aeb1eeb98e78759ae7235d098085 (diff)
downloadsamba-0c1e27abf69855abef396e4c93989964b70fcf1f.tar.gz
samba-0c1e27abf69855abef396e4c93989964b70fcf1f.tar.bz2
samba-0c1e27abf69855abef396e4c93989964b70fcf1f.zip
Directly call backends from idmap_[ugs]_to_[ugs]id
(This used to be commit f955407042e6d2384acccc399d72ff65ba0e721c)
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/idmap.c39
-rw-r--r--source3/winbindd/idmap_util.c28
2 files changed, 45 insertions, 22 deletions
diff --git a/source3/winbindd/idmap.c b/source3/winbindd/idmap.c
index 95ff923d0f..f0d2c03e0b 100644
--- a/source3/winbindd/idmap.c
+++ b/source3/winbindd/idmap.c
@@ -1282,6 +1282,45 @@ done:
return ret;
}
+NTSTATUS idmap_backends_unixid_to_sid(struct id_map *id)
+{
+ struct id_map *maps[2];
+ int i;
+
+ maps[0] = id;
+ maps[1] = NULL;
+
+ for (i = num_domains-1; i>=0; i--) {
+ struct idmap_domain *dom = idmap_domains[i];
+ NTSTATUS status;
+
+ DEBUG(10, ("Query sids from domain %s\n", dom->name));
+
+ status = dom->methods->unixids_to_sids(dom, maps);
+ if (NT_STATUS_IS_OK(status)) {
+ return NT_STATUS_OK;
+ }
+ }
+
+ return NT_STATUS_NONE_MAPPED;
+}
+
+NTSTATUS idmap_backends_sid_to_unixid(struct id_map *id)
+{
+ struct idmap_domain *dom;
+ struct id_map *maps[2];
+
+ dom = find_idmap_domain_from_sid(id->sid);
+ if (dom == NULL) {
+ return NT_STATUS_NONE_MAPPED;
+ }
+
+ maps[0] = id;
+ maps[1] = NULL;
+
+ return dom->methods->sids_to_unixids(dom, maps);
+}
+
/**************************************************************************
idmap interface functions
**************************************************************************/
diff --git a/source3/winbindd/idmap_util.c b/source3/winbindd/idmap_util.c
index 0d24070dd6..31b9895224 100644
--- a/source3/winbindd/idmap_util.c
+++ b/source3/winbindd/idmap_util.c
@@ -31,7 +31,6 @@ NTSTATUS idmap_uid_to_sid(DOM_SID *sid, uid_t uid)
{
NTSTATUS ret;
struct id_map map;
- struct id_map *maps[2];
DEBUG(10,("uid = [%lu]\n", (unsigned long)uid));
@@ -39,10 +38,7 @@ NTSTATUS idmap_uid_to_sid(DOM_SID *sid, uid_t uid)
map.xid.type = ID_TYPE_UID;
map.xid.id = uid;
- maps[0] = &map;
- maps[1] = NULL;
-
- ret = idmap_unixids_to_sids(maps);
+ ret = idmap_backends_unixid_to_sid(&map);
if ( ! NT_STATUS_IS_OK(ret)) {
DEBUG(10, ("error mapping uid [%lu]\n", (unsigned long)uid));
return ret;
@@ -65,7 +61,6 @@ NTSTATUS idmap_gid_to_sid(DOM_SID *sid, gid_t gid)
{
NTSTATUS ret;
struct id_map map;
- struct id_map *maps[2];
DEBUG(10,("gid = [%lu]\n", (unsigned long)gid));
@@ -73,10 +68,7 @@ NTSTATUS idmap_gid_to_sid(DOM_SID *sid, gid_t gid)
map.xid.type = ID_TYPE_GID;
map.xid.id = gid;
- maps[0] = &map;
- maps[1] = NULL;
-
- ret = idmap_unixids_to_sids(maps);
+ ret = idmap_backends_unixid_to_sid(&map);
if ( ! NT_STATUS_IS_OK(ret)) {
DEBUG(10, ("error mapping gid [%lu]\n", (unsigned long)gid));
return ret;
@@ -99,17 +91,13 @@ NTSTATUS idmap_sid_to_uid(DOM_SID *sid, uid_t *uid)
{
NTSTATUS ret;
struct id_map map;
- struct id_map *maps[2];
DEBUG(10,("idmap_sid_to_uid: sid = [%s]\n", sid_string_dbg(sid)));
map.sid = sid;
map.xid.type = ID_TYPE_UID;
-
- maps[0] = &map;
- maps[1] = NULL;
-
- ret = idmap_sids_to_unixids(maps);
+
+ ret = idmap_backends_sid_to_unixid(&map);
if ( ! NT_STATUS_IS_OK(ret)) {
DEBUG(10, ("error mapping sid [%s] to uid\n",
sid_string_dbg(sid)));
@@ -139,17 +127,13 @@ NTSTATUS idmap_sid_to_gid(DOM_SID *sid, gid_t *gid)
{
NTSTATUS ret;
struct id_map map;
- struct id_map *maps[2];
DEBUG(10,("idmap_sid_to_gid: sid = [%s]\n", sid_string_dbg(sid)));
map.sid = sid;
map.xid.type = ID_TYPE_GID;
-
- maps[0] = &map;
- maps[1] = NULL;
-
- ret = idmap_sids_to_unixids(maps);
+
+ ret = idmap_backends_sid_to_unixid(&map);
if ( ! NT_STATUS_IS_OK(ret)) {
DEBUG(10, ("error mapping sid [%s] to gid\n",
sid_string_dbg(sid)));