s3-winbindd: prefer "displayName" over "name" in ads user queries for the fullname.
authorGünther Deschner <gd@samba.org>
Mon, 14 Jul 2014 16:22:26 +0000 (18:22 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 15 Jul 2014 14:00:40 +0000 (16:00 +0200)
This makes use more consistent with security=domain as well where the gecos
field is also filled using the displayName field.

Guenther

Signed-off-by: Guenther Deschner <gd@samba.org>
Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/winbindd/winbindd_ads.c

index acbd10b6349785e2e0c7a63a72f093c295658b7e..a869ff5314de00853355a2d4551908ae63717238 100644 (file)
@@ -329,7 +329,10 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
                }
 
                info->acct_name = ads_pull_username(ads, mem_ctx, msg);
-               info->full_name = ads_pull_string(ads, mem_ctx, msg, "name");
+               info->full_name = ads_pull_string(ads, mem_ctx, msg, "displayName");
+               if (info->full_name == NULL) {
+                       info->full_name = ads_pull_string(ads, mem_ctx, msg, "name");
+               }
                info->homedir = NULL;
                info->shell = NULL;
                info->primary_gid = (gid_t)-1;
@@ -594,7 +597,7 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
        struct netr_SamInfo3 *user = NULL;
        gid_t gid = -1;
        int ret;
-       char *ads_name;
+       char *full_name;
 
        DEBUG(3,("ads: query_user\n"));
 
@@ -706,7 +709,10 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
         * nss_get_info_cached call. nss_get_info_cached might destroy
         * the ads struct, potentially invalidating the ldap message.
         */
-       ads_name = ads_pull_string(ads, mem_ctx, msg, "name");
+       full_name = ads_pull_string(ads, mem_ctx, msg, "displayName");
+       if (full_name == NULL) {
+               full_name = ads_pull_string(ads, mem_ctx, msg, "name");
+       }
 
        ads_msgfree(ads, msg);
        msg = NULL;
@@ -722,9 +728,9 @@ static NTSTATUS query_user(struct winbindd_domain *domain,
        }
 
        if (info->full_name == NULL) {
-               info->full_name = ads_name;
+               info->full_name = full_name;
        } else {
-               TALLOC_FREE(ads_name);
+               TALLOC_FREE(full_name);
        }
 
        status = NT_STATUS_OK;