summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-10-22 11:21:31 +0200
committerStefan Metzmacher <metze@samba.org>2008-10-29 13:54:52 +0100
commitd1f980444d22e41659af0d3681f81162b914aa61 (patch)
treecbeccc18befd6117426befa119d13a6af2a221bf /source3/nsswitch
parent6aac05f5cec2ba2f695527d64a03d07d9b09e03a (diff)
downloadsamba-d1f980444d22e41659af0d3681f81162b914aa61.tar.gz
samba-d1f980444d22e41659af0d3681f81162b914aa61.tar.bz2
samba-d1f980444d22e41659af0d3681f81162b914aa61.zip
wbinfo --sid-to-fullname
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/wbinfo.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c
index fc49be4314..84f01e19ff 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);