added SAMR_USER_INFO_24 info level to samr_set_userinfo. this is used
[samba.git] / source3 / include / rpc_samr.h
index ef7fefc72e7eba6307f7a4c1bb456a3c5c8cfbbf..9a62bd4b97efcd6de6736412bcb16b85ea282199 100644 (file)
@@ -2,9 +2,9 @@
    Unix SMB/Netbios implementation.
    Version 1.9.
    SMB parameters and setup
-   Copyright (C) Andrew Tridgell 1992-1997
-   Copyright (C) Luke Kenneth Casson Leighton 1996-1997
-   Copyright (C) Paul Ashton 1997
+   Copyright (C) Andrew Tridgell 1992-1998
+   Copyright (C) Luke Kenneth Casson Leighton 1996-1998
+   Copyright (C) Paul Ashton 1997-1998
    
    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 following information comes from a QuickView on samsrv.dll,
  and gives an idea of exactly what is needed:
  
-SamrAddMemberToAlias
-SamrAddMemberToGroup
+SamrAddMemberToAlias
+SamrAddMemberToGroup
 SamrAddMultipleMembersToAlias
-SamrChangePasswordUser
+SamrChangePasswordUser
 x SamrCloseHandle
 x SamrConnect
-SamrCreateAliasInDomain
-SamrCreateGroupInDomain
-SamrCreateUserInDomain
-SamrDeleteAlias
+SamrCreateAliasInDomain
+SamrCreateGroupInDomain
+SamrCreateUserInDomain
+SamrDeleteAlias
 SamrDeleteGroup
 SamrDeleteUser
 x SamrEnumerateAliasesInDomain
@@ -54,7 +54,7 @@ SamrLookupDomainInSamServer
 x SamrLookupNamesInDomain
 x SamrOpenAlias
 x SamrOpenDomain
-SamrOpenGroup
+SamrOpenGroup
 x SamrOpenUser
 x SamrQueryDisplayInformation
 x SamrQueryInformationAlias
@@ -65,10 +65,10 @@ SamrRemoveMemberFromAlias
 SamrRemoveMemberFromForiegnDomain
 SamrRemoveMemberFromGroup
 SamrRemoveMultipleMembersFromAlias
-SamrSetInformationAlias
+SamrSetInformationAlias
 SamrSetInformationDomain
-SamrSetInformationGroup
-SamrSetInformationUser
+SamrSetInformationGroup
+SamrSetInformationUser
 SamrSetMemberAttributesOfGroup
 SamrSetSecurityObject
 SamrShutdownSamServer
@@ -77,30 +77,60 @@ SamrTestPrivateFunctionsUser
 
 ********************************************************************/
 
+#define SAMR_CONNECT_ANON      0x00
 #define SAMR_CLOSE_HND         0x01
+
+#define SAMR_UNKNOWN_3         0x03
+#define SAMR_LOOKUP_DOMAIN     0x05
 #define SAMR_OPEN_DOMAIN       0x07
+
 #define SAMR_QUERY_DOMAIN_INFO 0x08
-#define SAMR_LOOKUP_IDS        0x10
+
+#define SAMR_CREATE_DOM_GROUP  0x0a
+#define SAMR_ENUM_DOM_GROUPS   0x0b
+#define SAMR_ENUM_DOM_USERS    0x0d
+#define SAMR_CREATE_DOM_ALIAS  0x0e
+#define SAMR_ENUM_DOM_ALIASES  0x0f
+#define SAMR_QUERY_USERALIASES 0x10
+
 #define SAMR_LOOKUP_NAMES      0x11
-#define SAMR_UNKNOWN_3         0x03
-#define SAMR_QUERY_DISPINFO    0x28
+#define SAMR_LOOKUP_RIDS       0x12
+
+#define SAMR_OPEN_GROUP        0x13
+#define SAMR_QUERY_GROUPINFO   0x14
+#define SAMR_SET_GROUPINFO     0x15
+#define SAMR_ADD_GROUPMEM      0x16
+#define SAMR_DELETE_DOM_GROUP  0x17
+#define SAMR_DEL_GROUPMEM      0x18
+#define SAMR_QUERY_GROUPMEM    0x19
+
+#define SAMR_OPEN_ALIAS        0x1b
+#define SAMR_QUERY_ALIASINFO   0x1c
+#define SAMR_SET_ALIASINFO     0x1d
+#define SAMR_DELETE_DOM_ALIAS  0x1e
+#define SAMR_ADD_ALIASMEM      0x1f
+#define SAMR_DEL_ALIASMEM      0x20
+#define SAMR_QUERY_ALIASMEM    0x21
+
 #define SAMR_OPEN_USER         0x22
+#define SAMR_CREATE_USER       0x32
+#define SAMR_SET_USERINFO      0x3A
+
 #define SAMR_QUERY_USERINFO    0x24
 #define SAMR_QUERY_USERGROUPS  0x27
-#define SAMR_UNKNOWN_12        0x12
-#define SAMR_UNKNOWN_21        0x21
+#define SAMR_QUERY_DISPINFO    0x28
+
 #define SAMR_UNKNOWN_2C        0x2c
-#define SAMR_UNKNOWN_32        0x32
+#define SAMR_QUERY_DISPINFO3   0x30 /* Alias for SAMR_QUERY_DISPINFO
+                                      with info level 3 */
+#define SAMR_QUERY_DISPINFO4   0x33 /* Alias for SAMR_QUERY_DISPINFO
+                                      with info level 4 */
 #define SAMR_UNKNOWN_34        0x34
+
 #define SAMR_CHGPASSWD_USER    0x37
 #define SAMR_UNKNOWN_38        0x38
+
 #define SAMR_CONNECT           0x39
-#define SAMR_CONNECT_ANON      0x00
-#define SAMR_OPEN_ALIAS        0x1b
-#define SAMR_QUERY_ALIASINFO   0x1c
-#define SAMR_ENUM_DOM_USERS    0x0d
-#define SAMR_ENUM_DOM_ALIASES  0x0f
-#define SAMR_ENUM_DOM_GROUPS   0x30
 
 
 typedef struct logon_hours_info
