[PATCH]SAMR_LOOKUP_DOMAIN functionality in rpcclient
amber palekar
amber at nu3.net
Fri Mar 28 10:23:21 GMT 2003
Ooops, wrong patch in the earlier mail.
Please find the correct patch here.
Cheers,
Amber.
--- message from amber palekar <amber at nu3.net> attached:
_____________________________________________________________
----------------------------------------
free webspace & email - http://www.nu3.net
_____________________________________________________________
Select your own custom email address for FREE! Get you at yourchoice.com w/No Ads, 6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag
-------------- next part --------------
*** /home/apalekar/tmp/source/rpcclient/cmd_samr.c Thu Mar 6 13:59:58 2003
--- rpcclient/cmd_samr.c Fri Mar 28 01:21:08 2003
***************
*** 1399,1404 ****
--- 1399,1450 ----
return result;
}
+ /**********************************************************************
+ *
+ */
+ static NTSTATUS cmd_samr_lookup_domain(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx,
+ int argc, char **argv)
+ {
+ POLICY_HND connect_pol, domain_pol, user_pol;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
+ fstring domain_name,sid_string;
+ DOM_SID sid;
+
+
+ if (argc != 2) {
+ printf("Usage: %s domain_name\n", argv[0]);
+ return NT_STATUS_OK;
+ }
+
+ sscanf(argv[1], "%s", domain_name);
+
+ result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol);
+
+ if (!NT_STATUS_IS_OK(result))
+ goto done;
+
+ result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid, &domain_pol);
+
+ if (!NT_STATUS_IS_OK(result))
+ goto done;
+
+ result = cli_samr_lookup_domain(cli,mem_ctx,&connect_pol,domain_name,&sid);
+
+ sid_to_string(sid_string,&sid);
+
+ if (NT_STATUS_IS_OK(result))
+ printf("SAMR_LOOKUP_DOMAIN: Domain Name: %s Domain SID: %s\n",domain_name,sid_string);
+
+
+ done:
+ return result;
+ }
+
/* List of commands exported by this module */
***************
*** 1424,1428 ****
--- 1470,1475 ----
{ "samquerysecobj", cmd_samr_query_sec_obj, PI_SAMR, "Query SAMR security object", "" },
{ "getdompwinfo", cmd_samr_get_dom_pwinfo, PI_SAMR, "Retrieve domain password info", "" },
+ { "lookupdomain", cmd_samr_lookup_domain, PI_SAMR, "Lookup Domain Name", "" },
{ NULL }
};
*** /home/apalekar/tmp/source/rpc_client/cli_samr.c Thu Mar 6 13:59:58 2003
--- rpc_client/cli_samr.c Fri Mar 28 00:52:55 2003
***************
*** 1449,1451 ****
--- 1449,1498 ----
return result;
}
+
+ /* Lookup Domain Name */
+
+ NTSTATUS cli_samr_lookup_domain(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *user_pol, fstring domain_name,
+ DOM_SID *sid)
+ {
+ prs_struct qbuf, rbuf;
+ SAMR_Q_LOOKUP_DOMAIN q;
+ SAMR_R_LOOKUP_DOMAIN r;
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise parse structures */
+
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
+
+ /* Marshall data and send request */
+
+ init_samr_q_lookup_domain(&q, user_pol, domain_name);
+
+ if (!samr_io_q_lookup_domain("", &q, &qbuf, 0) ||
+ !rpc_api_pipe_req(cli, SAMR_LOOKUP_DOMAIN, &qbuf, &rbuf))
+ goto done;
+
+ /* Unmarshall response */
+
+ if (!samr_io_r_lookup_domain("", &r, &rbuf, 0))
+ goto done;
+
+ /* Return output parameters */
+
+ result = r.status;
+ sid_copy(sid,&(r.dom_sid.sid));
+
+ done:
+ prs_mem_free(&qbuf);
+ prs_mem_free(&rbuf);
+
+ return result;
+ }
+
+ /* Lookup Domain Name */
+
-------------- next part --------------
An embedded message was scrubbed...
From: amber palekar <amber at nu3.net>
Subject: [PATCH]SAMR_LOOKUP_DOMAIN functionality in rpcclient
Date: Fri, 28 Mar 2003 01:09:29 -0800 (PST)
Size: 7989
Url: http://lists.samba.org/archive/samba-technical/attachments/20030328/2bad5f76/attachment.eml
More information about the samba-technical
mailing list