]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
r2691: Increase a debug level for a quite frequent operation.
authorVolker Lendecke <vlendec@samba.org>
Mon, 27 Sep 2004 14:44:07 +0000 (14:44 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:52:49 +0000 (10:52 -0500)
Optimization for 'idmap backend = ldap': When asking sid2id for the wrong
type, don't ask ldap when we have the opposite mapping in the local tdb.

Volker

source/nsswitch/winbindd_sid.c
source/sam/idmap.c

index 97e676813dde211e1c14521834e49391d269025c..060e66fbc2d616ede18fcf2e97770075d7c33140 100644 (file)
@@ -219,7 +219,7 @@ enum winbindd_result winbindd_sid_to_uid(struct winbindd_cli_state *state)
        if (NT_STATUS_IS_OK(result))
                return WINBINDD_OK;
 
-       DEBUG(1, ("Could not get uid for sid %s\n", state->request.data.sid));
+       DEBUG(4, ("Could not get uid for sid %s\n", state->request.data.sid));
        return WINBINDD_ERROR;
 }
 
@@ -337,7 +337,7 @@ enum winbindd_result winbindd_sid_to_gid(struct winbindd_cli_state *state)
        if (NT_STATUS_IS_OK(result))
                return WINBINDD_OK;
 
-       DEBUG(1, ("Could not get gid for sid %s\n", state->request.data.sid));
+       DEBUG(4, ("Could not get gid for sid %s\n", state->request.data.sid));
        return WINBINDD_ERROR;
 }
 
index d541776f3917915ec9a808f0aa15e4963ba1a17d..4de37f0e4999650b78b7778be2c3fa665796b039 100644 (file)
@@ -200,6 +200,7 @@ NTSTATUS idmap_get_id_from_sid(unid_t *id, int *id_type, const DOM_SID *sid)
 {
        NTSTATUS ret;
        int loc_type;
+       unid_t loc_id;
 
        if (proxyonly)
                return NT_STATUS_UNSUCCESSFUL;
@@ -223,6 +224,32 @@ NTSTATUS idmap_get_id_from_sid(unid_t *id, int *id_type, const DOM_SID *sid)
                return ret;
        }
 
+       /* Before forking out to the possibly slow remote map, lets see if we
+        * already have the sid as uid when asking for a gid or vice versa. */
+
+       loc_type = *id_type & ID_TYPEMASK;
+
+       switch (loc_type) {
+       case ID_USERID:
+               loc_type = ID_GROUPID;
+               break;
+       case ID_GROUPID:
+               loc_type = ID_USERID;
+               break;
+       default:
+               loc_type = ID_EMPTY;
+       }
+
+       loc_type |= ID_QUERY_ONLY;
+
+       ret = cache_map->get_id_from_sid(&loc_id, &loc_type, sid);
+
+       if (NT_STATUS_IS_OK(ret)) {
+               /* Ok, we have the uid as gid or vice versa. The remote map
+                * would not know anything different, so return here. */
+               return NT_STATUS_UNSUCCESSFUL;
+       }
+
        /* Ok, the mapping was not in the cache, give the remote map a
            second try. */