@@ -110,6 +140,74 @@ typedef struct logon_hours_info
 
 } LOGON_HRS;
 
+/* SAM_USER_INFO_23 */
+typedef struct sam_user_info_23
+{
+       NTTIME logon_time;            /* logon time */
+       NTTIME logoff_time;           /* logoff time */
+       NTTIME kickoff_time;          /* kickoff time */
+       NTTIME pass_last_set_time;    /* password last set time */
+       NTTIME pass_can_change_time;  /* password can change time */
+       NTTIME pass_must_change_time; /* password must change time */
+
+       UNIHDR hdr_user_name;    /* NULL - user name unicode string header */
+       UNIHDR hdr_full_name;    /* user's full name unicode string header */
+       UNIHDR hdr_home_dir;     /* home directory unicode string header */
+       UNIHDR hdr_dir_drive;    /* home drive unicode string header */
+       UNIHDR hdr_logon_script; /* logon script unicode string header */
+       UNIHDR hdr_profile_path; /* profile path unicode string header */
+       UNIHDR hdr_acct_desc  ;  /* user description */
+       UNIHDR hdr_workstations; /* comma-separated workstations user can log in from */
+       UNIHDR hdr_unknown_str ; /* don't know what this is, yet. */
+       UNIHDR hdr_munged_dial ; /* munged path name and dial-back tel number */
+
+       uint8 lm_pwd[16];    /* lm user passwords */
+       uint8 nt_pwd[16];    /* nt user passwords */
+
+       uint32 user_rid;      /* Primary User ID */
+       uint32 group_rid;     /* Primary Group ID */
+
+       uint16 acb_info; /* account info (ACB_xxxx bit-mask) */
+       /* uint8 pad[2] */
+
+       uint32 unknown_3; /* 0x09f8 27fa */
+
+       uint16 logon_divs; /* 0x0000 00a8 which is 168 which is num hrs in a week */
+       /* uint8 pad[2] */
+       uint32 ptr_logon_hrs; /* pointer to logon hours */
+
+       uint8 padding1[8];
+
+       uint32 unknown_5;     /* 0x0001 0000 */
+
+       uint8 pass[516];
+
+       UNISTR2 uni_user_name;    /* NULL - username unicode string */
+       UNISTR2 uni_full_name;    /* user's full name unicode string */
+       UNISTR2 uni_home_dir;     /* home directory unicode string */
+       UNISTR2 uni_dir_drive;    /* home directory drive unicode string */
+       UNISTR2 uni_logon_script; /* logon script unicode string */
+       UNISTR2 uni_profile_path; /* profile path unicode string */
+       UNISTR2 uni_acct_desc  ;  /* user description unicode string */
+       UNISTR2 uni_workstations; /* login from workstations unicode string */
+       UNISTR2 uni_unknown_str ; /* don't know what this is, yet. */
+       UNISTR2 uni_munged_dial ; /* munged path name and dial-back tel number */
+
+       uint32 unknown_6; /* 0x0000 04ec */
+       uint32 padding4;
+
+       LOGON_HRS logon_hrs;
+
+} SAM_USER_INFO_23;
+
+/* SAM_USER_INFO_24 */
+typedef struct sam_user_info_24
+{
+       uint8 pass[516];
+
+} SAM_USER_INFO_24;
+
+
 /* SAM_USER_INFO_21 */
 typedef struct sam_user_info_21
 {
@@ -228,7 +326,7 @@ typedef struct q_samr_close_hnd_info
 /* SAMR_R_CLOSE_HND - probably a policy handle close */
 typedef struct r_samr_close_hnd_info
 {
-    POLICY_HND pol;       /* policy handle */
+       POLICY_HND pol;       /* policy handle */
        uint32 status;         /* return status */
 
 } SAMR_R_CLOSE_HND;
@@ -345,11 +443,26 @@ SAMR_Q_QUERY_DOMAIN_INFO - probably a query on domain group info.
 typedef struct q_samr_query_domain_info
 {
        POLICY_HND domain_pol;   /* policy handle */
-       uint16 switch_value;     /* 0x0002 */
+       uint16 switch_value;     /* 0x0002, 0x0001 */
 
 } SAMR_Q_QUERY_DOMAIN_INFO;
 
-typedef struct sam_unkown_info_2_info
+typedef struct sam_unknown_info_6_info
+{
+       uint32 unknown_0; /* 0x0000 0000 */
+
+       uint32 ptr_0;     /* pointer to unknown structure */
+       uint8  padding[12]; /* 12 bytes zeros */
+
+} SAM_UNK_INFO_6;
+
+typedef struct sam_unknown_info_7_info
+{
+       uint16 unknown_0; /* 0x0003 */
+
+} SAM_UNK_INFO_7;
+
+typedef struct sam_unknown_info_2_inf
 {
        uint32 unknown_0; /* 0x0000 0000 */
        uint32 unknown_1; /* 0x8000 0000 */
@@ -380,12 +493,24 @@ typedef struct sam_unkown_info_2_info
 
 } SAM_UNK_INFO_2;
 
+typedef struct sam_unknown_info_1_inf
+{
+       uint8 padding[12]; /* 12 bytes zeros */
+       uint32 unknown_1; /* 0x8000 0000 */
+       uint32 unknown_2; /* 0x0000 0000 */
+       uint32 unknown_3; /* 0x0000 0000 */
+
+} SAM_UNK_INFO_1;
+
 
 typedef struct sam_unknown_ctr_info
 {
        union
        {
+               SAM_UNK_INFO_1 inf1;
                SAM_UNK_INFO_2 inf2;
+               SAM_UNK_INFO_6 inf6;
+               SAM_UNK_INFO_7 inf7;
 
        } info;
 
@@ -405,6 +530,28 @@ typedef struct r_samr_query_domain_info
 } SAMR_R_QUERY_DOMAIN_INFO;
 
 
+/* SAMR_Q_LOOKUP_DOMAIN - obtain SID for a local domain */
+typedef struct q_samr_lookup_domain_info
+{
+       POLICY_HND connect_pol;
+
+       UNIHDR  hdr_domain;
+       UNISTR2 uni_domain;
+
+} SAMR_Q_LOOKUP_DOMAIN;
+
+
+/* SAMR_R_LOOKUP_DOMAIN */
+typedef struct r_samr_lookup_domain_info
+{
+       uint32   ptr_sid;
+       DOM_SID2 dom_sid;
+
+       uint32 status;
+
+} SAMR_R_LOOKUP_DOMAIN;
+
+
 /****************************************************************************
 SAMR_Q_OPEN_DOMAIN - unknown_0 values seen associated with SIDs:
 
@@ -416,7 +563,7 @@ SAMR_Q_OPEN_DOMAIN - unknown_0 values seen associated with SIDs:
 typedef struct q_samr_open_domain_info
 {
        POLICY_HND connect_pol;   /* policy handle */
-       uint32 rid;               /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - a RID? */
+       uint32 flags;               /* 0x2000 0000; 0x0000 0211; 0x0000 0280; 0x0000 0200 - flags? */
        DOM_SID2 dom_sid;         /* domain SID */
 
 } SAMR_Q_OPEN_DOMAIN;
