From 6aac05f5cec2ba2f695527d64a03d07d9b09e03a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 21 Oct 2008 17:11:29 +0200 Subject: wbcGetDisplayName Signed-off-by: Stefan Metzmacher --- source3/nsswitch/libwbclient/wbc_sid.c | 44 +++++++++++++++++++++++++++++++++ source3/nsswitch/libwbclient/wbclient.h | 5 ++++ 2 files changed, 49 insertions(+) (limited to 'source3/nsswitch/libwbclient') diff --git a/source3/nsswitch/libwbclient/wbc_sid.c b/source3/nsswitch/libwbclient/wbc_sid.c index 54f6e705b3..ac929b1dd5 100644 --- a/source3/nsswitch/libwbclient/wbc_sid.c +++ b/source3/nsswitch/libwbclient/wbc_sid.c @@ -675,3 +675,47 @@ wbcErr wbcListGroups(const char *domain_name, } return wbc_status; } + +wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid, + char **pdomain, + char **pfullname, + enum wbcSidType *pname_type) +{ + wbcErr wbc_status; + char *domain = NULL; + char *name = NULL; + enum wbcSidType name_type; + + wbc_status = wbcLookupSid(sid, &domain, &name, &name_type); + BAIL_ON_WBC_ERROR(wbc_status); + + if (name_type == WBC_SID_NAME_USER) { + uid_t uid; + struct passwd *pwd; + + wbc_status = wbcSidToUid(sid, &uid); + BAIL_ON_WBC_ERROR(wbc_status); + + wbc_status = wbcGetpwuid(uid, &pwd); + BAIL_ON_WBC_ERROR(wbc_status); + + wbcFreeMemory(name); + + name = talloc_strdup(NULL, pwd->pw_gecos); + BAIL_ON_PTR_ERROR(name, wbc_status); + } + + wbc_status = WBC_ERR_SUCCESS; + + done: + if (WBC_ERROR_IS_OK(wbc_status)) { + *pdomain = domain; + *pfullname = name; + *pname_type = name_type; + } else { + wbcFreeMemory(domain); + wbcFreeMemory(name); + } + + return wbc_status; +} diff --git a/source3/nsswitch/libwbclient/wbclient.h b/source3/nsswitch/libwbclient/wbclient.h index 00a3c98966..662e0cdf8d 100644 --- a/source3/nsswitch/libwbclient/wbclient.h +++ b/source3/nsswitch/libwbclient/wbclient.h @@ -526,6 +526,11 @@ wbcErr wbcListGroups(const char *domain_name, uint32_t *num_groups, const char ***groups); +wbcErr wbcGetDisplayName(const struct wbcDomainSid *sid, + char **pdomain, + char **pfullname, + enum wbcSidType *pname_type); + /* * SID/uid/gid Mappings */ -- cgit