r23779: Change from v2 or later to v3 or later.
[samba.git] / source3 / rpc_server / srv_lsa.c
index e20b4e18b499c42cedfc936f3f4ba94768b8eb3b..157f819a3730e8c1cc147728fefcb26df89e13a6 100644 (file)
@@ -10,7 +10,7 @@
  *
  *  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
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
 
+static BOOL proxy_lsa_call(pipes_struct *p, uint8 opnum)
+{
+       struct api_struct *fns;
+       int n_fns;
+
+       lsarpc_get_pipe_fns(&fns, &n_fns);
+
+       if (opnum >= n_fns)
+               return False;
+
+       if (fns[opnum].opnum != opnum) {
+               smb_panic("LSA function table not sorted");
+       }
+
+       return fns[opnum].fn(p);
+}
+
 /***************************************************************************
  api_lsa_open_policy2
  ***************************************************************************/
@@ -218,28 +235,7 @@ static BOOL api_lsa_lookup_names(pipes_struct *p)
 
 static BOOL api_lsa_close(pipes_struct *p)
 {
-       LSA_Q_CLOSE q_u;
-       LSA_R_CLOSE 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_close("", &q_u, data, 0)) {
-               DEBUG(0,("api_lsa_close: lsa_io_q_close failed.\n"));
-               return False;
-       }
-
-       r_u.status = _lsa_close(p, &q_u, &r_u);
-
-       /* store the response in the SMB stream */
-       if (!lsa_io_r_close("", &r_u, rdata, 0)) {
-               DEBUG(0,("api_lsa_close: lsa_io_r_close failed.\n"));
-               return False;
-       }
-
-       return True;
+       return proxy_lsa_call(p, DCERPC_LSA_CLOSE);
 }
 
 /***************************************************************************
@@ -248,28 +244,7 @@ static BOOL api_lsa_close(pipes_struct *p)
 
 static BOOL api_lsa_open_secret(pipes_struct *p)
 {
-       LSA_Q_OPEN_SECRET q_u;
-       LSA_R_OPEN_SECRET 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_open_secret("", &q_u, data, 0)) {
-               DEBUG(0,("api_lsa_open_secret: failed to unmarshall LSA_Q_OPEN_SECRET.\n"));
-               return False;
-       }
-
-       r_u.status = _lsa_open_secret(p, &q_u, &r_u);
-
-       /* store the response in the SMB stream */
-       if(!lsa_io_r_open_secret("", &r_u, rdata, 0)) {
-               DEBUG(0,("api_lsa_open_secret: Failed to marshall LSA_R_OPEN_SECRET.\n"));
-               return False;
-       }
-
-       return True;
+       return proxy_lsa_call(p, DCERPC_LSA_OPENSECRET);
 }
 
 /***************************************************************************
@@ -771,29 +746,7 @@ static BOOL api_lsa_lookup_priv_value(pipes_struct *p)
 
 static BOOL api_lsa_open_trust_dom(pipes_struct *p)
 {
-       LSA_Q_OPEN_TRUSTED_DOMAIN q_u;
-       LSA_R_OPEN_TRUSTED_DOMAIN 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_open_trusted_domain("", &q_u, data, 0)) {
-               DEBUG(0,("api_lsa_open_trust_dom: failed to unmarshall LSA_Q_OPEN_TRUSTED_DOMAIN .\n"));
-               return False;
-       }
-
-       r_u.status = _lsa_open_trusted_domain(p, &q_u, &r_u);
-
-       /* store the response in the SMB stream */
-       if(!lsa_io_r_open_trusted_domain("", &r_u, rdata, 0)) {
-               DEBUG(0,("api_lsa_open_trust_dom: Failed to marshall LSA_R_OPEN_TRUSTED_DOMAIN.\n"));
-               return False;
-       }
-
-       return True;
+       return proxy_lsa_call(p, DCERPC_LSA_OPENTRUSTEDDOMAIN);
 }
 
 /***************************************************************************
@@ -801,29 +754,7 @@ static BOOL api_lsa_open_trust_dom(pipes_struct *p)
 
 static BOOL api_lsa_create_trust_dom(pipes_struct *p)
 {
-       LSA_Q_CREATE_TRUSTED_DOMAIN q_u;
-       LSA_R_CREATE_TRUSTED_DOMAIN 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_create_trusted_domain("", &q_u, data, 0)) {
-               DEBUG(0,("api_lsa_create_trust_dom: failed to unmarshall LSA_Q_CREATE_TRUSTED_DOMAIN .\n"));
-               return False;
-       }
-
-       r_u.status = _lsa_create_trusted_domain(p, &q_u, &r_u);
-
-       /* store the response in the SMB stream */
-       if(!lsa_io_r_create_trusted_domain("", &r_u, rdata, 0)) {
-               DEBUG(0,("api_lsa_create_trust_dom: Failed to marshall LSA_R_CREATE_TRUSTED_DOMAIN.\n"));
-               return False;
-       }
-
-       return True;
+       return proxy_lsa_call(p, DCERPC_LSA_CREATETRUSTEDDOMAIN);
 }
 
 /***************************************************************************
@@ -831,29 +762,7 @@ static BOOL api_lsa_create_trust_dom(pipes_struct *p)
 
 static BOOL api_lsa_create_secret(pipes_struct *p)
 {
-       LSA_Q_CREATE_SECRET q_u;
-       LSA_R_CREATE_SECRET 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_create_secret("", &q_u, data, 0)) {
-               DEBUG(0,("api_lsa_create_secret: failed to unmarshall LSA_Q_CREATE_SECRET.\n"));
-               return False;
-       }
-
-       r_u.status = _lsa_create_secret(p, &q_u, &r_u);
-
-       /* store the response in the SMB stream */
-       if(!lsa_io_r_create_secret("", &r_u, rdata, 0)) {
-               DEBUG(0,("api_lsa_create_secret: Failed to marshall LSA_R_CREATE_SECRET.\n"));
-               return False;
-       }
-
-       return True;
+       return proxy_lsa_call(p, DCERPC_LSA_CREATESECRET);
 }
 
 /***************************************************************************
@@ -861,29 +770,7 @@ static BOOL api_lsa_create_secret(pipes_struct *p)
 
 static BOOL api_lsa_set_secret(pipes_struct *p)
 {
-       LSA_Q_SET_SECRET q_u;
-       LSA_R_SET_SECRET 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_set_secret("", &q_u, data, 0)) {
-               DEBUG(0,("api_lsa_set_secret: failed to unmarshall LSA_Q_SET_SECRET.\n"));
-               return False;
-       }
-
-       r_u.status = _lsa_set_secret(p, &q_u, &r_u);
-
-       /* store the response in the SMB stream */
-       if(!lsa_io_r_set_secret("", &r_u, rdata, 0)) {
-               DEBUG(0,("api_lsa_set_secret: Failed to marshall LSA_R_SET_SECRET.\n"));
-               return False;
-       }
-
-       return True;
+       return proxy_lsa_call(p, DCERPC_LSA_SETSECRET);
 }
 
 /***************************************************************************
@@ -1007,6 +894,68 @@ static BOOL api_lsa_lookup_names2(pipes_struct *p)
        return True;
 }
 
+/***************************************************************************
+ api_lsa_lookup_names3
+ ***************************************************************************/
+
+static BOOL api_lsa_lookup_names3(pipes_struct *p)
+{
+       LSA_Q_LOOKUP_NAMES3 q_u;
+       LSA_R_LOOKUP_NAMES3 r_u;
+       prs_struct *data = &p->in_data.data;
+       prs_struct *rdata = &p->out_data.rdata;
+
+       ZERO_STRUCT(q_u);
+       ZERO_STRUCT(r_u);
+
+       /* grab the info class and policy handle */
+       if(!lsa_io_q_lookup_names3("", &q_u, data, 0)) {
+               DEBUG(0,("api_lsa_lookup_names3: failed to unmarshall LSA_Q_LOOKUP_NAMES3.\n"));
+               return False;
+       }
+
+       r_u.status = _lsa_lookup_names3(p, &q_u, &r_u);
+
+       /* store the response in the SMB stream */
+       if(!lsa_io_r_lookup_names3("", &r_u, rdata, 0)) {
+               DEBUG(0,("api_lsa_lookup_names3: Failed to marshall LSA_R_LOOKUP_NAMES3.\n"));
+               return False;
+       }
+
+       return True;
+}
+
+/***************************************************************************
+ api_lsa_lookup_names4
+ ***************************************************************************/
+
+static BOOL api_lsa_lookup_names4(pipes_struct *p)
+{
+       LSA_Q_LOOKUP_NAMES4 q_u;
+       LSA_R_LOOKUP_NAMES4 r_u;
+       prs_struct *data = &p->in_data.data;
+       prs_struct *rdata = &p->out_data.rdata;
+
+       ZERO_STRUCT(q_u);
+       ZERO_STRUCT(r_u);
+
+       /* grab the info class and policy handle */
+       if(!lsa_io_q_lookup_names4("", &q_u, data, 0)) {
+               DEBUG(0,("api_lsa_lookup_names4: failed to unmarshall LSA_Q_LOOKUP_NAMES4.\n"));
+               return False;
+       }
+
+       r_u.status = _lsa_lookup_names4(p, &q_u, &r_u);
+
+       /* store the response in the SMB stream */
+       if(!lsa_io_r_lookup_names4("", &r_u, rdata, 0)) {
+               DEBUG(0,("api_lsa_lookup_names4: Failed to marshall LSA_R_LOOKUP_NAMES4.\n"));
+               return False;
+       }
+
+       return True;
+}
+
 #if 0  /* AD DC work in ongoing in Samba 4 */
 
 /***************************************************************************
@@ -1078,7 +1027,9 @@ static struct api_struct api_lsa_cmds[] =
        { "LSA_DELETEOBJECT"    , LSA_DELETEOBJECT    , api_lsa_delete_object },
        { "LSA_LOOKUPSIDS2"     , LSA_LOOKUPSIDS2     , api_lsa_lookup_sids2 },
        { "LSA_LOOKUPNAMES2"    , LSA_LOOKUPNAMES2    , api_lsa_lookup_names2 },
-       { "LSA_LOOKUPSIDS3"     , LSA_LOOKUPSIDS3     , api_lsa_lookup_sids3 }
+       { "LSA_LOOKUPNAMES3"    , LSA_LOOKUPNAMES3    , api_lsa_lookup_names3 },
+       { "LSA_LOOKUPSIDS3"     , LSA_LOOKUPSIDS3     , api_lsa_lookup_sids3 },
+       { "LSA_LOOKUPNAMES4"    , LSA_LOOKUPNAMES4    , api_lsa_lookup_names4 }
 #if 0  /* AD DC work in ongoing in Samba 4 */
        /* be careful of the adding of new RPC's.  See commentrs below about
           ADS DC capabilities                                               */