s3-winbindd: add wcache_query_user_fullname().
authorGünther Deschner <gd@samba.org>
Mon, 7 Jul 2014 15:14:37 +0000 (17:14 +0200)
committerGünther Deschner <gd@samba.org>
Tue, 15 Jul 2014 14:00:40 +0000 (16:00 +0200)
This helper function is used to query the full name of a cached user object (for
further gecos processing).

Thanks to Matt Rogers <mrogers@redhat.com>.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=10440

Guenther

Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Signed-off-by: Günther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/winbindd/winbindd_cache.c
source3/winbindd/winbindd_proto.h

index bfd78daef537e45a1551536677f3b958059de72b..9ec46cf924ffbc5d55ca0a04054b846a1c03c110 100644 (file)
@@ -2314,6 +2314,40 @@ NTSTATUS wcache_query_user(struct winbindd_domain *domain,
        return status;
 }
 
+
+/**
+* @brief Query a fullname from the username cache (for further gecos processing)
+*
+* @param domain                A pointer to the winbindd_domain struct.
+* @param mem_ctx       The talloc context.
+* @param user_sid      The user sid.
+* @param full_name     A pointer to the full_name string.
+*
+* @return NTSTATUS code
+*/
+NTSTATUS wcache_query_user_fullname(struct winbindd_domain *domain,
+                                   TALLOC_CTX *mem_ctx,
+                                   const struct dom_sid *user_sid,
+                                   const char **full_name)
+{
+       NTSTATUS status;
+       struct wbint_userinfo info;
+
+       status = wcache_query_user(domain, mem_ctx, user_sid, &info);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       if (info.full_name != NULL) {
+               *full_name = talloc_strdup(mem_ctx, info.full_name);
+               if (*full_name == NULL) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+       }
+
+       return NT_STATUS_OK;
+}
+
 /* Lookup user information from a rid */
 static NTSTATUS query_user(struct winbindd_domain *domain,
                           TALLOC_CTX *mem_ctx,
index e1b32b77993fe35518244fd0f8bf06c89006fd5e..42fffc0656bb4d2730065efafbd9fdd533e20a22 100644 (file)
@@ -104,6 +104,10 @@ NTSTATUS wcache_query_user(struct winbindd_domain *domain,
                           TALLOC_CTX *mem_ctx,
                           const struct dom_sid *user_sid,
                           struct wbint_userinfo *info);
+NTSTATUS wcache_query_user_fullname(struct winbindd_domain *domain,
+                                   TALLOC_CTX *mem_ctx,
+                                   const struct dom_sid *user_sid,
+                                   const char **full_name);
 NTSTATUS wcache_lookup_useraliases(struct winbindd_domain *domain,
                                   TALLOC_CTX *mem_ctx,
                                   uint32 num_sids, const struct dom_sid *sids,