@@ -440,13 +587,13 @@ typedef struct samr_entry_info
 
 } SAM_ENTRY;
 
+
 /* SAMR_Q_ENUM_DOM_USERS - SAM rids and names */
 typedef struct q_samr_enum_dom_users_info
 {
        POLICY_HND pol;          /* policy handle */
 
-       uint16 req_num_entries;   /* number of values (0 indicates unlimited?) */
-       uint16 unknown_0;         /* enumeration context? */
+       uint32 start_idx;   /* number of values (0 indicates unlimited?) */
        uint16 acb_mask;          /* 0x0000 indicates all */
        uint16 unknown_1;         /* 0x0000 */
 
@@ -458,17 +605,16 @@ typedef struct q_samr_enum_dom_users_info
 /* SAMR_R_ENUM_DOM_USERS - SAM rids and names */
 typedef struct r_samr_enum_dom_users_info
 {
-       uint16 total_num_entries;  /* number of entries that match without the acb mask */
-       uint16 unknown_0;          /* same as unknown_0 (enum context?) in request */
-       uint32 ptr_entries1;       /* actual number of entries to follow, having masked some out */
+       uint32 next_idx;     /* next starting index required for enum */
+       uint32 ptr_entries1;  
 
        uint32 num_entries2;
        uint32 ptr_entries2;
 
        uint32 num_entries3;
 
-       SAM_ENTRY sam[MAX_SAM_ENTRIES];
-       UNISTR2 uni_acct_name[MAX_SAM_ENTRIES];
+       SAM_ENTRY *sam;
+       UNISTR2 *uni_acct_name;
 
        uint32 num_entries4;
 
@@ -477,37 +623,15 @@ typedef struct r_samr_enum_dom_users_info
 } SAMR_R_ENUM_DOM_USERS;
 
 
-typedef struct samr_entry_info3
-{
-       uint32 grp_idx;
-
-       uint32 rid_grp;
-       uint32 attr;
-
-       UNIHDR hdr_grp_name;
-       UNIHDR hdr_grp_desc;
-
-} SAM_ENTRY3;
-
-typedef struct samr_str_entry_info3
-{
-       UNISTR2 uni_grp_name;
-       UNISTR2 uni_grp_desc;
-
-} SAM_STR3;
-
 /* SAMR_Q_ENUM_DOM_GROUPS - SAM rids and names */
 typedef struct q_samr_enum_dom_groups_info
 {
        POLICY_HND pol;          /* policy handle */
 
-       /* these are possibly an enumeration context handle... */
-       uint16 switch_level;      /* 0x0003 */
-       uint16 unknown_0;         /* 0x0000 */
-       uint32 start_idx;       /* presumably the start enumeration index */
-       uint32 unknown_1;       /* 0x0000 07d0 */
+       /* this is possibly an enumeration context handle... */
+       uint32 unknown_0;         /* 0x0000 0000 */
 
-       uint32 max_size;        /* 0x0000 7fff */
+       uint32 max_size;              /* 0x0000 ffff */
 
 } SAMR_Q_ENUM_DOM_GROUPS;
 
@@ -515,24 +639,24 @@ typedef struct q_samr_enum_dom_groups_info
 /* SAMR_R_ENUM_DOM_GROUPS - SAM rids and names */
 typedef struct r_samr_enum_dom_groups_info
 {
-       uint32 unknown_0;        /* 0x0000 0492 or 0x0000 00be */
-       uint32 unknown_1;        /* 0x0000 049a or 0x0000 00be */
-       uint32 switch_level;     /* 0x0000 0003 */
-
        uint32 num_entries;
        uint32 ptr_entries;
 
        uint32 num_entries2;
+       uint32 ptr_entries2;
 
-       SAM_ENTRY3 sam[MAX_SAM_ENTRIES];
-       SAM_STR3   str[MAX_SAM_ENTRIES];
+       uint32 num_entries3;
+
+       SAM_ENTRY sam[MAX_SAM_ENTRIES];
+       UNISTR2 uni_grp_name[MAX_SAM_ENTRIES];
+
+       uint32 num_entries4;
 
        uint32 status;
 
 } SAMR_R_ENUM_DOM_GROUPS;
 
 
-
 /* SAMR_Q_ENUM_DOM_ALIASES - SAM rids and names */
 typedef struct q_samr_enum_dom_aliases_info
 {
@@ -545,6 +669,7 @@ typedef struct q_samr_enum_dom_aliases_info
 
 } SAMR_Q_ENUM_DOM_ALIASES;
 
+
 /* SAMR_R_ENUM_DOM_ALIASES - SAM rids and names */
 typedef struct r_samr_enum_dom_aliases_info
 {
@@ -566,20 +691,7 @@ typedef struct r_samr_enum_dom_aliases_info
 } SAMR_R_ENUM_DOM_ALIASES;
 
 
-
-/* SAMR_Q_QUERY_DISPINFO - SAM rids, names and descriptions */
-typedef struct q_samr_query_disp_info
-{
-       POLICY_HND pol;        /* policy handle */
-
-       uint16 switch_level;    /* 0x0001 and 0x0002 seen */
-       uint16 unknown_0;       /* 0x0000 and 0x2000 seen */
-       uint32 start_idx;       /* presumably the start enumeration index */
-       uint32 unknown_1;       /* 0x0000 07d0, 0x0000 0400 and 0x0000 0200 seen */
-
-       uint32 max_size;        /* 0x0000 7fff, 0x0000 7ffe and 0x0000 3fff seen*/
-
-} SAMR_Q_QUERY_DISPINFO;
+/* -- Level 1 Display Info - User Information -- */
 
 typedef struct samr_entry_info1
 {
@@ -605,15 +717,13 @@ typedef struct samr_str_entry_info1
 
 typedef struct sam_entry_info_1
 {
-       uint32 num_entries;
-       uint32 ptr_entries;
-       uint32 num_entries2;
-
        SAM_ENTRY1 sam[MAX_SAM_ENTRIES];
        SAM_STR1   str[MAX_SAM_ENTRIES];
 
+} SAM_DISPINFO_1;
+
 
-} SAM_INFO_1;
+/* -- Level 2 Display Info - Trust Account Information -- */
 
 typedef struct samr_entry_info2
 {
@@ -637,45 +747,295 @@ typedef struct samr_str_entry_info2
 
 typedef struct sam_entry_info_2
 {
-       uint32 num_entries;
-       uint32 ptr_entries;
-       uint32 num_entries2;
-
        SAM_ENTRY2 sam[MAX_SAM_ENTRIES];
        SAM_STR2   str[MAX_SAM_ENTRIES];
 
-} SAM_INFO_2;
+} SAM_DISPINFO_2;
+
+
+/* -- Level 3 Display Info - Domain Group Information -- */
+
+typedef struct samr_entry_info3
+{
+       uint32 grp_idx;
+
+       uint32 rid_grp;
+       uint32 attr;     /* SE_GROUP_xxx, usually 7 */
+
+       UNIHDR hdr_grp_name;
+       UNIHDR hdr_grp_desc;
+
+} SAM_ENTRY3;
+
+typedef struct samr_str_entry_info3
+{
+       UNISTR2 uni_grp_name;
+       UNISTR2 uni_grp_desc;
+
+} SAM_STR3;
+
+typedef struct sam_entry_info_3
+{
+       SAM_ENTRY3 sam[MAX_SAM_ENTRIES];
+       SAM_STR3   str[MAX_SAM_ENTRIES];
+
+} SAM_DISPINFO_3;
+
 
-typedef struct sam_info_ctr_info
+/* -- Level 4 Display Info - User List (ASCII) -- */
+
+typedef struct samr_entry_info4
+{
+       uint32 user_idx;
+       STRHDR hdr_acct_name;
+
+} SAM_ENTRY4;
+
+typedef struct samr_str_entry_info4
+{
+       STRING2 acct_name;
+
+} SAM_STR4;
+
+typedef struct sam_entry_info_4
+{
+       SAM_ENTRY4 sam[MAX_SAM_ENTRIES];
+       SAM_STR4   str[MAX_SAM_ENTRIES];
+
+} SAM_DISPINFO_4;
+
+
+/* -- Level 5 Display Info - Group List (ASCII) -- */
+
+typedef struct samr_entry_info5
+{
+       uint32 grp_idx;
+       STRHDR hdr_grp_name;
+
+} SAM_ENTRY5;
+
+typedef struct samr_str_entry_info5
+{
+       STRING2 grp_name;
+
+} SAM_STR5;
+
+typedef struct sam_entry_info_5
+{
+       SAM_ENTRY5 sam[MAX_SAM_ENTRIES];
+       SAM_STR5   str[MAX_SAM_ENTRIES];
+
+} SAM_DISPINFO_5;
+
+
+typedef struct sam_dispinfo_ctr_info
 {
        union
        {
-               SAM_INFO_1 *info1; /* server info */
-               SAM_INFO_2 *info2; /* user info */
+               SAM_DISPINFO_1 *info1; /* users/names/descriptions */
+               SAM_DISPINFO_2 *info2; /* trust accounts */
+               SAM_DISPINFO_3 *info3; /* domain groups/descriptions */
+               SAM_DISPINFO_4 *info4; /* user list (ASCII) - used by Win95 */
+               SAM_DISPINFO_5 *info5; /* group list (ASCII) */
                void       *info; /* allows assignment without typecasting, */
 
        } sam;
 
-} SAM_INFO_CTR;
+} SAM_DISPINFO_CTR;
 
