]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:rpc_client: Implement dcerpc_lsa_open_policy_fallback()
authorAndreas Schneider <asn@samba.org>
Mon, 23 Oct 2023 13:35:38 +0000 (15:35 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Tue, 21 Nov 2023 11:16:37 +0000 (11:16 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/rpc_client/cli_lsarpc.c
source3/rpc_client/cli_lsarpc.h

index f4aeb582a8fad1c998c0e3d33f9ed8eb52133f18..9a9acbab323abb4d127a7c18bf15bc4cf84c4520 100644 (file)
@@ -193,6 +193,47 @@ NTSTATUS dcerpc_lsa_open_policy3(struct dcerpc_binding_handle *h,
                                      result);
 }
 
+NTSTATUS dcerpc_lsa_open_policy_fallback(struct dcerpc_binding_handle *h,
+                                        TALLOC_CTX *mem_ctx,
+                                        const char *srv_name_slash,
+                                        bool sec_qos,
+                                        uint32_t desired_access,
+                                        uint32_t *out_version,
+                                        union lsa_revision_info *out_revision_info,
+                                        struct policy_handle *pol,
+                                        NTSTATUS *result)
+{
+       NTSTATUS status;
+
+       status = dcerpc_lsa_open_policy3(h,
+                                        mem_ctx,
+                                        srv_name_slash,
+                                        sec_qos,
+                                        desired_access,
+                                        out_version,
+                                        out_revision_info,
+                                        pol,
+                                        result);
+       if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE)) {
+               *out_version = 1;
+               *out_revision_info = (union lsa_revision_info) {
+                       .info1 = {
+                               .revision = 1,
+                       }
+               };
+
+               status = dcerpc_lsa_open_policy2(h,
+                                                mem_ctx,
+                                                srv_name_slash,
+                                                sec_qos,
+                                                desired_access,
+                                                pol,
+                                                result);
+       }
+
+       return status;
+}
+
 /* Lookup a list of sids
  *
  * internal version withOUT memory allocation of the target arrays.
index 240fa6804e4174a0bc292ebff12fe58edd5a58bf..2d0c5868b22580432bf133f6846cb74b2c85720b 100644 (file)
@@ -117,6 +117,41 @@ NTSTATUS dcerpc_lsa_open_policy3(struct dcerpc_binding_handle *h,
                                 struct policy_handle *pol,
                                 NTSTATUS *result);
 
+/**
+ * @brief Open a LSA policy with fallback to previous version
+ *
+ * This first calls lsa_open_policy3 and falls back to lsa_open_policy2 in case
+ * it isn't implemented.
+ *
+ * @param[in]  h        The dcerpc binding handle to use.
+ *
+ * @param[in]  mem_ctx  The memory context to use.
+ *
+ * @param[in]  sec_qos  Enable security quality of services.
+ *
+ * @param[in]  des_access The desired access rights to be granted.
+ *
+ * @param[out]  out_version A pointer to an uin32_t to store the version of the
+ *                          following data structure.
+ *
+ * @param[out]  out_revision info A pointer to store the out_revision_info.
+ *
+ * @param[out]  pol     A pointer to a rpc policy handle.
+ *
+ * @param[out]  result  A pointer for the NDR NTSTATUS error code.
+ *
+ * @return              A corresponding NTSTATUS error code for the connection.
+ */
+NTSTATUS dcerpc_lsa_open_policy_fallback(struct dcerpc_binding_handle *h,
+                                        TALLOC_CTX *mem_ctx,
+                                        const char *srv_name_slash,
+                                        bool sec_qos,
+                                        uint32_t desired_access,
+                                        uint32_t *out_version,
+                                        union lsa_revision_info *out_revision_info,
+                                        struct policy_handle *pol,
+                                        NTSTATUS *result);
+
 /**
  * @brief Look up the names that correspond to an array of sids.
  *