diff options
Diffstat (limited to 'source3/nsswitch/winbindd_user.c')
-rw-r--r-- | source3/nsswitch/winbindd_user.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/source3/nsswitch/winbindd_user.c b/source3/nsswitch/winbindd_user.c index ce677198ff..74dc291e01 100644 --- a/source3/nsswitch/winbindd_user.c +++ b/source3/nsswitch/winbindd_user.c @@ -239,7 +239,30 @@ static void getpwsid_queryuser_recv(void *private_data, BOOL success, return; } + if ( acct_name && *acct_name ) { fstrcpy( username, acct_name ); + } else { + char *domain_name = NULL; + enum lsa_SidType type; + char *user_name = NULL; + struct winbindd_domain *domain = NULL; + + domain = find_lookup_domain_from_sid(&s->user_sid); + winbindd_lookup_name_by_sid(s->state->mem_ctx, domain, + &s->user_sid, &domain_name, + &user_name, &type ); + + /* If this still fails we ar4e done. Just error out */ + if ( !user_name ) { + DEBUG(5,("Could not obtain a name for SID %s\n", + sid_string_static(&s->user_sid))); + request_error(s->state); + return; + } + + fstrcpy( username, user_name ); + } + strlower_m( username ); s->username = talloc_strdup(s->state->mem_ctx, username); @@ -360,11 +383,14 @@ void winbindd_getpwnam(struct winbindd_cli_state *state) domain = find_domain_from_name(domname); if (domain == NULL) { - DEBUG(7, ("could not find domain entry for domain %s\n", - domname)); + DEBUG(7, ("could not find domain entry for domain %s. " + "Using primary domain\n", domname)); + if ( (domain = find_our_domain()) == NULL ) { + DEBUG(0,("Cannot find my primary domain structure!\n")); request_error(state); return; } + } if ( strequal(domname, lp_workgroup()) && lp_winbind_trusted_domains_only() ) { DEBUG(7,("winbindd_getpwnam: My domain -- rejecting getpwnam() for %s\\%s.\n", @@ -384,6 +410,7 @@ static void getpwnam_name2sid_recv(void *private_data, BOOL success, { struct winbindd_cli_state *state = (struct winbindd_cli_state *)private_data; + fstring domname, username; if (!success) { DEBUG(5, ("Could not lookup name for user %s\n", @@ -398,6 +425,12 @@ static void getpwnam_name2sid_recv(void *private_data, BOOL success, return; } + if ( parse_domain_user(state->request.data.username, domname, username) ) { + check_domain_trusted( domname, sid ); + } + + + winbindd_getpwsid(state, sid); } |