-/* SAMR_R_QUERY_DISPINFO - SAM rids, names and descriptions */
+
+/* SAMR_Q_QUERY_DISPINFO - SAM rids, names and descriptions */
+typedef struct q_samr_query_disp_info
+{
+       POLICY_HND domain_pol;
+
+       uint16 switch_level;    /* see SAM_DISPINFO_CTR above */
+       /* align */
+
+       uint32 start_idx;       /* start enumeration index */
+       uint32 max_entries;     /* maximum number of entries to return */
+       uint32 max_size;        /* recommended data size; if exceeded server
+                                  should return STATUS_MORE_ENTRIES */
+
+} SAMR_Q_QUERY_DISPINFO;
+
+
+/* SAMR_R_QUERY_DISPINFO  */
 typedef struct r_samr_query_dispinfo_info
 {
-       uint32 unknown_0;        /* container length? 0x0000 0492 or 0x0000 00be */
-       uint32 unknown_1;        /* container length? 0x0000 049a or 0x0000 00be */
-       uint16 switch_level;     /* 0x0001 or 0x0002 */
-       /*uint8 pad[2] */
+       uint32 total_size;     /* total data size for all matching entries
+                                 (0 = uncalculated) */
+       uint32 data_size;      /* actual data size returned = size of SAM_ENTRY
+                                 structures + total length of strings */
 
-       SAM_INFO_CTR *ctr;
+       uint16 switch_level;   /* see SAM_DISPINFO_CTR above */
+       /* align */
+
+       uint32 num_entries;    /* number of entries returned */
+       uint32 ptr_entries;
+       uint32 num_entries2;
+
+       SAM_DISPINFO_CTR *ctr;
 
        uint32 status;
 
 } SAMR_R_QUERY_DISPINFO;
 
 
