r4279: added IDL and test code for lsa_AddPrivilegesToAccount() and lsa_RemovePrivile...
authorAndrew Tridgell <tridge@samba.org>
Sun, 19 Dec 2004 07:20:55 +0000 (07:20 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:07:31 +0000 (13:07 -0500)
(This used to be commit 705b870c73995609c8d3ebb24418538bfe20c05b)

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

index 42891eecf79d8f0387777336a049017ce0fa8c2e..5928f44d321b021aa20b31d504675785e501dfc1 100644 (file)
        } lsa_LUIDAttribute;
        
        typedef struct {
-               uint32 count;
+               [range(0,1000)] uint32 count;
                uint32 unknown;
                [size_is(count)] lsa_LUIDAttribute set[*];
        } lsa_PrivilegeSet;
                );
 
 
+       /****************************************/
        /* Function:            0x13 */
-       NTSTATUS lsa_AddPrivilegesToAccount();
+       NTSTATUS lsa_AddPrivilegesToAccount(
+               [in,ref]     policy_handle *handle,
+               [in,ref]     lsa_PrivilegeSet *privs
+               );
        
+
+       /****************************************/
        /* Function:         0x14 */
-       NTSTATUS lsa_RemovePrivilegesFromAccount();
+       NTSTATUS lsa_RemovePrivilegesFromAccount(
+               [in,ref]     policy_handle *handle,
+               [in]         uint8 remove_all,
+               [in]         lsa_PrivilegeSet *privs
+               );
 
        /* Function:           0x15 */
        NTSTATUS lsa_GetQuotasForAccount();
index 3b7635f13b656a6ac883c2ddfa5deec17583c1dc..9fe6541dabc4e7a2a878ac75aeea3e27ccd431f0 100644 (file)
@@ -357,6 +357,67 @@ static BOOL test_LookupPrivName(struct dcerpc_pipe *p,
        return True;
 }
 
+static BOOL test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, 
+                                            TALLOC_CTX *mem_ctx,                                 
+                                            struct policy_handle *acct_handle,
+                                            struct lsa_LUID *luid)
+{
+       NTSTATUS status;
+       struct lsa_RemovePrivilegesFromAccount r;
+       struct lsa_PrivilegeSet privs;
+       BOOL ret = True;
+
+       printf("Testing RemovePrivilegesFromAccount\n");
+
+       r.in.handle = acct_handle;
+       r.in.remove_all = 0;
+       r.in.privs = &privs;
+
+       privs.count = 1;
+       privs.unknown = 0;
+       privs.set = talloc_array_p(mem_ctx, struct lsa_LUIDAttribute, 1);
+       privs.set[0].luid = *luid;
+       privs.set[0].attribute = 0;
+
+       status = dcerpc_lsa_RemovePrivilegesFromAccount(p, mem_ctx, &r);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("RemovePrivilegesFromAccount failed - %s\n", nt_errstr(status));
+               return False;
+       }
+
+       return ret;
+}
+
+static BOOL test_AddPrivilegesToAccount(struct dcerpc_pipe *p, 
+                                       TALLOC_CTX *mem_ctx,                              
+                                       struct policy_handle *acct_handle,
+                                       struct lsa_LUID *luid)
+{
+       NTSTATUS status;
+       struct lsa_AddPrivilegesToAccount r;
+       struct lsa_PrivilegeSet privs;
+       BOOL ret = True;
+
+       printf("Testing AddPrivilegesToAccount\n");
+
+       r.in.handle = acct_handle;
+       r.in.privs = &privs;
+
+       privs.count = 1;
+       privs.unknown = 0;
+       privs.set = talloc_array_p(mem_ctx, struct lsa_LUIDAttribute, 1);
+       privs.set[0].luid = *luid;
+       privs.set[0].attribute = 0;
+
+       status = dcerpc_lsa_AddPrivilegesToAccount(p, mem_ctx, &r);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("AddPrivilegesToAccount failed - %s\n", nt_errstr(status));
+               return False;
+       }
+
+       return ret;
+}
+
 static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p, 
                                  TALLOC_CTX *mem_ctx,                            
                                  struct policy_handle *handle,
@@ -364,6 +425,7 @@ static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p,
 {
        NTSTATUS status;
        struct lsa_EnumPrivsAccount r;
+       BOOL ret = True;
 
        printf("Testing EnumPrivsAccount\n");
 
@@ -375,15 +437,20 @@ static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p,
                return False;
        }
 
-       if (r.out.privs) {
+       if (r.out.privs && r.out.privs->count > 0) {
                int i;
                for (i=0;i<r.out.privs->count;i++) {
                        test_LookupPrivName(p, mem_ctx, handle, 
                                            &r.out.privs->set[i].luid);
                }
+
+               ret &= test_RemovePrivilegesFromAccount(p, mem_ctx, acct_handle, 
+                                                       &r.out.privs->set[0].luid);
+               ret &= test_AddPrivilegesToAccount(p, mem_ctx, acct_handle, 
+                                                  &r.out.privs->set[0].luid);
        }
 
-       return True;
+       return ret;
 }
 
 static BOOL test_Delete(struct dcerpc_pipe *p, 
@@ -636,7 +703,7 @@ static BOOL test_QuerySecurity(struct dcerpc_pipe *p,
        NTSTATUS status;
        struct lsa_QuerySecurity r;
 
-       printf("Testing QuerySecuriy\n");
+       printf("Testing QuerySecurity\n");
 
        r.in.handle = acct_handle;
        r.in.sec_info = 7;