diff options
author | Volker Lendecke <vl@samba.org> | 2008-10-21 17:11:29 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-10-29 13:54:51 +0100 |
commit | 6aac05f5cec2ba2f695527d64a03d07d9b09e03a (patch) | |
tree | cf33b2fc03c5f02ba3da1ac4d97fe85d7da978f9 /source3 | |
parent | ecd2434d69407821d68a253bf9758533db3ad7c2 (diff) | |
download | samba-6aac05f5cec2ba2f695527d64a03d07d9b09e03a.tar.gz samba-6aac05f5cec2ba2f695527d64a03d07d9b09e03a.tar.bz2 samba-6aac05f5cec2ba2f695527d64a03d07d9b09e03a.zip |
wbcGetDisplayName
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/nsswitch/libwbclient/wbc_sid.c | 44 | ||||
-rw-r--r-- | source3/nsswitch/libwbclient/wbclient.h | 5 |
2 files changed, 49 insertions, 0 deletions
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 */ |