+/* SAMR_Q_DELETE_DOM_GROUP - delete domain group */
+typedef struct q_samr_delete_dom_group_info
+{
+    POLICY_HND group_pol;          /* policy handle */
+
+} SAMR_Q_DELETE_DOM_GROUP;
+
+
+/* SAMR_R_DELETE_DOM_GROUP - delete domain group */
+typedef struct r_samr_delete_dom_group_info
+{
+       POLICY_HND pol;       /* policy handle */
+       uint32 status;        /* return status */
+
+} SAMR_R_DELETE_DOM_GROUP;
+
+
+/* SAMR_Q_CREATE_DOM_GROUP - SAM create group */
+typedef struct q_samr_create_dom_group_info
+{
+       POLICY_HND pol;        /* policy handle */
+
+       UNIHDR hdr_acct_desc;
+       UNISTR2 uni_acct_desc;
+
+       uint16 unknown_1;    /* 0x0002 */
+       uint16 unknown_2;    /* 0x0001 */
+
+} SAMR_Q_CREATE_DOM_GROUP;
+
+/* SAMR_R_CREATE_DOM_GROUP - SAM create group */
+typedef struct r_samr_create_dom_group_info
+{
+       POLICY_HND pol;        /* policy handle */
+
+       uint32 rid;    
+       uint32 status;    
+
+} SAMR_R_CREATE_DOM_GROUP;
+
+/* SAMR_Q_QUERY_GROUPINFO - SAM Group Info */
+typedef struct q_samr_query_group_info
+{
+       POLICY_HND pol;        /* policy handle */
+
+       uint16 switch_level;    /* 0x0001 seen */
+
+} SAMR_Q_QUERY_GROUPINFO;
+
+typedef struct samr_group_info1
+{
+       UNIHDR hdr_acct_name;
+
+       uint32 unknown_1; /* 0x0000 0003 - number of group members? */
+       uint32 unknown_2; /* 0x0000 0001 - number of group members? */
+
+       UNIHDR hdr_acct_desc;
+
+       UNISTR2 uni_acct_name;
+       UNISTR2 uni_acct_desc;
+
+} GROUP_INFO1;
+
+typedef struct samr_group_info4
+{
+       UNIHDR hdr_acct_desc;
+       UNISTR2 uni_acct_desc;
+
+} GROUP_INFO4;
+
+/* GROUP_INFO_CTR */
+typedef struct group_info_ctr
+{
+       uint16 switch_value1;
+       uint16 switch_value2;
+
+       union
+       {
+               GROUP_INFO4 info4;
+               GROUP_INFO1 info1;
+
+       } group;
+
+} GROUP_INFO_CTR;
+
+/* SAMR_R_QUERY_GROUPINFO - SAM Group Info */
+typedef struct r_samr_query_groupinfo_info
+{
+       uint32 ptr;        
+       GROUP_INFO_CTR *ctr;
+
+       uint32 status;
+
+} SAMR_R_QUERY_GROUPINFO;
+
+
+/* SAMR_Q_SET_GROUPINFO - SAM Group Info */
+typedef struct q_samr_set_group_info
+{
+       POLICY_HND pol;        /* policy handle */
+       GROUP_INFO_CTR *ctr;
+
+} SAMR_Q_SET_GROUPINFO;
+
+/* SAMR_R_SET_GROUPINFO - SAM Group Info */
+typedef struct r_samr_set_group_info
+{
+       uint32 status;
+
+} SAMR_R_SET_GROUPINFO;
+
+
+/* SAMR_Q_DELETE_DOM_ALIAS - delete domain alias */
+typedef struct q_samr_delete_dom_alias_info
+{
+    POLICY_HND alias_pol;          /* policy handle */
+
+} SAMR_Q_DELETE_DOM_ALIAS;
+
+
+/* SAMR_R_DELETE_DOM_ALIAS - delete domain alias */
+typedef struct r_samr_delete_dom_alias_info
+{
+       POLICY_HND pol;       /* policy handle */
+       uint32 status;        /* return status */
+
+} SAMR_R_DELETE_DOM_ALIAS;
+
+
+/* SAMR_Q_CREATE_DOM_ALIAS - SAM create alias */
+typedef struct q_samr_create_dom_alias_info
+{
+       POLICY_HND dom_pol;        /* policy handle */
+
+       UNIHDR hdr_acct_desc;
+       UNISTR2 uni_acct_desc;
+
+       uint16 unknown_1;    /* 0x001f */
+       uint16 unknown_2;    /* 0x000f */
+
+} SAMR_Q_CREATE_DOM_ALIAS;
+
+/* SAMR_R_CREATE_DOM_ALIAS - SAM create alias */
+typedef struct r_samr_create_dom_alias_info
+{
+       POLICY_HND alias_pol;        /* policy handle */
+
+       uint32 rid;    
+       uint32 status;    
+
+} SAMR_R_CREATE_DOM_ALIAS;
 
 /* SAMR_Q_QUERY_ALIASINFO - SAM Alias Info */
-typedef struct q_samr_enum_alias_info
+typedef struct q_samr_query_alias_info
 {
        POLICY_HND pol;        /* policy handle */
 
@@ -690,12 +1050,11 @@ typedef struct samr_alias_info3
 
 } ALIAS_INFO3;
 
