merge of working dsrolegetprimdominfo() client code from APP_HEAD
authorGerald Carter <jerry@samba.org>
Fri, 4 Oct 2002 19:11:36 +0000 (19:11 +0000)
committerGerald Carter <jerry@samba.org>
Fri, 4 Oct 2002 19:11:36 +0000 (19:11 +0000)
(This used to be commit f70caa25e4ee198151b915cf2bc0a26b2d0e243d)

13 files changed:
source3/Makefile.in
source3/include/ntdomain.h
source3/include/rpc_dce.h
source3/include/rpc_ds.h [new file with mode: 0644]
source3/include/smb.h
source3/libsmb/cliconnect.c
source3/rpc_client/cli_ds.c [new file with mode: 0644]
source3/rpc_client/cli_pipe.c
source3/rpc_parse/parse_ds.c [new file with mode: 0644]
source3/rpc_parse/parse_rpc.c
source3/rpcclient/cmd_ds.c [new file with mode: 0644]
source3/rpcclient/cmd_lsarpc.c
source3/rpcclient/rpcclient.c

index 3e884b11ede894a45dfd835714425c8e5b01f95d..11cec4a78383078251d33bc913f4cc7514b1da2a 100644 (file)
@@ -178,7 +178,8 @@ LIBMSRPC_OBJ = rpc_client/cli_lsarpc.o rpc_client/cli_samr.o \
               rpc_client/cli_netlogon.o rpc_client/cli_srvsvc.o \
               rpc_client/cli_wkssvc.o rpc_client/cli_dfs.o \
               rpc_client/cli_reg.o rpc_client/cli_pipe.o \
-              rpc_client/cli_spoolss.o rpc_client/cli_spoolss_notify.o 
+              rpc_client/cli_spoolss.o rpc_client/cli_spoolss_notify.o  \
+               rpc_client/cli_ds.o
 
 LIBMSRPC_SERVER_OBJ = libsmb/trust_passwd.o
 
@@ -205,7 +206,7 @@ RPC_PARSE_OBJ1 = rpc_parse/parse_prs.o rpc_parse/parse_sec.o \
 RPC_PARSE_OBJ = rpc_parse/parse_lsa.o rpc_parse/parse_net.o \
                 rpc_parse/parse_reg.o rpc_parse/parse_rpc.o \
                 rpc_parse/parse_samr.o rpc_parse/parse_srv.o \
-                rpc_parse/parse_wks.o \
+                rpc_parse/parse_wks.o rpc_parse/parse_ds.o \
                rpc_parse/parse_spoolss.o rpc_parse/parse_dfs.o \
                $(REGOBJS_OBJ)
 
@@ -352,7 +353,7 @@ RPCCLIENT_OBJ1 = rpcclient/rpcclient.o rpcclient/cmd_lsarpc.o \
                 rpcclient/cmd_samr.o rpcclient/cmd_spoolss.o \
                 rpcclient/cmd_netlogon.o rpcclient/cmd_srvsvc.o \
                 rpcclient/cmd_dfs.o rpcclient/cmd_reg.o \
-                rpcclient/display_sec.o
+                rpcclient/display_sec.o rpcclient/cmd_ds.o
 
 RPCCLIENT_OBJ = $(RPCCLIENT_OBJ1) \
              $(PARAM_OBJ) $(LIBSMB_OBJ) $(UBIQX_OBJ) $(LIB_OBJ) \
index ffb9c96b72528ba04a4a9fca6f75f6600be1946e..628035885e18f088abe4c4f93e4363f80a933057 100644 (file)
@@ -374,5 +374,6 @@ struct acct_info
 #include "rpc_wkssvc.h"
 #include "rpc_spoolss.h"
 #include "rpc_dfs.h"
+#include "rpc_ds.h"
 
 #endif /* _NT_DOMAIN_H */
