2 * Unix SMB/CIFS implementation.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "rpcclient.h"
20 #include "../librpc/gen_ndr/ndr_unixinfo_c.h"
21 #include "libcli/security/dom_sid.h"
23 static NTSTATUS cmd_unixinfo_uidtosid(
24 struct rpc_pipe_client *cli,
29 struct dcerpc_binding_handle *b = cli->binding_handle;
31 struct dom_sid sid = { .sid_rev_num = 0, };
32 struct dom_sid_buf buf;
33 NTSTATUS status, result;
36 printf("Usage: %s [uid]\n", argv[0]);
41 status = dcerpc_unixinfo_UidToSid(b, mem_ctx, uid, &sid, &result);
42 if (!NT_STATUS_IS_OK(status)) {
44 "dcerpc_unixinfo_UidToSid failed: %s\n",
48 if (!NT_STATUS_IS_OK(result)) {
50 "dcerpc_unixinfo_UidToSid returned: %s\n",
56 printf("UidToSid(%"PRIu64")=%s\n",
58 dom_sid_str_buf(&sid, &buf));
64 static NTSTATUS cmd_unixinfo_getpwuid(
65 struct rpc_pipe_client *cli,
70 struct dcerpc_binding_handle *b = cli->binding_handle;
73 struct unixinfo_GetPWUidInfo infos = { .homedir = NULL, };
74 NTSTATUS status, result;
77 printf("Usage: %s [uid]\n", argv[0]);
82 status = dcerpc_unixinfo_GetPWUid(
83 b, mem_ctx, &count, &uids, &infos, &result);
84 if (!NT_STATUS_IS_OK(status)) {
88 if (!NT_STATUS_IS_OK(status)) {
90 "dcerpc_unixinfo_GetPWUid failed: %s\n",
94 if (!NT_STATUS_IS_OK(result)) {
96 "dcerpc_unixinfo_GetPWUid returned: %s\n",
101 printf("status=%s, homedir=%s, shell=%s\n",
102 nt_errstr(infos.status),
110 /* List of commands exported by this module */
112 struct cmd_set unixinfo_commands[] = {
120 .returntype = RPC_RTYPE_NTSTATUS,
121 .ntfn = cmd_unixinfo_getpwuid,
123 .table = &ndr_table_unixinfo,
125 .description = "Get shell and homedir",
130 .returntype = RPC_RTYPE_NTSTATUS,
131 .ntfn = cmd_unixinfo_uidtosid,
133 .table = &ndr_table_unixinfo,
135 .description = "Convert uid to sid",