-/* SAMR_R_QUERY_ALIASINFO - SAM rids, names and descriptions */
-typedef struct r_samr_query_aliasinfo_info
+/* ALIAS_INFO_CTR */
+typedef struct alias_info_ctr
 {
-       uint32 ptr;        
-       uint16 switch_value;     /* 0x0003 */
-       /* uint8[2] padding */
+       uint16 switch_value1;
+       uint16 switch_value2;
 
        union
        {
@@ -703,11 +1062,35 @@ typedef struct r_samr_query_aliasinfo_info
 
        } alias;
 
+} ALIAS_INFO_CTR;
+
+/* SAMR_R_QUERY_ALIASINFO - SAM alias info */
+typedef struct r_samr_query_aliasinfo_info
+{
+       uint32 ptr;        
+       ALIAS_INFO_CTR *ctr;
+
        uint32 status;
 
 } SAMR_R_QUERY_ALIASINFO;
 
 
+/* SAMR_Q_SET_ALIASINFO - SAM Alias Info */
+typedef struct q_samr_set_alias_info
+{
+       POLICY_HND alias_pol;        /* policy handle */
+       ALIAS_INFO_CTR *ctr;
+
+} SAMR_Q_SET_ALIASINFO;
+
+/* SAMR_R_SET_ALIASINFO - SAM alias info */
+typedef struct r_samr_set_aliasinfo_info
+{
+       uint32 status;
+
+} SAMR_R_SET_ALIASINFO;
+
+
 /* SAMR_Q_QUERY_USERGROUPS - */
 typedef struct q_samr_query_usergroup_info
 {
@@ -730,6 +1113,31 @@ typedef struct r_samr_query_usergroup_info
 } SAMR_R_QUERY_USERGROUPS;
 
 
+/* SAMR_Q_SET_USERINFO - set sam info */
+typedef struct q_samr_set_user_info
+{
+       POLICY_HND pol;          /* policy handle associated with user */
+       uint16 switch_value;      /* 0x0017 */
+       uint16 switch_value2;      /* 0x0017 */
+
+       union
+       {
+               SAM_USER_INFO_23 *id23; /* auth-level 0x17 */
+               SAM_USER_INFO_24 *id24; /* auth-level 0x18 */
+               void* id; /* to make typecasting easy */
+
+       } info;
+
+} SAMR_Q_SET_USERINFO;
+
+/* SAMR_R_SET_USERINFO - set sam info */
+typedef struct r_samr_set_user_info
+{
+       uint32 status;         /* return status */
+
+} SAMR_R_SET_USERINFO;
+
+
 /* SAMR_Q_QUERY_USERINFO - probably a get sam info */
 typedef struct q_samr_query_user_info
 {
@@ -760,14 +1168,14 @@ typedef struct r_samr_query_user_info
 
 
 /****************************************************************************
-SAMR_Q_LOOKUP_IDS - do a conversion from name to RID.
+SAMR_Q_QUERY_USERALIASES - do a conversion from name to RID.
 
 the policy handle allocated by an "samr open secret" call is associated
 with a SID.  this policy handle is what is queried here, *not* the SID
 itself.  the response to the lookup rids is relative to this SID.
 *****************************************************************************/
-/* SAMR_Q_LOOKUP_IDS */
-typedef struct q_samr_lookup_ids_info
+/* SAMR_Q_QUERY_USERALIASES */
+typedef struct q_samr_query_useraliases_info
 {
        POLICY_HND pol;       /* policy handle */
 
@@ -778,42 +1186,38 @@ typedef struct q_samr_lookup_ids_info
        uint32   ptr_sid[MAX_LOOKUP_SIDS]; /* pointers to sids to be looked up */
        DOM_SID2 sid    [MAX_LOOKUP_SIDS]; /* sids to be looked up. */
 
-} SAMR_Q_LOOKUP_IDS;
+} SAMR_Q_QUERY_USERALIASES;
 
 
-/* SAMR_R_LOOKUP_IDS */
-typedef struct r_samr_lookup_ids_info
+/* SAMR_R_QUERY_USERALIASES */
+typedef struct r_samr_query_useraliases_info
 {
        uint32 num_entries;
        uint32 ptr; /* undocumented buffer pointer */
 
        uint32 num_entries2; 
-       uint32 rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
+       uint32 *rid; /* domain RIDs being looked up */
 
        uint32 status; /* return code */
 
-} SAMR_R_LOOKUP_IDS;
+} SAMR_R_QUERY_USERALIASES;
 
 
 /****************************************************************************
-SAMR_Q_LOOKUP_NAMES - do a conversion from SID to RID.
-
-the policy handle allocated by an "samr open secret" call is associated
-with a SID.  this policy handle is what is queried here, *not* the SID
-itself.  the response to the lookup rids is relative to this SID.
+SAMR_Q_LOOKUP_NAMES - do a conversion from Names to RIDs+types.
 *****************************************************************************/
 /* SAMR_Q_LOOKUP_NAMES */
 typedef struct q_samr_lookup_names_info
 {
     POLICY_HND pol;       /* policy handle */
 
-       uint32 num_rids1;      /* number of rids being looked up */
-       uint32 rid;            /* 0x0000 03e8 - RID of the server doing the query? */
+       uint32 num_names1;      /* number of names being looked up */
+       uint32 flags;           /* 0x0000 03e8 - unknown */
        uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
-       uint32 num_rids2;      /* number of rids being looked up */
+       uint32 num_names2;      /* number of names being looked up */
 
-       UNIHDR  hdr_user_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
-       UNISTR2 uni_user_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
+       UNIHDR  hdr_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
+       UNISTR2 uni_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
 
 } SAMR_Q_LOOKUP_NAMES;
 
