Re: [PATCH]SAMR_LOOKUP_DOMAIN functionality in rpcclient

2003-03-28 Thread amber palekar
Ooops, wrong patch in the earlier mail.

Please find the correct patch here.

Cheers,
Amber.


--- message from amber palekar <[EMAIL PROTECTED]> attached:

_

free webspace & email - http://www.nu3.net

_
Select your own custom email address for FREE! Get [EMAIL PROTECTED] w/No Ads, 6MB, 
POP & more! http://www.everyone.net/selectmail?campaign=tag
*** /home/apalekar/tmp/source/rpcclient/cmd_samr.c  Thu Mar  6 13:59:58 2003
--- rpcclient/cmd_samr.cFri 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 */
+ 
--- Begin Message ---
Hi All,

I wanted to test the server SAMR_LOOOKUP_DOMAIN functionality in samba3.0 which made 
me add the client functionality for the same in rpcclient which was not present(also I 
cudnt think abt any scenarios where it wud be genearted ). This is a _trivial_ patch 
to adding the client side functioning using two functions :

cli_samr_lookup_domain
cmd_samr_lookup_domain

Could u pls comment( /apply it :-) ? 

Cheers,
Amber.
P.S. Use: patch -p0 



_

free webspace & email - http://www.nu3.net

_
Select your own custom email address for FREE! Get [EMAIL PROTECTED] w/No Ads, 6MB, 
POP & more! http://www.everyone.net/selectmail?campaign=tag
*** /home/apalekar/tm

[PATCH]SAMR_LOOKUP_DOMAIN functionality in rpcclient

2003-03-28 Thread amber palekar
Hi All,

I wanted to test the server SAMR_LOOOKUP_DOMAIN functionality in samba3.0 which made 
me add the client functionality for the same in rpcclient which was not present(also I 
cudnt think abt any scenarios where it wud be genearted ). This is a _trivial_ patch 
to adding the client side functioning using two functions :

cli_samr_lookup_domain
cmd_samr_lookup_domain

Could u pls comment( /apply it :-) ? 

Cheers,
Amber.
P.S. Use: patch -p0 



_

free webspace & email - http://www.nu3.net

_
Select your own custom email address for FREE! Get [EMAIL PROTECTED] w/No Ads, 6MB, 
POP & more! http://www.everyone.net/selectmail?campaign=tag
*** /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:47:56 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 */
+ 
*** /home/apalekar/tmp/source/rpcclient/cmd_samr.c  Thu Mar  6 13:59:58 2003
--- rpcclient/cmd_samr.cFri Mar 28 00:49:04 2003
***
*** 1399,1404 
--- 1399,1454 
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 0 
+   if ((argc < 2) || (argc > 4)) {
+   printf("Usage: %s rid [info level] [access mask] \n", argv[0]);
+   return NT_STATUS_OK;
+   }
+ #endif
+   
+   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)) {
+  DEBUG(0,("SAMR_LOOKUP_DOMAIN: Domain Name: %s Domain SID: 
%s\n",domain_name,sid_string));
+  goto done;
+   }
+   
+   
+ done:
+   return result;
+ }
+ 
  
  /* List of commands exported by this module */
  
***
*** 1424,1428 
--- 1474,1479 
{ "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 }
  };