]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
improved enumdomains added -i option.
authorLuke Leighton <lkcl@samba.org>
Thu, 2 Dec 1999 01:46:01 +0000 (01:46 +0000)
committerLuke Leighton <lkcl@samba.org>
Thu, 2 Dec 1999 01:46:01 +0000 (01:46 +0000)
(This used to be commit 50dc709fa95e86ebe2b3132176241cb3a2cc4e36)

source3/include/ntdomain.h
source3/include/proto.h
source3/rpc_client/msrpc_samr.c
source3/rpcclient/cmd_samr.c
source3/rpcclient/rpcclient.c

index 603dce0a17b17eb404a8e109d551555143bd6a3e..9dd6c2d3a711c352941172e4b35edf9487441285 100644 (file)
@@ -173,6 +173,8 @@ struct acct_info
 
 #define DOMAIN_FN(fn)\
        void (*fn)(const char*)
+#define DOMAIN_INFO_FN(fn)\
+       void (*fn)(const char*, const DOM_SID *, uint32, SAM_UNK_CTR *)
 
 #define USER_FN(fn)\
        void (*fn)(const char*, const DOM_SID*, uint32, const char*)
index e84607e726ac27f053406e06a331a55445f56438..fc7653009f5097ada23abc63b1ccc8de5262fe30 100644 (file)
@@ -2285,7 +2285,8 @@ BOOL req_groupmem_info( const POLICY_HND *pol_dom,
 uint32 msrpc_sam_enum_domains( const char* srv_name,
                                struct acct_info **sam,
                                uint32 *num_sam_entries,
-                               DOMAIN_FN(dom_fn));
+                               DOMAIN_FN(dom_fn),
+                               DOMAIN_INFO_FN(dom_inf_fn));
 uint32 msrpc_sam_enum_groups( const char* srv_name,
                                const char* domain,
                                const DOM_SID *sid1,
index e1392f428f1904a06a9c3fe3fd4dbf1201191913..621b218ad6dc9870210a144fed79389348659bef 100644 (file)
@@ -444,19 +444,16 @@ BOOL sam_query_dominfo(const char* srv_name,
                                &sam_pol) : False;
 
        /* connect to the domain */
-       res1 = res ? samr_open_domain( 
-                   &sam_pol, ace_perms, sid1,
+       res1 = res ? samr_open_domain( &sam_pol, ace_perms, sid1,
                    &pol_dom) : False;
 
        /* send a samr 0x8 command */
        res2 = res ? samr_query_dom_info(
                    &pol_dom, switch_value, ctr) : False;
 
-       res1 = res1 ? samr_close(
-                   &sam_pol) : False;
+       res1 = res1 ? samr_close( &sam_pol) : False;
 
-       res = res ? samr_close( 
-                   &pol_dom) : False;
+       res = res ? samr_close( &pol_dom) : False;
 
        if (res2)
        {
@@ -735,7 +732,8 @@ SAM Domains query.
 uint32 msrpc_sam_enum_domains( const char* srv_name,
                                struct acct_info **sam,
                                uint32 *num_sam_entries,
-                               DOMAIN_FN(dom_fn))
+                               DOMAIN_FN(dom_fn),
+                               DOMAIN_INFO_FN(dom_inf_fn))
 {
        BOOL res = True;
        uint32 ace_perms = 0x02000000; /* access control permissions. */
@@ -778,20 +776,22 @@ uint32 msrpc_sam_enum_domains( const char* srv_name,
                                dom_fn(domain_name);
                        }
 
-#if 0
                        if (dom_inf_fn != NULL)
                        {
-                               query_domaininfo(&sam_pol,
-                                                 domain_name,
-                                                 dom_inf_fn);
-                       }
-                       if (dom_mem_fn != NULL)
-                       {
-                               req_domainmem_info(&sam_pol,
-                                                 domain_name,
-                                                 dom_mem_fn);
+                               uint32 switch_value = 2;
+                               SAM_UNK_CTR ctr;
+                               DOM_SID dom_sid;
+                               /* connect to the domain */
+                               if (samr_query_lookup_domain( &sam_pol,
+                                                             domain_name,
+                                                             &dom_sid) &&
+                                   sam_query_dominfo(srv_name, &dom_sid,
+                                                     switch_value, &ctr))
+                               {
+                                       dom_inf_fn(domain_name, &dom_sid,
+                                                  switch_value, &ctr);
+                               }
                        }
-#endif
                }
        }
 
index 476ea08ea8fff3845b4e6d601c73eb447a8b3c0e..078d7d2cc3c7985b966631b2963bed3816407f38 100644 (file)
@@ -42,6 +42,18 @@ static void sam_display_domain(const char *domain)
        report(out_hnd, "Domain Name: %s\n", domain);
 }
 