@@ -821,13 +1225,17 @@ typedef struct q_samr_lookup_names_info
 /* SAMR_R_LOOKUP_NAMES */
 typedef struct r_samr_lookup_names_info
 {
-       uint32 num_entries;
-       uint32 undoc_buffer; /* undocumented buffer pointer */
+       uint32 num_rids1;      /* number of aliases being looked up */
+       uint32 ptr_rids;       /* pointer to aliases */
+       uint32 num_rids2;      /* number of aliases being looked up */
 
-       uint32 num_entries2; 
-       DOM_RID3 dom_rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
+       uint32 rid[MAX_LOOKUP_SIDS]; /* rids */
+
+       uint32 num_types1;      /* number of users in aliases being looked up */
+       uint32 ptr_types;       /* pointer to users in aliases */
+       uint32 num_types2;      /* number of users in aliases being looked up */
 
-       uint32 num_entries3; 
+       uint32 type[MAX_LOOKUP_SIDS]; /* SID_ENUM type */
 
        uint32 status; /* return code */
 
@@ -835,56 +1243,54 @@ typedef struct r_samr_lookup_names_info
 
 
 /****************************************************************************
-SAMR_Q_UNKNOWN_12 - do a conversion from RID groups to something.
+SAMR_Q_LOOKUP_RIDS - do a conversion from RID groups to something.
 
 called to resolve domain RID groups.
 *****************************************************************************/
-/* SAMR_Q_UNKNOWN_12 */
-typedef struct q_samr_unknown_12_info
+/* SAMR_Q_LOOKUP_RIDS */
+typedef struct q_samr_lookup_rids_info
 {
-    POLICY_HND pol;       /* policy handle */
+       POLICY_HND pol;       /* policy handle */
 
-       uint32 num_gids1;      /* number of rids being looked up */
-       uint32 rid;            /* 0x0000 03e8 - RID of the server doing the query? */
+       uint32 num_rids1;      /* number of rids being looked up */
+       uint32 flags;          /* 0x0000 03e8 - unknown */
        uint32 ptr;            /* 0x0000 0000 - 32 bit unknown */
-       uint32 num_gids2;      /* number of rids being looked up */
+       uint32 num_rids2;      /* number of rids being looked up */
 
-       uint32 gid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
+       uint32 rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
 
-} SAMR_Q_UNKNOWN_12;
+} SAMR_Q_LOOKUP_RIDS;
 
 
 /****************************************************************************
-SAMR_R_UNKNOWN_12 - do a conversion from group RID to names
+SAMR_R_LOOKUP_RIDS - do a conversion from group RID to names
 
 *****************************************************************************/
-/* SAMR_R_UNKNOWN_12 */
-typedef struct r_samr_unknown_12_info
+/* SAMR_R_LOOKUP_RIDS */
+typedef struct r_samr_lookup_rids_info
 {
-    POLICY_HND pol;       /* policy handle */
-
-       uint32 num_aliases1;      /* number of aliases being looked up */
-       uint32 ptr_aliases;       /* pointer to aliases */
-       uint32 num_aliases2;      /* number of aliases being looked up */
+       uint32 num_names1;      /* number of aliases being looked up */
+       uint32 ptr_names;       /* pointer to aliases */
+       uint32 num_names2;      /* number of aliases being looked up */
 
-       UNIHDR  hdr_als_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
-       UNISTR2 uni_als_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
+       UNIHDR  hdr_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
+       UNISTR2 uni_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
 
-       uint32 num_als_usrs1;      /* number of users in aliases being looked up */
-       uint32 ptr_als_usrs;       /* pointer to users in aliases */
-       uint32 num_als_usrs2;      /* number of users in aliases being looked up */
+       uint32 num_types1;      /* number of users in aliases being looked up */
+       uint32 ptr_types;       /* pointer to users in aliases */
+       uint32 num_types2;      /* number of users in aliases being looked up */
 
-       uint32 num_als_usrs[MAX_LOOKUP_SIDS]; /* number of users per group */
+       uint32 type[MAX_LOOKUP_SIDS]; /* SID_ENUM type */
 
        uint32 status;
 
-} SAMR_R_UNKNOWN_12;
+} SAMR_R_LOOKUP_RIDS;
 
 
 /* SAMR_Q_OPEN_USER - probably an open */
 typedef struct q_samr_open_user_info
 {
-    POLICY_HND domain_pol;       /* policy handle */
+       POLICY_HND domain_pol;       /* policy handle */
        uint32 unknown_0;     /* 32 bit unknown - 0x02011b */
        uint32 user_rid;      /* user RID */
 
@@ -894,65 +1300,187 @@ typedef struct q_samr_open_user_info
 /* SAMR_R_OPEN_USER - probably an open */
 typedef struct r_samr_open_user_info
 {
-    POLICY_HND user_pol;       /* policy handle associated with unknown id */
+       POLICY_HND user_pol;       /* policy handle associated with unknown id */
        uint32 status;         /* return status */
 
 } SAMR_R_OPEN_USER;
 
 
-/* SAMR_Q_UNKNOWN_13 - probably an open alias in domain */
-typedef struct q_samr_unknown_13_info
+/* SAMR_Q_CREATE_USER - probably a create */
+typedef struct q_samr_create_user_info
 {
-    POLICY_HND alias_pol;        /* policy handle */
+       POLICY_HND domain_pol;       /* policy handle */
+
+       UNIHDR  hdr_name;       /* unicode account name header */
+       UNISTR2 uni_name;       /* unicode account name */
 
-       uint16 unknown_1;            /* 16 bit unknown - 0x0200 */
-       uint16 unknown_2;            /* 16 bit unknown - 0x0000 */
+       uint16 acb_info;      /* account control info */
+       uint32 unknown_1;     /* 0xe005 00b0 */
 
-} SAMR_Q_UNKNOWN_13;
+} SAMR_Q_CREATE_USER;
 
 
-/* SAMR_Q_UNKNOWN_21 - probably an open group in domain */
-typedef struct q_samr_unknown_21_info
+/* SAMR_R_CREATE_USER - probably a create */
+typedef struct r_samr_create_user_info
 {
-    POLICY_HND group_pol;        /* policy handle */
+       POLICY_HND user_pol;       /* policy handle associated with user */
 
-       uint16 unknown_1;            /* 16 bit unknown - 0x0477 */
-       uint16 unknown_2;            /* 16 bit unknown - 0x0000 */
+       uint32 unknown_0;     /* 0x0007 03ff */
+       uint32 user_rid;      /* user RID */
+       uint32 status;         /* return status */
 
-} SAMR_Q_UNKNOWN_21;
+} SAMR_R_CREATE_USER;
 
 
-/* SAMR_Q_UNKNOWN_32 - probably a "create SAM entry" */
-typedef struct q_samr_unknown_32_info
+
+/* SAMR_Q_QUERY_GROUPMEM - query group members */
+typedef struct q_samr_query_groupmem_info
 {
-    POLICY_HND pol;             /* policy handle */
+       POLICY_HND group_pol;        /* policy handle */
+
+} SAMR_Q_QUERY_GROUPMEM;
 
