splitting dom info into sam_query_dominfo function
authorLuke Leighton <lkcl@samba.org>
Fri, 1 Oct 1999 18:44:33 +0000 (18:44 +0000)
committerLuke Leighton <lkcl@samba.org>
Fri, 1 Oct 1999 18:44:33 +0000 (18:44 +0000)
(This used to be commit 39c367b8e9932f64fa774b807e14416f97254312)

source3/include/proto.h
source3/rpc_parse/parse_samr.c
source3/rpcclient/cmd_samr.c

index 4326cb4762d4696ebf7cce6476ccc38e0d07465b..5172dfb495b97192f1fe6218dc3c9e3b5f180587 100644 (file)
@@ -3183,6 +3183,8 @@ int msrpc_sam_enum_users(struct client_info *info,
 void cmd_sam_enum_users(struct client_info *info);
 void cmd_sam_query_user(struct client_info *info);
 void cmd_sam_query_dispinfo(struct client_info *info);
+BOOL sam_query_dominfo(struct client_info *info, DOM_SID *sid1,
+                               uint32 switch_value, SAM_UNK_CTR *ctr);
 void cmd_sam_query_dominfo(struct client_info *info);
 void cmd_sam_enum_aliases(struct client_info *info);
 void cmd_sam_enum_groups(struct client_info *info);
index ccc9cdc183cbfedea2a2e4e7bdd5efffa5d3b53f..e5c015a6b3f99d62ce1257bf25f47da6970489ec 100644 (file)
@@ -543,11 +543,12 @@ void samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO *r_u, prs_str
        prs_align(ps);
 
        prs_uint32("ptr_0       ", ps, depth, &(r_u->ptr_0));
-       prs_uint16("switch_value", ps, depth, &(r_u->switch_value));
-       prs_align(ps);
 
        if (r_u->ptr_0 != 0 && r_u->ctr != NULL)
        {
+               prs_uint16("switch_value", ps, depth, &(r_u->switch_value));
+               prs_align(ps);
+
                switch (r_u->switch_value)
                {
                        case 0x07:
index a14c2d29bd6e4d5e9b84810b102883e53da8dacd..130790e4160eb54abcb0d9dc4f69fb3b650d8a54 100644 (file)
@@ -1666,43 +1666,20 @@ void cmd_sam_query_dispinfo(struct client_info *info)
 /****************************************************************************
 experimental SAM domain info query.
 ****************************************************************************/
-void cmd_sam_query_dominfo(struct client_info *info)
+BOOL sam_query_dominfo(struct client_info *info, DOM_SID *sid1,
+                               uint32 switch_value, SAM_UNK_CTR *ctr)
 {
        uint16 fnum;
        fstring srv_name;
-       fstring domain;
-       fstring sid;
-       DOM_SID sid1;
        BOOL res = True;
-       fstring info_str;
-       uint32 switch_value = 2;
+       BOOL res1 = True;
+       BOOL res2 = True;
        uint32 ace_perms = 0x02000000; /* absolutely no idea. */
-       SAM_UNK_CTR ctr;
-
-       sid_to_string(sid, &info->dom.level5_sid);
-       fstrcpy(domain, info->dom.level5_dom);
-
-       if (strlen(sid) == 0)
-       {
-               report(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
-               return;
-       }
-
-       string_to_sid(&sid1, sid);
 
        fstrcpy(srv_name, "\\\\");
        fstrcat(srv_name, info->dest_host);
        strupper(srv_name);
 
-       if (next_token(NULL, info_str, NULL, sizeof(info_str)))
-       {
-               switch_value = strtoul(info_str, (char**)NULL, 10);
-       }
-
-       report(out_hnd, "SAM Query Domain Info: info level %d\n", switch_value);
-       report(out_hnd, "From: %s To: %s Domain: %s SID: %s\n",
-                         info->myhostname, srv_name, domain, sid);
-
        /* open SAMR session.  negotiate credentials */
        res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, &fnum) : False;
 
@@ -1712,15 +1689,15 @@ void cmd_sam_query_dominfo(struct client_info *info)
                                &info->dom.samr_pol_connect) : False;
 
        /* connect to the domain */
-       res = res ? samr_open_domain(smb_cli, fnum, 
-                   &info->dom.samr_pol_connect, ace_perms, &sid1,
+       res1 = res ? samr_open_domain(smb_cli, fnum, 
+                   &info->dom.samr_pol_connect, ace_perms, sid1,
                    &info->dom.samr_pol_open_domain) : False;
 
        /* send a samr 0x8 command */
-       res = res ? samr_query_dom_info(smb_cli, fnum,
-                   &info->dom.samr_pol_open_domain, switch_value, &ctr) : False;
+       res2 = res ? samr_query_dom_info(smb_cli, fnum,
+                   &info->dom.samr_pol_open_domain, switch_value, ctr) : False;
 
-       res = res ? samr_close(smb_cli, fnum,
+       res1 = res1 ? samr_close(smb_cli, fnum,
                    &info->dom.samr_pol_connect) : False;
 
        res = res ? samr_close(smb_cli, fnum, 
@@ -1729,7 +1706,52 @@ void cmd_sam_query_dominfo(struct client_info *info)
        /* close the session */
        cli_nt_session_close(smb_cli, fnum);
 
-       if (res)
+       if (res2)
+       {
+               DEBUG(5,("sam_query_dominfo: succeeded\n"));
+       }
+       else
+       {
+               DEBUG(5,("sam_query_dominfo: failed\n"));
+       }
+
+       return res2;
+}
+
+
+/****************************************************************************
+experimental SAM domain info query.
+****************************************************************************/
+void cmd_sam_query_dominfo(struct client_info *info)
+{
+       fstring domain;
+       fstring sid;
+       DOM_SID sid1;
+       fstring info_str;
+       uint32 switch_value = 2;
+       SAM_UNK_CTR ctr;
+
+       sid_to_string(sid, &info->dom.level5_sid);
+       fstrcpy(domain, info->dom.level5_dom);
+
+       if (strlen(sid) == 0)
+       {
+               report(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
+               return;
+       }
+
+       string_to_sid(&sid1, sid);
+
+       if (next_token(NULL, info_str, NULL, sizeof(info_str)))
+       {
+               switch_value = strtoul(info_str, (char**)NULL, 10);
+       }
+
+       report(out_hnd, "SAM Query Domain Info: info level %d\n", switch_value);
+       report(out_hnd, "From: %s Domain: %s SID: %s\n",
+                         info->myhostname, domain, sid);
+
+       if (sam_query_dominfo(info, &sid1, switch_value, &ctr))
        {
                DEBUG(5,("cmd_sam_query_dominfo: succeeded\n"));
                display_sam_unk_ctr(out_hnd, ACTION_HEADER   , switch_value, &ctr);