s3-talloc Change TALLOC_ARRAY() to talloc_array()
[samba.git] / source3 / rpc_client / cli_lsarpc.c
index 6b5d7f82d4a4beb997d4eb2113d05524359080e0..66192bdf54f9ec8c8c51c121518731fb7e0aea33 100644 (file)
@@ -23,7 +23,8 @@
 */
 
 #include "includes.h"
-#include "../librpc/gen_ndr/cli_lsa.h"
+#include "rpc_client/rpc_client.h"
+#include "../librpc/gen_ndr/ndr_lsa_c.h"
 #include "rpc_client/cli_lsarpc.h"
 #include "rpc_client/init_lsa.h"
 #include "../libcli/security/security.h"
@@ -144,12 +145,13 @@ NTSTATUS rpccli_lsa_open_policy2(struct rpc_pipe_client *cli,
        NTSTATUS status;
        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
 
-       status = dcerpc_lsa_open_policy(cli->binding_handle,
-                                       mem_ctx,
-                                       sec_qos,
-                                       des_access,
-                                       pol,
-                                       &result);
+       status = dcerpc_lsa_open_policy2(cli->binding_handle,
+                                        mem_ctx,
+                                        cli->srv_name_slash,
+                                        sec_qos,
+                                        des_access,
+                                        pol,
+                                        &result);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -160,7 +162,7 @@ NTSTATUS rpccli_lsa_open_policy2(struct rpc_pipe_client *cli,
 /* Lookup a list of sids
  *
  * internal version withOUT memory allocation of the target arrays.
- * this assumes suffciently sized arrays to store domains, names and types. */
+ * this assumes sufficiently sized arrays to store domains, names and types. */
 
 static NTSTATUS dcerpc_lsa_lookup_sids_noalloc(struct dcerpc_binding_handle *h,
                                               TALLOC_CTX *mem_ctx,
@@ -185,7 +187,7 @@ static NTSTATUS dcerpc_lsa_lookup_sids_noalloc(struct dcerpc_binding_handle *h,
        ZERO_STRUCT(lsa_names);
 
        sid_array.num_sids = num_sids;
-       sid_array.sids = TALLOC_ARRAY(mem_ctx, struct lsa_SidPtr, num_sids);
+       sid_array.sids = talloc_array(mem_ctx, struct lsa_SidPtr, num_sids);
        if (sid_array.sids == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -210,10 +212,10 @@ static NTSTATUS dcerpc_lsa_lookup_sids_noalloc(struct dcerpc_binding_handle *h,
                                                &lsa_names2,
                                                level,
                                                &count,
-                                               0,
-                                               0,
+                                               LSA_LOOKUP_OPTION_SEARCH_ISOLATED_NAMES,
+                                               LSA_CLIENT_REVISION_2,
                                                &result);
-               if (NT_STATUS_IS_OK(status)) {
+               if (!NT_STATUS_IS_OK(status)) {
                        return status;
                }
 
@@ -337,7 +339,7 @@ static NTSTATUS dcerpc_lsa_lookup_sids_generic(struct dcerpc_binding_handle *h,
                                               bool use_lookupsids3,
                                               NTSTATUS *presult)
 {
-       NTSTATUS status;
+       NTSTATUS status = NT_STATUS_OK;
        NTSTATUS result = NT_STATUS_OK;
        int sids_left = 0;
        int sids_processed = 0;
@@ -352,21 +354,21 @@ static NTSTATUS dcerpc_lsa_lookup_sids_generic(struct dcerpc_binding_handle *h,
        bool have_unmapped = false;
 
        if (num_sids) {
-               if (!(domains = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
+               if (!(domains = talloc_array(mem_ctx, char *, num_sids))) {
                        DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
-                       result = NT_STATUS_NO_MEMORY;
+                       status = NT_STATUS_NO_MEMORY;
                        goto fail;
                }
 
-               if (!(names = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
+               if (!(names = talloc_array(mem_ctx, char *, num_sids))) {
                        DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
-                       result = NT_STATUS_NO_MEMORY;
+                       status = NT_STATUS_NO_MEMORY;
                        goto fail;
                }
 
-               if (!(types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_sids))) {
+               if (!(types = talloc_array(mem_ctx, enum lsa_SidType, num_sids))) {
                        DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
-                       result = NT_STATUS_NO_MEMORY;
+                       status = NT_STATUS_NO_MEMORY;
                        goto fail;
                }
        }
@@ -378,7 +380,7 @@ static NTSTATUS dcerpc_lsa_lookup_sids_generic(struct dcerpc_binding_handle *h,
 
        while (sids_left > 0) {
                int hunk_num_sids;
-               NTSTATUS hunk_result;
+               NTSTATUS hunk_result = NT_STATUS_UNSUCCESSFUL;
 
                hunk_num_sids = ((sids_left > LOOKUP_SIDS_HUNK_SIZE)
                                ? LOOKUP_SIDS_HUNK_SIZE
@@ -587,7 +589,7 @@ static NTSTATUS dcerpc_lsa_lookup_names_generic(struct dcerpc_binding_handle *h,
        ZERO_STRUCT(sid_array);
        ZERO_STRUCT(sid_array3);
 
-       lsa_names = TALLOC_ARRAY(mem_ctx, struct lsa_String, num_names);
+       lsa_names = talloc_array(mem_ctx, struct lsa_String, num_names);
        if (lsa_names == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
@@ -605,8 +607,8 @@ static NTSTATUS dcerpc_lsa_lookup_names_generic(struct dcerpc_binding_handle *h,
                                                 &sid_array3,
                                                 level,
                                                 &count,
-                                                0,
-                                                0,
+                                                LSA_LOOKUP_OPTION_SEARCH_ISOLATED_NAMES,
+                                                LSA_CLIENT_REVISION_2,
                                                 presult);
        } else {
                status = dcerpc_lsa_LookupNames(h,
@@ -637,20 +639,20 @@ static NTSTATUS dcerpc_lsa_lookup_names_generic(struct dcerpc_binding_handle *h,
        }
 
        if (num_names) {
-               if (!((*sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, num_names)))) {
+               if (!((*sids = talloc_array(mem_ctx, struct dom_sid, num_names)))) {
                        DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
                        *presult = NT_STATUS_NO_MEMORY;
                        goto done;
                }
 
-               if (!((*types = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_names)))) {
+               if (!((*types = talloc_array(mem_ctx, enum lsa_SidType, num_names)))) {
                        DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
                        *presult = NT_STATUS_NO_MEMORY;
                        goto done;
                }
 
                if (dom_names != NULL) {
-                       *dom_names = TALLOC_ARRAY(mem_ctx, const char *, num_names);
+                       *dom_names = talloc_array(mem_ctx, const char *, num_names);
                        if (*dom_names == NULL) {
                                DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
                                *presult = NT_STATUS_NO_MEMORY;