r4437: added IDL and test code for lsa_LookupSids3() and lsa_LookupNames3().
authorAndrew Tridgell <tridge@samba.org>
Fri, 31 Dec 2004 07:26:26 +0000 (07:26 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:07:50 +0000 (13:07 -0500)
For some reason I am getting ACCESS_DENIED from w2k3 on
lsa_LookupSids3(). I will investigate.
(This used to be commit c759fa0000e37c3e93a7529a7701998af6727612)

source4/librpc/idl/lsa.idl
source4/torture/rpc/lsa.c

index e4ef17b7124ac4ad16f9b558f99bb64ab33b1f91..66a75935664f34b642f8a0516f5ff8a6de102610 100644 (file)
        /* Function 0x43 */
        NTSTATUS lsa_CREDRPROFILELOADED();
 
+       /**********************/
        /* Function 0x44 */
-       NTSTATUS lsa_LSARLOOKUPNAMES3();
+       typedef struct {
+               uint16 sid_type;
+               dom_sid *sid;
+               uint32 sid_index;
+               uint32 unknown;
+       } lsa_TranslatedSid3;
+
+       typedef struct {
+               [range(0,1000)] uint32 count;
+               [size_is(count)] lsa_TranslatedSid3 *sids;
+       } lsa_TransSidArray3;
+
+       NTSTATUS lsa_LookupNames3 (
+               [in,ref]     policy_handle *handle,
+               [in,range(0,1000)] uint32 num_names,
+               [in,ref,size_is(num_names)]  lsa_String *names,
+               [out]        lsa_RefDomainList *domains,
+               [in,out,ref] lsa_TransSidArray3 *sids,
+               [in]         uint16 level,
+               [in,out,ref] uint32 *count,
+               [in]         uint32 unknown1,
+               [in]         uint32 unknown2
+               );
 
        /* Function 0x45 */
        NTSTATUS lsa_CREDRGETSESSIONTYPES();
        /* Function 0x4b */
        NTSTATUS lsa_CREDRRENAME();
 
+       /*****************/
        /* Function 0x4c */
-       NTSTATUS lsa_LSARLOOKUPSIDS3();
+
+       NTSTATUS lsa_LookupSids3(
+               [in,ref]     lsa_SidArray *sids,
+               [out]        lsa_RefDomainList *domains,
+               [in,out,ref] lsa_TransNameArray2 *names,
+               [in]         uint16 level,
+               [in,out,ref] uint32 *count,
+               [in]         uint32 unknown1,
+               [in]         uint32 unknown2
+               );
 
        /* Function 0x4d */
        NTSTATUS lsa_LSARLOOKUPNAMES4();
index 7d1ba5fdaeeddc7109f40bc9a36e4953c582a20c..3fba1bf4b0cf0ed80903e54d5c2e1f071f4d62ad 100644 (file)
@@ -188,6 +188,51 @@ static BOOL test_LookupNames2(struct dcerpc_pipe *p,
 }
 
 
+static BOOL test_LookupNames3(struct dcerpc_pipe *p, 
+                             TALLOC_CTX *mem_ctx, 
+                             struct policy_handle *handle,
+                             struct lsa_TransNameArray2 *tnames)
+{
+       struct lsa_LookupNames3 r;
+       struct lsa_TransSidArray3 sids;
+       struct lsa_String *names;
+       uint32_t count = 0;
+       NTSTATUS status;
+       int i;
+
+       printf("\nTesting LookupNames3 with %d names\n", tnames->count);
+
+       sids.count = 0;
+       sids.sids = NULL;
+
+       names = talloc_array_p(mem_ctx, struct lsa_String, tnames->count);
+       for (i=0;i<tnames->count;i++) {
+               init_lsa_String(&names[i], tnames->names[i].name.string);
+       }
+
+       r.in.handle = handle;
+       r.in.num_names = tnames->count;
+       r.in.names = names;
+       r.in.sids = &sids;
+       r.in.level = 1;
+       r.in.count = &count;
+       r.in.unknown1 = 0;
+       r.in.unknown2 = 0;
+       r.out.count = &count;
+       r.out.sids = &sids;
+
+       status = dcerpc_lsa_LookupNames3(p, mem_ctx, &r);
+       if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+               printf("LookupNames3 failed - %s\n", nt_errstr(status));
+               return False;
+       }
+
+       printf("\n");
+
+       return True;
+}
+
+
 static BOOL test_LookupSids(struct dcerpc_pipe *p, 
                            TALLOC_CTX *mem_ctx, 
                            struct policy_handle *handle,
@@ -267,6 +312,45 @@ static BOOL test_LookupSids2(struct dcerpc_pipe *p,
        return True;
 }
 
+static BOOL test_LookupSids3(struct dcerpc_pipe *p, 
+                           TALLOC_CTX *mem_ctx, 
+                           struct policy_handle *handle,
+                           struct lsa_SidArray *sids)
+{
+       struct lsa_LookupSids3 r;
+       struct lsa_TransNameArray2 names;
+       uint32_t count = sids->num_sids;
+       NTSTATUS status;
+
+       printf("\nTesting LookupSids3\n");
+
+       names.count = 0;
+       names.names = NULL;
+
+       r.in.sids = sids;
+       r.in.names = &names;
+       r.in.level = 1;
+       r.in.count = &count;
+       r.in.unknown1 = 0;
+       r.in.unknown2 = 0;
+       r.out.count = &count;
+       r.out.names = &names;
+
+       status = dcerpc_lsa_LookupSids3(p, mem_ctx, &r);
+       if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
+               printf("LookupSids3 failed - %s\n", nt_errstr(status));
+               return False;
+       }
+
+       printf("\n");
+
+       if (!test_LookupNames3(p, mem_ctx, handle, &names)) {
+               return False;
+       }
+
+       return True;
+}
+
 static BOOL test_many_LookupSids(struct dcerpc_pipe *p, 
                                 TALLOC_CTX *mem_ctx, 
                                 struct policy_handle *handle)
@@ -789,6 +873,10 @@ static BOOL test_EnumAccounts(struct dcerpc_pipe *p,
                        return False;
                }
 
+               if (!test_LookupSids3(p, mem_ctx, handle, &sids1)) {
+                       return False;
+               }
+
                printf("testing all accounts\n");
                for (i=0;i<sids1.num_sids;i++) {
                        test_OpenAccount(p, mem_ctx, handle, sids1.sids[i].sid);