The branch, master has been updated
       via  d1f980444d22e41659af0d3681f81162b914aa61 (commit)
       via  6aac05f5cec2ba2f695527d64a03d07d9b09e03a (commit)
      from  ecd2434d69407821d68a253bf9758533db3ad7c2 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit d1f980444d22e41659af0d3681f81162b914aa61
Author: Volker Lendecke <[EMAIL PROTECTED]>
Date:   Wed Oct 22 11:21:31 2008 +0200

    wbinfo --sid-to-fullname
    
    Signed-off-by: Stefan Metzmacher <[EMAIL PROTECTED]>

commit 6aac05f5cec2ba2f695527d64a03d07d9b09e03a
Author: Volker Lendecke <[EMAIL PROTECTED]>
Date:   Tue Oct 21 17:11:29 2008 +0200

    wbcGetDisplayName
    
    Signed-off-by: Stefan Metzmacher <[EMAIL PROTECTED]>

-----------------------------------------------------------------------

Summary of changes:
 source3/nsswitch/libwbclient/wbc_sid.c  |   44 +++++++++++++++++++++++++++++++
 source3/nsswitch/libwbclient/wbclient.h |    5 +++
 source3/nsswitch/wbinfo.c               |   42 ++++++++++++++++++++++++++++-
 3 files changed, 90 insertions(+), 1 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/nsswitch/libwbclient/wbc_sid.c 
b/source3/nsswitch/libwbclient/wbc_sid.c
index 54f6e70..ac929b1 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 00a3c98..662e0cd 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
  */
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index fc49be4..84f01e1 100644
--- a/source3/nsswitch/wbinfo.c
+++ b/source3/nsswitch/wbinfo.c
@@ -768,6 +768,36 @@ static bool wbinfo_lookupsid(const char *sid_str)
        return true;
 }
 
+/* Convert sid to fullname */
+
+static bool wbinfo_lookupsid_fullname(const char *sid_str)
+{
+       wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+       struct wbcDomainSid sid;
+       char *domain;
+       char *name;
+       enum wbcSidType type;
+
+       /* Send off request */
+
+       wbc_status = wbcStringToSid(sid_str, &sid);
+       if (!WBC_ERROR_IS_OK(wbc_status)) {
+               return false;
+       }
+
+       wbc_status = wbcGetDisplayName(&sid, &domain, &name, &type);
+       if (!WBC_ERROR_IS_OK(wbc_status)) {
+               return false;
+       }
+
+       /* Display response */
+
+       d_printf("%s%c%s %d\n",
+                domain, winbind_separator(), name, type);
+
+       return true;
+}
+
 /* Lookup a list of RIDs */
 
 static bool wbinfo_lookuprids(const char *domain, const char *arg)
@@ -1391,7 +1421,8 @@ enum {
        OPT_GROUP_INFO,
        OPT_VERBOSE,
        OPT_ONLINESTATUS,
-       OPT_CHANGE_USER_PASSWORD
+       OPT_CHANGE_USER_PASSWORD,
+       OPT_SID_TO_FULLNAME
 };
 
 int main(int argc, char **argv, char **envp)
@@ -1417,6 +1448,8 @@ int main(int argc, char **argv, char **envp)
                { "WINS-by-ip", 'I', POPT_ARG_STRING, &string_arg, 'I', 
"Converts IP address to NetBIOS name", "IP" },
                { "name-to-sid", 'n', POPT_ARG_STRING, &string_arg, 'n', 
"Converts name to sid", "NAME" },
                { "sid-to-name", 's', POPT_ARG_STRING, &string_arg, 's', 
"Converts sid to name", "SID" },
+               { "sid-to-fullname", 0, POPT_ARG_STRING, &string_arg,
+                 OPT_SID_TO_FULLNAME, "Converts sid to fullname", "SID" },
                { "lookup-rids", 'R', POPT_ARG_STRING, &string_arg, 'R', 
"Converts RIDs to names", "RIDs" },
                { "uid-to-sid", 'U', POPT_ARG_INT, &int_arg, 'U', "Converts uid 
to sid" , "UID" },
                { "gid-to-sid", 'G', POPT_ARG_INT, &int_arg, 'G', "Converts gid 
to sid", "GID" },
@@ -1524,6 +1557,13 @@ int main(int argc, char **argv, char **envp)
                                goto done;
                        }
                        break;
+               case OPT_SID_TO_FULLNAME:
+                       if (!wbinfo_lookupsid_fullname(string_arg)) {
+                               d_fprintf(stderr, "Could not lookup sid %s\n",
+                                         string_arg);
+                               goto done;
+                       }
+                       break;
                case 'R':
                        if (!wbinfo_lookuprids(opt_domain_name, string_arg)) {
                                d_fprintf(stderr, "Could not lookup RIDs %s\n", 
string_arg);


-- 
Samba Shared Repository

Reply via email to