index 61316de89ca1b85b6dcee248935507e2aafbea51..3e615dab80ade69f859f2d8df183c7bc80e99cd3 100644 (file)
@@ -89,6 +89,7 @@ enum NTLM_MESSAGE_TYPE
 
 /* Maximum PDU fragment size. */
 #define MAX_PDU_FRAG_LEN 0x1630
+/* #define MAX_PDU_FRAG_LEN 0x10b8             this is what w2k sets */
 
 /*
  * Actual structure of a DCE UUID
diff --git a/source3/include/rpc_ds.h b/source3/include/rpc_ds.h
new file mode 100644 (file)
index 0000000..c01d105
--- /dev/null
@@ -0,0 +1,91 @@
+/* 
+   Unix SMB/CIFS implementation.
+   SMB parameters and setup
+   Copyright (C) Gerald Carter                 2002
+      
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _RPC_DS_H /* _RPC_LSA_H */
+#define _RPC_DS_H 
+
+#include "rpc_misc.h"
+
+
+/* Opcodes available on PIPE_LSARPC_DS */
+
+#define DS_GETPRIMDOMINFO      0x00
+
+
+/* macros for RPC's */
+
+#define DSROLE_PRIMARY_DS_RUNNING           0x00000001
+#define DSROLE_PRIMARY_DS_MIXED_MODE        0x00000002
+#define DSROLE_UPGRADE_IN_PROGRESS          0x00000004
+#define DSROLE_PRIMARY_DOMAIN_GUID_PRESENT  0x01000000
+
+typedef struct
+{
+       uint16          machine_role;
+       uint16          unknown;                /* 0x6173 -- maybe just alignment? */
+       
+       uint32          flags;
+       
+       uint32          netbios_ptr;
+       uint32          dnsname_ptr;
+       uint32          forestname_ptr;
+       
+       GUID            domain_guid;
+       
+       UNISTR2 netbios_domain;
+       /* these 2 might be reversed in order.  I can't tell from 
+          my tests as both values are the same --jerry */
+       UNISTR2 dns_domain;
+       UNISTR2 forest_domain;
+} DSROLE_PRIMARY_DOMAIN_INFO_BASIC;
+
+typedef struct
+{
+       DSROLE_PRIMARY_DOMAIN_INFO_BASIC        *basic;
+} DS_DOMINFO_CTR;
+
+/* info levels for ds_getprimdominfo() */
+
+#define DsRolePrimaryDomainInfoBasic           1
+
+
+/* DS_Q_GETPRIMDOMINFO - DsGetPrimaryDomainInformation() request */
+typedef struct 
+{
+       uint16  level;
+} DS_Q_GETPRIMDOMINFO;
+
+/* DS_R_GETPRIMDOMINFO - DsGetPrimaryDomainInformation() response */
+typedef struct 
+{
+       uint32          ptr;
+               
+       uint16          level;
+       uint16          unknown0;       /* 0x455c -- maybe just alignment? */
+
+       DS_DOMINFO_CTR  info;
+       
+       NTSTATUS status;
+} DS_R_GETPRIMDOMINFO;
+
+
+
+
+#endif /* _RPC_DS_H */
index 5bf79b75fe6462446ef81a2b26c500b669f4d18f..b5ab504415fd3c786936a948f8ea4215ddd293ce 100644 (file)
@@ -188,7 +188,7 @@ typedef smb_ucs2_t wfstring[FSTRING_LEN];
 #define PIPE_NETDFS   "\\PIPE\\netdfs"
 
 #define PI_LSARPC              0
-#define PI_LSARPC_V2           1
+#define PI_LSARPC_DS           1
 #define PI_SAMR                        2
 #define PI_NETLOGON            3
 #define PI_SRVSVC              4
index 3951e3c7762ebe3254f1d46f15701148bbd510c5..f005ac21f39ee332d646d73adf953aa96771ec0a 100644 (file)
@@ -344,7 +344,7 @@ static BOOL cli_session_setup_nt1(struct cli_state *cli, char *user,
                /* Have plaintext orginal */
                set_signing_on_cli(cli, pass, ntpword);
        }