+static void sam_display_dom_info(const char* domain, const DOM_SID *sid,
+                               uint32 switch_value,
+                               SAM_UNK_CTR *ctr)
+{
+       fstring sidstr;
+       sid_to_string(sidstr, sid);
+       report(out_hnd, "Domain Name:\t%s\tSID:\t%s\n", domain, sidstr);
+       display_sam_unk_ctr(out_hnd, ACTION_HEADER   , switch_value, ctr);
+       display_sam_unk_ctr(out_hnd, ACTION_ENUMERATE, switch_value, ctr);
+       display_sam_unk_ctr(out_hnd, ACTION_FOOTER   , switch_value, ctr);
+}
+
 static void sam_display_alias_info(const char *domain, const DOM_SID *sid,
                                uint32 alias_rid, 
                                ALIAS_INFO_CTR *const ctr)
@@ -2055,33 +2067,26 @@ void cmd_sam_query_dominfo(struct client_info *info, int argc, char *argv[])
        fstrcat(srv_name, info->dest_host);
        strupper(srv_name);
 
-
        sid_to_string(sid, &info->dom.level5_sid);
        fstrcpy(domain, info->dom.level5_dom);
 
+       string_to_sid(&sid1, sid);
+
        if (sid1.num_auths == 0)
        {
                report(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
                return;
        }
 
-       string_to_sid(&sid1, sid);
-
        if (argc > 1)
        {
                switch_value = strtoul(argv[1], (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(srv_name, &sid1, switch_value, &ctr))
        {
                DEBUG(5,("cmd_sam_query_dominfo: succeeded\n"));
-               display_sam_unk_ctr(out_hnd, ACTION_HEADER   , switch_value, &ctr);
-               display_sam_unk_ctr(out_hnd, ACTION_ENUMERATE, switch_value, &ctr);
-               display_sam_unk_ctr(out_hnd, ACTION_FOOTER   , switch_value, &ctr);
+               sam_display_dom_info(domain, &sid1, switch_value, &ctr);
        }
        else
        {
@@ -2413,7 +2418,8 @@ void cmd_sam_enum_domains(struct client_info *info, int argc, char *argv[])
 
        msrpc_sam_enum_domains(srv_name,
                    &sam, &num_sam_entries,
-                   sam_display_domain);
+                   request_domain_info ? NULL : sam_display_domain,
+                   request_domain_info ? sam_display_dom_info : NULL);
 
        if (sam != NULL)
        {
index 2339cc892b94ec668983e37b6b18d1072320ef63..ba40920a406f3680876fe6e6df59eafeb3f4c7cb 100644 (file)
@@ -758,6 +758,7 @@ static BOOL process( struct client_info *info, char *cmd_str)
                pstring pline;
                BOOL at_sym = False;
                pline[0] = 0;
+               safe_strcat(pline, "[", sizeof(pline)-1);
                if (usr.domain[0] != 0)
                {
                        safe_strcat(pline, usr.domain, sizeof(pline)-1);
@@ -775,7 +776,7 @@ static BOOL process( struct client_info *info, char *cmd_str)
                }
        
                safe_strcat(pline, cli_info.dest_host, sizeof(pline)-1);
-               safe_strcat(pline, "$ ", sizeof(pline)-1);
+               safe_strcat(pline, "]$ ", sizeof(pline)-1);
 
 #ifndef HAVE_LIBREADLINE