Added LsaGetConnectedCredentials patch from Manoj Naik <manoj@almaden.ibm.com>.
authorJeremy Allison <jra@samba.org>
Fri, 29 Jun 2001 23:12:55 +0000 (23:12 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 29 Jun 2001 23:12:55 +0000 (23:12 +0000)
Jeremy.
(This used to be commit 7079300da6dbd950e55dc5871851250d5a3717ff)

source3/include/rpc_lsa.h
source3/rpc_parse/parse_lsa.c
source3/rpc_server/srv_lsa.c
source3/rpc_server/srv_lsa_nt.c

index ad7fa31365e844d2a4cac8b20dd9523fd5b5b944..1a6e178068aa73694a40863ce0bd3b4ba5b74199 100644 (file)
@@ -48,6 +48,7 @@ enum SID_NAME_USE
 #define LSA_OPENPOLICY         0x06
 #define LSA_OPENPOLICY2        0x2c
 #define LSA_OPENSECRET         0x1C
+#define LSA_UNK_GET_CONNUSER   0x2d /* LsaGetConnectedCredentials ? */
 
 /* XXXX these are here to get a compile! */
 #define LSA_LOOKUPRIDS      0xFD
@@ -380,4 +381,31 @@ typedef struct lsa_r_open_secret
        uint32 status;
 } LSA_R_OPEN_SECRET;
 
+/* LSA_Q_UNK_GET_CONNUSER - gets username\domain of connected user
+                  called when "Take Ownership" is clicked -SK */
+typedef struct lsa_q_unk_get_connuser
+{
+  uint32 ptr_srvname;
+  UNISTR2 uni2_srvname;
+  uint32 unk1; /* 3 unknown uint32's are seen right after uni2_srvname */
+  uint32 unk2; /* unk2 appears to be a ptr, unk1 = unk3 = 0 usually */
+  uint32 unk3; 
+} LSA_Q_UNK_GET_CONNUSER;
+
+/* LSA_R_UNK_GET_CONNUSER */
+typedef struct lsa_r_unk_get_connuser
+{
+  uint32 ptr_user_name;
+  UNIHDR hdr_user_name;
+  UNISTR2 uni2_user_name;
+  
+  uint32 unk1;
+  
+  uint32 ptr_dom_name;
+  UNIHDR hdr_dom_name;
+  UNISTR2 uni2_dom_name;
+
+  uint32 status;
+} LSA_R_UNK_GET_CONNUSER;
+
 #endif /* _RPC_LSA_H */
index 18ed6943eca439e6ec0a493ee3ed3f1e40ac5fa7..5abcfb9eef88d0463f512b78823da4e024dd1ec9 100644 (file)
@@ -1281,3 +1281,73 @@ BOOL lsa_io_r_open_secret(char *desc, LSA_R_OPEN_SECRET *r_c, prs_struct *ps, in
 
        return True;
 }
+
+/*******************************************************************
+ Reads or writes an LSA_Q_UNK_GET_CONNUSER structure.
+********************************************************************/
+
+BOOL lsa_io_q_unk_get_connuser(char *desc, LSA_Q_UNK_GET_CONNUSER *q_c, prs_struct *ps, int depth)
+{
+       prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser");
+       depth++;
+
+       if(!prs_align(ps))
+               return False;
+   
+       if(!prs_uint32("ptr_srvname", ps, depth, &q_c->ptr_srvname))
+               return False;
+
+       if(!smb_io_unistr2("uni2_srvname", &q_c->uni2_srvname, q_c->ptr_srvname, ps, depth)) /* server name to be looked up */
+               return False;
+
+       if(!prs_uint32("unk1", ps, depth, &q_c->unk1))
+               return False;
+       if(!prs_uint32("unk2", ps, depth, &q_c->unk2))
+               return False;
+       if(!prs_uint32("unk3", ps, depth, &q_c->unk3))
+               return False;
+
+       /* Don't bother to read or write at present... */
+       return True;
+}
+
+/*******************************************************************
+ Reads or writes an LSA_R_UNK_GET_CONNUSER structure.
+********************************************************************/
+
+BOOL lsa_io_r_unk_get_connuser(char *desc, LSA_R_UNK_GET_CONNUSER *r_c, prs_struct *ps, int depth)
+{
+       prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser");
+       depth++;
+
+       if(!prs_align(ps))
+               return False;
+   
+       if(!prs_uint32("ptr_user_name", ps, depth, &r_c->ptr_user_name))
+               return False;
+       if(!smb_io_unihdr("hdr_user_name", &r_c->hdr_user_name, ps, depth))
+               return False;
+       if(!smb_io_unistr2("uni2_user_name", &r_c->uni2_user_name, r_c->ptr_user_name, ps, depth))
+               return False;
+
+       if (!prs_align(ps))
+         return False;
+       
+       if(!prs_uint32("unk1", ps, depth, &r_c->unk1))
+               return False;
+
+       if(!prs_uint32("ptr_dom_name", ps, depth, &r_c->ptr_dom_name))
+               return False;
+       if(!smb_io_unihdr("hdr_dom_name", &r_c->hdr_dom_name, ps, depth))
+               return False;
+       if(!smb_io_unistr2("uni2_dom_name", &r_c->uni2_dom_name, r_c->ptr_dom_name, ps, depth))
+               return False;
+
+       if (!prs_align(ps))
+         return False;
+       
+       if(!prs_uint32("status", ps, depth, &r_c->status))
+               return False;
+
+       return True;
+}
index b6a8c745a45867e06f1fbd3c8714882cc1203777..005398924ee1dd84b9fa2964a8e94e62b93bb5b0 100644 (file)
@@ -268,6 +268,37 @@ static BOOL api_lsa_open_secret(pipes_struct *p)
        return True;
 }
 