-
+       
        return True;
 }
 
diff --git a/source3/rpc_client/cli_ds.c b/source3/rpc_client/cli_ds.c
new file mode 100644 (file)
index 0000000..d6985bf
--- /dev/null
@@ -0,0 +1,63 @@
+/* 
+   Unix SMB/CIFS implementation.
+   RPC pipe client
+   Copyright (C) Gerald Carter                        2002,
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+
+/* implementations of client side DsXXX() functions */
+
+NTSTATUS cli_ds_getprimarydominfo( struct cli_state *cli, TALLOC_CTX *mem_ctx, 
+                                               uint16 level, DS_DOMINFO_CTR *ctr)
+{
+       prs_struct qbuf, rbuf;
+       DS_Q_GETPRIMDOMINFO q;
+       DS_R_GETPRIMDOMINFO r;
+       NTSTATUS result;
+
+       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);
+       
+       q.level = level;
+       
+       if (!ds_io_q_getprimdominfo("", &q, &qbuf, 0) 
+               || !rpc_api_pipe_req(cli, DS_GETPRIMDOMINFO, &qbuf, &rbuf)) 
+       {
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+
+       /* Unmarshall response */
+
+       if (!ds_io_r_getprimdominfo("", &r, &rbuf, 0)) {
+               result = NT_STATUS_UNSUCCESSFUL;
+               goto done;
+       }
+       
+       memcpy( ctr, &r.info, sizeof(DS_DOMINFO_CTR) );
+       result = r.status;
+       
+done:
+       return result;
+}
+
index b6b58d223786e48c362bdcf730535a5958b7c82a..2732c53e5ca7632124faa82191999fa30f9fcb74 100644 (file)
@@ -599,7 +599,7 @@ static BOOL create_rpc_bind_req(prs_struct *rpc_out, BOOL do_auth, uint32 rpc_ca
        }
 
        /* create the request RPC_HDR */