-       UNIHDR  hdr_mach_acct;       /* unicode machine account name header */
-       UNISTR2 uni_mach_acct;       /* unicode machine account name */
 
-       uint32 acct_ctrl;            /* 32 bit ACB_XXXX */
-       uint16 unknown_1;            /* 16 bit unknown - 0x00B0 */
-       uint16 unknown_2;            /* 16 bit unknown - 0xe005 */
+/* SAMR_R_QUERY_GROUPMEM - query group members */
+typedef struct r_samr_query_groupmem_info
+{
+       uint32 ptr;
+       uint32 num_entries;
 
-} SAMR_Q_UNKNOWN_32;
+       uint32 ptr_rids;
+       uint32 ptr_attrs;
 
+       uint32 num_rids;
+       uint32 *rid;
 
-/* SAMR_R_UNKNOWN_32 - probably a "create SAM entry" */
-typedef struct r_samr_unknown_32_info
+       uint32 num_attrs;
+       uint32 *attr;
+
+       uint32 status;
+
+} SAMR_R_QUERY_GROUPMEM;
+
+
+/* SAMR_Q_DEL_GROUPMEM - probably an del group member */
+typedef struct q_samr_del_group_mem_info
 {
-    POLICY_HND pol;       /* policy handle */
+       POLICY_HND pol;       /* policy handle */
+
+       uint32 rid;         /* rid */
+
+} SAMR_Q_DEL_GROUPMEM;
+
+
+/* SAMR_R_DEL_GROUPMEM - probably an del group member */
+typedef struct r_samr_del_group_mem_info
+{
+       uint32 status;         /* return status */
 
-       /* rid4.unknown - fail: 0030 success: 0x03ff */
-       DOM_RID4 rid4;         /* rid and attributes */
+} SAMR_R_DEL_GROUPMEM;
 
-       uint32 status;         /* return status - fail: 0xC000 0099: user exists */
 
-} SAMR_R_UNKNOWN_32;
+/* SAMR_Q_ADD_GROUPMEM - probably an add group member */
+typedef struct q_samr_add_group_mem_info
+{
+       POLICY_HND pol;       /* policy handle */
+
+       uint32 rid;         /* rid */
+       uint32 unknown;     /* 0x0000 0005 */
+
+} SAMR_Q_ADD_GROUPMEM;
+
+
+/* SAMR_R_ADD_GROUPMEM - probably an add group member */
+typedef struct r_samr_add_group_mem_info
+{
+       uint32 status;         /* return status */
+
+} SAMR_R_ADD_GROUPMEM;
+
+
+/* SAMR_Q_OPEN_GROUP - probably an open */
+typedef struct q_samr_open_group_info
+{
+       POLICY_HND domain_pol;       /* policy handle */
+       uint32 unknown;         /* 0x0000 0001, 0x0000 0003, 0x0000 001f */
+       uint32 rid_group;        /* rid */
+
+} SAMR_Q_OPEN_GROUP;
+
+
+/* SAMR_R_OPEN_GROUP - probably an open */
+typedef struct r_samr_open_group_info
+{
+       POLICY_HND pol;       /* policy handle */
+       uint32 status;         /* return status */
+
+} SAMR_R_OPEN_GROUP;
+
+
+/* SAMR_Q_QUERY_ALIASMEM - query alias members */
+typedef struct q_samr_query_aliasmem_info
+{
+       POLICY_HND alias_pol;        /* policy handle */
+
+} SAMR_Q_QUERY_ALIASMEM;
+
+
+/* SAMR_R_QUERY_ALIASMEM - query alias members */
+typedef struct r_samr_query_aliasmem_info
+{
+       uint32 num_sids;
+       uint32 ptr;
+       uint32 num_sids1;
+
+       DOM_SID2 *sid;
+
+       uint32 status;
+
+} SAMR_R_QUERY_ALIASMEM;
+
+
+/* SAMR_Q_ADD_ALIASMEM - add alias member */
+typedef struct q_samr_add_alias_mem_info
+{
+       POLICY_HND alias_pol;       /* policy handle */
+
+       DOM_SID2 sid; /* member sid to be added to the alias */
+
+} SAMR_Q_ADD_ALIASMEM;
+
+
+/* SAMR_R_ADD_ALIASMEM - add alias member */
+typedef struct r_samr_add_alias_mem_info
+{
+       uint32 status;         /* return status */
+
+} SAMR_R_ADD_ALIASMEM;
+
+
+/* SAMR_Q_DEL_ALIASMEM - add an add alias member */
+typedef struct q_samr_del_alias_mem_info
+{
+       POLICY_HND alias_pol;       /* policy handle */
+
+       DOM_SID2 sid; /* member sid to be added to alias */
+
+} SAMR_Q_DEL_ALIASMEM;
+
+
+/* SAMR_R_DEL_ALIASMEM - delete alias member */
+typedef struct r_samr_del_alias_mem_info
+{
+       uint32 status;         /* return status */
+
+} SAMR_R_DEL_ALIASMEM;
+
 
 
 /* SAMR_Q_OPEN_ALIAS - probably an open */
 typedef struct q_samr_open_alias_info
 {
+       POLICY_HND dom_pol;
+
        uint32 unknown_0;         /* 0x0000 0008 */
        uint32 rid_alias;        /* rid */