+/***************************************************************************
+ api_lsa_UNK_GET_CONNUSER
+ ***************************************************************************/
+
+static BOOL api_lsa_unk_get_connuser(pipes_struct *p)
+{
+       LSA_Q_UNK_GET_CONNUSER q_u;
+       LSA_R_UNK_GET_CONNUSER r_u;
+       
+       prs_struct *data = &p->in_data.data;
+       prs_struct *rdata = &p->out_data.rdata;
+
+       ZERO_STRUCT(q_u);
+       ZERO_STRUCT(r_u);
+
+       if(!lsa_io_q_unk_get_connuser("", &q_u, data, 0)) {
+               DEBUG(0,("api_lsa_unk_get_connuser: failed to unmarshall LSA_Q_UNK_GET_CONNUSER.\n"));
+               return False;
+       }
+
+       r_u.status = _lsa_unk_get_connuser(p, &q_u, &r_u);
+
+       /* store the response in the SMB stream */
+       if(!lsa_io_r_unk_get_connuser("", &r_u, rdata, 0)) {
+               DEBUG(0,("api_lsa_unk_get_connuser: Failed to marshall LSA_R_UNK_GET_CONNUSER.\n"));
+               return False;
+       }
+
+       return True;
+}
+
 /***************************************************************************
  \PIPE\ntlsa commands
  ***************************************************************************/
@@ -282,6 +313,7 @@ static struct api_struct api_lsa_cmds[] =
        { "LSA_OPENSECRET"      , LSA_OPENSECRET      , api_lsa_open_secret    },
        { "LSA_LOOKUPSIDS"      , LSA_LOOKUPSIDS      , api_lsa_lookup_sids    },
        { "LSA_LOOKUPNAMES"     , LSA_LOOKUPNAMES     , api_lsa_lookup_names   },
+       { "LSA_UNK_GET_CONNUSER", LSA_UNK_GET_CONNUSER, api_lsa_unk_get_connuser},
        { NULL                  , 0                   , NULL                   }
 };
 
index 6e501df414df1d71552e7e4c6e5f4dd7887238e0..afcace3f9c83c549ecf48c97af006cbdeeea320e 100644 (file)
@@ -519,3 +519,33 @@ uint32 _lsa_open_secret(pipes_struct *p, LSA_Q_OPEN_SECRET *q_u, LSA_R_OPEN_SECR
 {
        return NT_STATUS_OBJECT_NAME_NOT_FOUND;
 }
+
+uint32 _lsa_unk_get_connuser(pipes_struct *p, LSA_Q_UNK_GET_CONNUSER *q_u, LSA_R_UNK_GET_CONNUSER *r_u)
+{
+  fstring username, domname;
+  int ulen, dlen;
+  user_struct *vuser = get_valid_user_struct(p->vuid);
+  
+  if (vuser == NULL)
+    return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
+  
+  fstrcpy(username, vuser->user.smb_name);
+  fstrcpy(domname, vuser->user.domain);
+  
+  ulen = strlen(username);
+  dlen = strlen(domname);
+  
+  init_uni_hdr(&r_u->hdr_user_name, ulen);
+  r_u->ptr_user_name = 1;
+  init_unistr2(&r_u->uni2_user_name, username, ulen);
+
+  r_u->unk1 = 1;
+  
+  init_uni_hdr(&r_u->hdr_dom_name, dlen);
+  r_u->ptr_dom_name = 1;
+  init_unistr2(&r_u->uni2_dom_name, domname, dlen);
+
+  r_u->status = NT_STATUS_NO_PROBLEMO;
+  
+  return r_u->status;
+}