wbcGetDisplayName
authorVolker Lendecke <vl@samba.org>
Tue, 21 Oct 2008 15:11:29 +0000 (17:11 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 29 Oct 2008 12:54:51 +0000 (13:54 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
source3/nsswitch/libwbclient/wbc_sid.c
source3/nsswitch/libwbclient/wbclient.h

index 54f6e705b324831cd2386ae669db21c4e29fd7d2..ac929b1dd5276fd5d9530dd6c647e1c94103da82 100644 (file)
@@ -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;
+}
index 00a3c98966cf5f92124475332f4a179959706dbb..662e0cdf8ddccd939067c941ba2fbae6d124cf0d 100644 (file)
@@ -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
  */