-       init_rpc_hdr(&hdr, RPC_BIND, 0x0, rpc_call_id, 
+       init_rpc_hdr(&hdr, RPC_BIND, 0x3, rpc_call_id, 
                RPC_HEADER_LEN + RPC_HDR_RB_LEN + prs_offset(&auth_info),
                auth_len);
 
diff --git a/source3/rpc_parse/parse_ds.c b/source3/rpc_parse/parse_ds.c
new file mode 100644 (file)
index 0000000..ec5ea45
--- /dev/null
@@ -0,0 +1,113 @@
+/* 
+ *  Unix SMB/CIFS implementation.
+ *  RPC Pipe client / server routines
+ *  Copyright (C) Gerald Carter                                2002
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "includes.h"
+
+static BOOL ds_io_dominfobasic( char *desc, prs_struct *ps, int depth, DSROLE_PRIMARY_DOMAIN_INFO_BASIC **basic)
+{
+       DSROLE_PRIMARY_DOMAIN_INFO_BASIC *p = *basic;
+       
+       if ( UNMARSHALLING(ps) )
+               p = *basic = (DSROLE_PRIMARY_DOMAIN_INFO_BASIC *)prs_alloc_mem(ps, sizeof(DSROLE_PRIMARY_DOMAIN_INFO_BASIC));
+               
+       if ( !p )
+               return False;
+               
+       if ( !prs_uint16("machine_role", ps, depth, &p->machine_role) )
+               return False;
+       if ( !prs_uint16("unknown", ps, depth, &p->unknown) )
+               return False;
+
+       if ( !prs_uint32("flags", ps, depth, &p->flags) )
+               return False;
+
+       if ( !prs_uint32("netbios_ptr", ps, depth, &p->netbios_ptr) )
+               return False;
+       if ( !prs_uint32("dnsname_ptr", ps, depth, &p->dnsname_ptr) )
+               return False;
+       if ( !prs_uint32("forestname_ptr", ps, depth, &p->forestname_ptr) )
+               return False;
+               
+       if ( !prs_uint8s(False, "domain_guid", ps, depth, p->domain_guid.info, GUID_SIZE) )
+               return False;
+               
+       if ( !smb_io_unistr2( "netbios_domain", &p->netbios_domain, p->netbios_ptr, ps, depth) )
+               return False;
+       if ( !smb_io_unistr2( "dns_domain", &p->dns_domain, p->dnsname_ptr, ps, depth) )
+               return False;
+       if ( !smb_io_unistr2( "forest_domain", &p->forest_domain, p->forestname_ptr, ps, depth) )
+               return False;
+               
+       return True;
+               
+}
+
+BOOL ds_io_q_getprimdominfo( char *desc, DS_Q_GETPRIMDOMINFO *q_u, prs_struct *ps, int depth)
+{
+       prs_debug(ps, depth, desc, "ds_io_q_getprimdominfo");
+       depth++;
+
+       if(!prs_align(ps))
+               return False;
+
+       if ( !prs_uint16( "level", ps, depth, &q_u->level ) )
+               return False;
+               
+       return True;
+}
+
+BOOL ds_io_r_getprimdominfo( char *desc, DS_R_GETPRIMDOMINFO *r_u, prs_struct *ps, int depth)
+{
+       prs_debug(ps, depth, desc, "ds_io_r_getprimdominfo");
+       depth++;
+
+       if(!prs_align(ps))
+               return False;
+
+       if ( !prs_uint32( "ptr", ps, depth, &r_u->ptr ) )
+               return False;
+               
+       if ( r_u->ptr )
+       {
+               if ( !prs_uint16( "level", ps, depth, &r_u->level ) )
+                       return False;
+       
+               if ( !prs_uint16( "unknown0", ps, depth, &r_u->unknown0 ) )
+                       return False;
+               
+               switch ( r_u->level )
+               {
+                       case DsRolePrimaryDomainInfoBasic:
+                               if ( !ds_io_dominfobasic( "dominfobasic", ps, depth, &r_u->info.basic ) )
+                                       return False;
+                               break;
+                       default:
+                               return False;
+               }
+       }
+
+       if ( !prs_align(ps) )
+               return False;
+       
+       if ( !prs_ntstatus("status", ps, depth, &r_u->status ) )
+               return False;           
+               
+       return True;
+}
index 590268bed5501a204f398dc0dadeb7a939fa3860..247c83aecd55fd3417abfd9eb0379863bd227530 100644 (file)
@@ -75,7 +75,7 @@ interface/version dce/rpc pipe identification
        }, 0x00                             \
 }
 
-#define SYNT_LSARPC_V0_WIN2K                \
+#define SYNT_LSARPC_V0_DS                \
 {                                           \
        {                                   \
                0x3919286a, 0xb10c, 0x11d0, \
@@ -147,7 +147,7 @@ struct pipe_id_info pipe_names [] =
 {
        /* client pipe , abstract syntax       , server pipe   , transfer syntax */
        { PIPE_LSARPC  , SYNT_LSARPC_V0        , PIPE_LSASS    , TRANS_SYNT_V2 },
-       { PIPE_LSARPC  , SYNT_LSARPC_V0_WIN2K  , PIPE_LSASS    , TRANS_SYNT_V2 },
+       { PIPE_LSARPC  , SYNT_LSARPC_V0_DS     , PIPE_LSASS    , TRANS_SYNT_V2 },
        { PIPE_SAMR    , SYNT_SAMR_V1          , PIPE_LSASS    , TRANS_SYNT_V2 },
        { PIPE_NETLOGON, SYNT_NETLOGON_V1      , PIPE_LSASS    , TRANS_SYNT_V2 },
        { PIPE_SRVSVC  , SYNT_SRVSVC_V3        , PIPE_NTSVCS   , TRANS_SYNT_V2 },
diff --git a/source3/rpcclient/cmd_ds.c b/source3/rpcclient/cmd_ds.c
new file mode 100644 (file)
index 0000000..9a2114e
--- /dev/null
@@ -0,0 +1,59 @@
+/* 
+   Unix SMB/CIFS implementation.
+   RPC pipe client
+
+   Copyright (C) Gerald Carter 2002
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "rpcclient.h"
+
+/* Look up domain related information on a remote host */
+
+static NTSTATUS cmd_ds_dsrole_getprimarydominfo(struct cli_state *cli, 
+                                    TALLOC_CTX *mem_ctx, int argc, 
+                                    char **argv) 
+{
+       NTSTATUS result;
+       DS_DOMINFO_CTR  ctr;
+       
+       result = cli_ds_getprimarydominfo( cli, mem_ctx, DsRolePrimaryDomainInfoBasic, &ctr );
+       if ( NT_STATUS_IS_OK(result) )
+       {
+               printf ("Machine Role = [%d]\n", ctr.basic->machine_role);
+               
+               if ( ctr.basic->flags & DSROLE_PRIMARY_DS_RUNNING )     {
+                       printf( "Directory Service is running.\n");
+                       printf( "Domain is in %s mode.\n", (ctr.basic->flags & DSROLE_PRIMARY_DS_MIXED_MODE) ? "mized" : "native" );
+               }
+               else
+                       printf( "Directory Service not running on server\n");
+       }
+       
+       return result;
+}
+
+/* List of commands exported by this module */
+
+struct cmd_set ds_commands[] = {
+
+       { "LSARPC-DS" },
+
+       { "dsroledominfo",      cmd_ds_dsrole_getprimarydominfo,       PI_LSARPC_DS, "Get Primary Domain Information", "" },
+
+       { NULL }
+};
index af5bb2066bd7439ea726c9fc895e8a0d518282ce..8eb8ce8754778f46bc70b6f8a120b996585b9943 100644 (file)
@@ -525,13 +525,6 @@ static NTSTATUS cmd_lsa_query_secobj(struct cli_state *cli,
 }
 
 
-static NTSTATUS cmd_lsa_dsrole_getprimarydominfo(struct cli_state *cli,
-                                       TALLOC_CTX *mem_ctx, int argc,
-                                       char **argv)
-{
-       return NT_STATUS_OK;
-}
-
 /* List of commands exported by this module */
 
 struct cmd_set lsarpc_commands[] = {
@@ -548,7 +541,6 @@ struct cmd_set lsarpc_commands[] = {
        { "lsaenumprivsaccount", cmd_lsa_enum_privsaccounts, PI_LSARPC, "Enumerate the privileges of an SID",   "" },
        { "lsalookupprivvalue",  cmd_lsa_lookupprivvalue,    PI_LSARPC, "Get a privilege value given its name", "" },
        { "lsaquerysecobj",      cmd_lsa_query_secobj,       PI_LSARPC, "Query LSA security object", "" },
-       { "lsarpcbind",         cmd_lsa_dsrole_getprimarydominfo,       PI_LSARPC_V2, "Test 2k UUID in rpc bind", "" },
 
        { NULL }
 };
index 9c6cd3794b4be473af3db6b814c94b69a7a6418e..c34f3b08ad90619d75a63e55ed8ae608e02c6e73 100644 (file)
@@ -402,10 +402,12 @@ extern struct cmd_set netlogon_commands[];
 extern struct cmd_set srvsvc_commands[];
 extern struct cmd_set dfs_commands[];
 extern struct cmd_set reg_commands[];
+extern struct cmd_set ds_commands[];
 
 static struct cmd_set *rpcclient_command_list[] = {
        rpcclient_commands,
        lsarpc_commands,
+       ds_commands,
        samr_commands,
        spoolss_commands,
        netlogon_commands,