--- a/source3/winbindd/nss_info_template.c +++ b/source3/winbindd/nss_info_template.c @@ -41,14 +41,16 @@ static NTSTATUS nss_template_get_info( s const char **gecos, gid_t *gid ) { - if ( !homedir || !shell || !gecos ) + /* gecos is not handled, like gid, so ignore it. It may be a + * hint for the cache, like gid + */ + if ( !homedir || !shell ) return NT_STATUS_INVALID_PARAMETER; /* protect against home directories using whitespace in the username */ *homedir = talloc_strdup( ctx, lp_template_homedir() ); *shell = talloc_strdup( ctx, lp_template_shell() ); - *gecos = NULL; if ( !*homedir || !*shell ) { return NT_STATUS_NO_MEMORY; --- a/source3/winbindd/winbindd_ads.c +++ b/source3/winbindd/winbindd_ads.c @@ -355,6 +355,10 @@ static NTSTATUS query_user_list(struct w struct wbint_userinfo *info = &((*pinfo)[i]); const char *gecos = NULL; gid_t primary_gid = (gid_t)-1; + /* set gecos if we know full_name already as a hint. nss_template does not + * handle gecos, so the cache would be filled incomplete + */ + if(info->full_name!=NULL) gecos = info->full_name; status = nss_get_info_cached(domain, &info->user_sid, mem_ctx, &info->homedir, &info->shell, @@ -368,6 +372,7 @@ static NTSTATUS query_user_list(struct w } if (gecos != NULL) { + if (gecos != info->full_name) TALLOC_FREE(info->full_name); info->full_name = gecos; } info->primary_gid = primary_gid; @@ -637,6 +642,7 @@ static NTSTATUS query_user(struct winbin sid_compose(&info->group_sid, &domain->sid, DOMAIN_RID_USERS ); /* Try to fill in what the nss_info backend can do */ + info->full_name=NULL; //we cannot get this offline, so we have no hint nss_get_info_cached( domain, sid, mem_ctx, &info->homedir, &info->shell, &info->full_name, @@ -701,6 +707,9 @@ static NTSTATUS query_user(struct winbin ads_msgfree(ads, msg); msg = NULL; + /* give nss_get_info a hint */ + info->full_name = ads_name; + status = nss_get_info_cached( domain, sid, mem_ctx, &info->homedir, &info->shell, &info->full_name, &gid); @@ -713,7 +722,7 @@ static NTSTATUS query_user(struct winbin if (info->full_name == NULL) { info->full_name = ads_name; - } else { + } else if (info->full_name != ads_name) { TALLOC_FREE(ads_name); }