It turns out that the Netlogon PAC verification is encrypted.
[kai/samba.git] / source4 / librpc / idl / netlogon.idl
index c98fa8f1e6a193d5d3728e9a6ee21695860b6ce3..22981068518bcd5ad0ec7a2e3b8f412daa78cc99 100644 (file)
@@ -4,6 +4,8 @@
   who contributed!
 */
 
+import "misc.idl", "lsa.idl", "samr.idl", "security.idl", "nbt.idl";
+
 #include "idl_types.h"
 
 [
 
 interface netlogon
 {
+       typedef bitmap samr_AcctFlags samr_AcctFlags;
+       typedef bitmap samr_GroupAttrs samr_GroupAttrs;
 
        /*****************/
        /* Function 0x00 */
 
        typedef struct {
-               unistr *account_name;
+               [string,charset(UTF16)] uint16 *account_name;
                uint32 priv;
                uint32 auth_flags;
                uint32 logon_count;
@@ -32,17 +36,17 @@ interface netlogon
                uint32 password_age;
                time_t pw_can_change;
                time_t pw_must_change;
-               unistr *computer;
-               unistr *domain;
-               unistr *script_path;
+               [string,charset(UTF16)] uint16 *computer;
+               [string,charset(UTF16)] uint16 *domain;
+               [string,charset(UTF16)] uint16 *script_path;
                uint32 unknown;
        } netr_UasInfo;
 
        WERROR netr_LogonUasLogon(
-               [in]   unistr *server_name,
-               [in]   unistr account_name,
-               [in]   unistr workstation,
-               [out netr_UasInfo *info
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in]   [string,charset(UTF16)] uint16 account_name[],
+               [in]   [string,charset(UTF16)] uint16 workstation[],
+               [out,unique] netr_UasInfo *info
                );
 
 
@@ -55,9 +59,9 @@ interface netlogon
        } netr_UasLogoffInfo;
 
        WERROR netr_LogonUasLogoff(
-               [in] unistr *server_name,
-               [in] unistr account_name,
-               [in] unistr workstation,
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in] [string,charset(UTF16)] uint16 account_name[],
+               [in] [string,charset(UTF16)] uint16 workstation[],
                [out] netr_UasLogoffInfo info
                );
 
@@ -65,21 +69,11 @@ interface netlogon
        /*****************/
        /* Function 0x02 */
 
-       typedef [flag(NDR_PAHEX)] struct {
-               uint8 data[8];
-       } netr_Credential;
-
-       typedef struct {
-               [value(strlen_m(r->string)*2)]  uint16 size;
-               [value(r->size)]                uint16 length;
-               unistr_noterm *string;
-       } netr_String;
-       
        /* in netr_AcctLockStr size seems to be be 24, and rrenard thinks 
           that the structure of the bindata looks like this:
 
-               uint64 lockout_duration;
-               uint64 reset_count;
+               dlong  lockout_duration;
+               udlong reset_count;
                uint32 bad_attempt_lockout;
                uint32 dummy;   
 
@@ -92,13 +86,22 @@ interface netlogon
                [size_is(size/2),length_is(length/2)] uint16 *bindata;
        } netr_AcctLockStr;
 
+       typedef [public,bitmap32bit] bitmap {
+               MSV1_0_CLEARTEXT_PASSWORD_ALLOWED       = 0x00000002,
+               MSV1_0_UPDATE_LOGON_STATISTICS          = 0x00000004,
+               MSV1_0_RETURN_USER_PARAMETERS           = 0x00000008,
+               MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT       = 0x00000020,
+               MSV1_0_RETURN_PROFILE_PATH              = 0x00000200,
+               MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT  = 0x00000800
+       } netr_LogonParameterControl;
+
        typedef struct {
-               netr_String domain_name;
-               uint32      parameter_control;
+               lsa_String  domain_name;
+               netr_LogonParameterControl parameter_control; /* see MSV1_0_* */
                uint32      logon_id_low;
                uint32      logon_id_high;
-               netr_String account_name;
-               netr_String workstation;
+               lsa_String  account_name;
+               lsa_String  workstation;
        } netr_IdentityInfo;
 
        typedef struct {
@@ -109,8 +112,8 @@ interface netlogon
 
        typedef [flag(NDR_PAHEX)] struct {
                uint16 length;
-               [value(r->length)] uint16 size;
-               [size_is(size),length_is(length)] uint8 *data;
+               [value(length)] uint16 size;
+               [size_is(length),length_is(length)] uint8 *data;
        } netr_ChallengeResponse;
 
        typedef [flag(NDR_PAHEX)] struct {
@@ -120,32 +123,55 @@ interface netlogon
                netr_ChallengeResponse lm;
        } netr_NetworkInfo;
 
-       typedef union {
-               [case(1)] netr_PasswordInfo *password;
-               [case(2)] netr_NetworkInfo  *network;
-               [case(3)] netr_PasswordInfo *password;
-               [case(5)] netr_PasswordInfo *password;
-               [case(6)] netr_NetworkInfo  *network;
-       } netr_LogonLevel;
-
-       typedef struct {
-               netr_Credential cred;
-               time_t timestamp;
-       } netr_Authenticator;
+       typedef [flag(NDR_PAHEX)] struct {
+               netr_IdentityInfo identity_info;
+               lsa_String  package_name;
+               uint32 length;
+               [size_is(length)] uint8 *data;
+       } netr_GenericInfo;
 
-       typedef struct {
-               uint32 rid;
-               uint32 attributes;
-       } netr_GroupMembership;
+       typedef enum {
+               NetlogonInteractiveInformation = 1,
+               NetlogonNetworkInformation = 2,
+               NetlogonServiceInformation = 3,
+               NetlogonGenericInformation = 4,
+               NetlogonInteractiveTransitiveInformation = 5,
+               NetlogonNetworkTransitiveInformation = 6,
+               NetlogonServiceTransitiveInformation = 7
+       } netr_LogonInfoClass;
+
+       typedef [public,switch_type(netr_LogonInfoClass)] union {
+               [case(NetlogonInteractiveInformation)]           netr_PasswordInfo *password;
+               [case(NetlogonNetworkInformation)]               netr_NetworkInfo  *network;
+               [case(NetlogonServiceInformation)]               netr_PasswordInfo *password;
+               [case(NetlogonGenericInformation)]               netr_GenericInfo  *generic;
+               [case(NetlogonInteractiveTransitiveInformation)] netr_PasswordInfo *password;
+               [case(NetlogonNetworkTransitiveInformation)]     netr_NetworkInfo  *network;
+               [case(NetlogonServiceTransitiveInformation)]     netr_PasswordInfo *password;
+       } netr_LogonLevel;
 
-       typedef [flag(NDR_PAHEX)] struct {
+       typedef [public,flag(NDR_PAHEX)] struct {
                uint8 key[16];
        } netr_UserSessionKey;
 
-       typedef [flag(NDR_PAHEX)] struct {
+       typedef [public,flag(NDR_PAHEX)] struct {
                uint8 key[8];
        } netr_LMSessionKey;
 
+       /* Flags for user_flags below */
+       typedef [public,bitmap32bit] bitmap {
+               NETLOGON_GUEST                  = 0x0001,
+               NETLOGON_NOENCRYPTION           = 0x0002,
+               NETLOGON_CACHED_ACCOUNT         = 0x0004,
+               NETLOGON_USED_LM_PASSWORD       = 0x0008,
+               NETLOGON_EXTRA_SIDS             = 0x0020,
+               NETLOGON_SUBAUTH_SESSION_KEY    = 0x0040,
+               NETLOGON_SERVER_TRUST_ACCOUNT   = 0x0080,
+               NETLOGON_NTLMV2_ENABLED         = 0x0100,
+               NETLOGON_RESOURCE_GROUPS        = 0x0200,
+               NETLOGON_PROFILE_PATH_RETURNED  = 0x0400
+       } netr_UserFlags;
+
        typedef struct {
                NTTIME last_logon;
                NTTIME last_logoff;
@@ -153,25 +179,24 @@ interface netlogon
                NTTIME last_password_change;
                NTTIME allow_password_change;
                NTTIME force_password_change;
-               netr_String account_name;
-               netr_String full_name;
-               netr_String logon_script;
-               netr_String profile_path;
-               netr_String home_directory;
-               netr_String home_drive;
+               lsa_String account_name;
+               lsa_String full_name;
+               lsa_String logon_script;
+               lsa_String profile_path;
+               lsa_String home_directory;
+               lsa_String home_drive;
                uint16 logon_count;
                uint16 bad_password_count;
                uint32 rid;
                uint32 primary_gid;
-               uint32 group_count;
-               [size_is(group_count)] netr_GroupMembership *groupids;
-               uint32 user_flags;
+               samr_RidWithAttributeArray groups;
+               netr_UserFlags user_flags;
                netr_UserSessionKey key;
-               netr_String logon_server;
-               netr_String domain;
+               lsa_StringLarge logon_server;
+               lsa_StringLarge domain;
                dom_sid2 *domain_sid;
                netr_LMSessionKey LMSessKey;
-               uint32 acct_flags;
+               samr_AcctFlags acct_flags;
                uint32 unknown[7];
        } netr_SamBaseInfo;
 
@@ -181,7 +206,7 @@ interface netlogon
 
        typedef struct {
                dom_sid2 *sid;
-               uint32 attribute;
+               samr_GroupAttrs attributes;
        } netr_SidAttr;
 
        typedef [public] struct {
@@ -194,45 +219,67 @@ interface netlogon
                netr_SamBaseInfo base;
                uint32 sidcount;
                [size_is(sidcount)] netr_SidAttr *sids;
-               netr_String forest;
-               netr_String principle;
+               lsa_String forest;
+               lsa_String principle;
                uint32 unknown4[20];
        } netr_SamInfo6;
 
        typedef struct {
                uint32 pac_size;
                [size_is(pac_size)] uint8 *pac;
-               netr_String logon_domain;
-               netr_String logon_server;
-               netr_String principal_name;
+               lsa_String logon_domain;
+               lsa_String logon_server;
+               lsa_String principal_name;
                uint32 auth_size;
                [size_is(auth_size)] uint8 *auth;
                netr_UserSessionKey user_session_key;
                uint32 expansionroom[10];
-               netr_String unknown1;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
+               lsa_String unknown1;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
        } netr_PacInfo;
 
-       typedef union {
-               [case(2)] netr_SamInfo2 *sam2;
-               [case(3)] netr_SamInfo3 *sam3;
+       typedef [flag(NDR_PAHEX)] struct {
+               uint32 length;
+               [size_is(length)] uint8 *data;
+       } netr_GenericInfo2;
+
+       typedef enum {
+               NetlogonValidationUasInfo = 1,
+               NetlogonValidationSamInfo = 2,
+               NetlogonValidationSamInfo2 = 3,
+               NetlogonValidationGenericInfo2 = 5,
+               NetlogonValidationSamInfo4 = 6
+       } netr_ValidationInfoClass;
+
+       typedef [public,switch_type(uint16)] union {
+               [case(NetlogonValidationSamInfo)] netr_SamInfo2 *sam2;
+               [case(NetlogonValidationSamInfo2)] netr_SamInfo3 *sam3;
                [case(4)] netr_PacInfo  *pac;
-               [case(5)] netr_PacInfo  *pac;
-               [case(6)] netr_SamInfo6 *sam6;
+               [case(NetlogonValidationGenericInfo2)] netr_GenericInfo2  *generic;
+               [case(NetlogonValidationSamInfo4)] netr_SamInfo6 *sam6;
        } netr_Validation;
 
+       typedef [public, flag(NDR_PAHEX)] struct {
+               uint8 data[8];
+       } netr_Credential;
+
+       typedef [public] struct {
+               netr_Credential cred;
+               time_t timestamp;
+       } netr_Authenticator;
+
        NTSTATUS netr_LogonSamLogon(
-               [in] unistr *server_name,
-               [in] unistr *workstation,
-               [in] netr_Authenticator *credential,
-               [in][out] netr_Authenticator *return_authenticator,
-               [in]  uint16 logon_level,
-               [in]  [switch_is(logon_level)] netr_LogonLevel logon,
-               [in]  uint16 validation_level,
+               [in,unique] [string,charset(UTF16)] uint16         *server_name,
+               [in,unique] [string,charset(UTF16)] uint16         *computer_name,
+               [in,unique] netr_Authenticator                     *credential,
+               [in,out,unique] netr_Authenticator                 *return_authenticator,
+               [in]  netr_LogonInfoClass                           logon_level,
+               [in]  [switch_is(logon_level)] netr_LogonLevel      logon,
+               [in]  uint16                                        validation_level,
                [out] [switch_is(validation_level)] netr_Validation validation,
-               [out] uint32 authoritative
+               [out] uint8                                         authoritative
                );
 
 
@@ -240,22 +287,22 @@ interface netlogon
        /* Function 0x03 */
 
        NTSTATUS netr_LogonSamLogoff(
-               [in] unistr *server_name,
-               [in] unistr *computer_name,
-               [in]      netr_Authenticator *credential,
-               [in][out] netr_Authenticator *return_authenticator,
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in,unique] [string,charset(UTF16)] uint16 *computer_name,
+               [in,unique] netr_Authenticator *credential,
+               [in,out,unique] netr_Authenticator *return_authenticator,
                [in] uint16 logon_level,
                [in] [switch_is(logon_level)] netr_LogonLevel logon
                );
-
+       
 
 
        /*****************/
        /* Function 0x04 */
 
-       NTSTATUS netr_ServerReqChallenge(
-               [in]         unistr *server_name,
-               [in]         unistr computer_name,
+       [public] NTSTATUS netr_ServerReqChallenge(
+               [in,unique,string,charset(UTF16)] uint16 *server_name,
+               [in,string,charset(UTF16)] uint16 computer_name[],
                [in,out,ref] netr_Credential *credentials
                );
 
@@ -263,16 +310,13 @@ interface netlogon
        /*****************/
        /* Function 0x05 */
 
-       /* secure channel types */
-       const int SEC_CHAN_WKSTA   = 2;
-       const int SEC_CHAN_DOMAIN  = 4;
-       const int SEC_CHAN_BDC     = 6;
+       typedef enum netr_SchannelType netr_SchannelType;
 
        NTSTATUS netr_ServerAuthenticate(
-               [in]         unistr *server_name,
-               [in]         unistr account_name,
-               [in]         uint16 secure_channel_type,
-               [in]         unistr computer_name,
+               [in,unique,string,charset(UTF16)] uint16 *server_name,
+               [in,string,charset(UTF16)] uint16 account_name[],
+               [in]                       netr_SchannelType secure_channel_type,
+               [in,string,charset(UTF16)] uint16 computer_name[],
                [in,out,ref] netr_Credential *credentials
                );
 
@@ -281,10 +325,10 @@ interface netlogon
        /* Function 0x06 */
 
        NTSTATUS netr_ServerPasswordSet(
-               [in]  unistr *server_name,
-               [in]  unistr account_name,
-               [in]  uint16 secure_channel_type,
-               [in]  unistr computer_name,
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in]  [string,charset(UTF16)] uint16 account_name[],
+               [in]  netr_SchannelType secure_channel_type,
+               [in]  [string,charset(UTF16)] uint16 computer_name[],
                [in]  netr_Authenticator credential,
                [in]  samr_Password new_password,
                [out] netr_Authenticator return_authenticator
@@ -294,12 +338,14 @@ interface netlogon
        /*****************/
        /* Function 0x07 */
 
+       typedef enum netr_SamDatabaseID netr_SamDatabaseID;
+
        typedef struct {
-               unistr *account_name;
-               netr_String unknown1;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
+               [string,charset(UTF16)] uint16 *account_name;
+               lsa_String unknown1;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
                uint32 unknown5;
                uint32 unknown6;
                uint32 unknown7;
@@ -307,45 +353,80 @@ interface netlogon
        } netr_DELTA_DELETE_USER;
 
        typedef struct {
-               bool8  SensitiveDataFlag;
+               uint16 length;
+               [value(length)] uint16 size;
+               uint32 flags;
+               samr_Password pwd;
+       } netr_USER_KEY16;
+
+       typedef struct {
+               uint16 nt_length;
+               [value(nt_length)] uint16 nt_size;
+               uint32 nt_flags;
+               uint16 lm_length;
+               [value(lm_length)] uint16 lm_size;
+               uint32 lm_flags;
+               uint8 nt_history[nt_length];
+               uint8 lm_history[lm_length];
+       } netr_PasswordHistory;
+
+       typedef struct {
+               netr_USER_KEY16 lmpassword;
+               netr_USER_KEY16 ntpassword;
+               netr_PasswordHistory history;
+       } netr_USER_KEYS2;
+
+       typedef struct { /* TODO: make this a union! */
+               netr_USER_KEYS2 keys2;
+       } netr_USER_KEY_UNION;
+
+       typedef [public] struct {
+               uint32 version;
+               netr_USER_KEY_UNION keys;
+       } netr_USER_KEYS;
+
+       typedef struct {
+               boolean8  SensitiveDataFlag;
                uint32 DataLength;
-               [size_is(DataLength)] uint8 *SensitiveData;
+
+               /* netr_USER_KEYS encrypted with the session key */
+               [size_is(DataLength)][flag(NDR_PAHEX)] uint8 *SensitiveData;
        } netr_USER_PRIVATE_INFO;
 
        typedef struct {
-               netr_String account_name;
-               netr_String full_name;
+               lsa_String account_name;
+               lsa_String full_name;
                uint32 rid;
-               uint32 primary_group;
-               netr_String home_dir;
-               netr_String home_drive;
-               netr_String logon_script;
-               netr_String description;
-               netr_String workstations;
-               NTTIME LastLogon;
-               NTTIME LastLogoff;
+               uint32 primary_gid;
+               lsa_String home_directory;
+               lsa_String home_drive;
+               lsa_String logon_script;
+               lsa_String description;
+               lsa_String workstations;
+               NTTIME last_logon;
+               NTTIME last_logoff;
                samr_LogonHours logon_hours;
-               uint16 bad_pw_count;
+               uint16 bad_password_count;
                uint16 logon_count;
-               NTTIME PwLastSet;
-               NTTIME AccountExpires;
-               uint32 AccountControl;
-               samr_Password lmpw;
-               samr_Password ntpw;
-               bool8 NTPwPresent;
-               bool8 LMPwPresent;
-               bool8 PwExpired;
-               netr_String UserComment;
-               netr_String Parameters;
-               uint16 CountryCode;
-               uint16 CodePage;
+               NTTIME last_password_change;
+               NTTIME acct_expiry;
+               samr_AcctFlags acct_flags;
+               samr_Password lmpassword;
+               samr_Password ntpassword;
+               boolean8 nt_password_present;
+               boolean8 lm_password_present;
+               boolean8 password_expired;
+               lsa_String comment;
+               lsa_String parameters;
+               uint16 country_code;
+               uint16 code_page;
                netr_USER_PRIVATE_INFO user_private_info;
                uint32 SecurityInformation;
                sec_desc_buf sdbuf;
-               netr_String profile_path;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
+               lsa_String profile_path;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
                uint32 unknown5;
                uint32 unknown6;
                uint32 unknown7;
@@ -353,37 +434,39 @@ interface netlogon
        } netr_DELTA_USER;
 
        typedef struct {
-               netr_String DomainName;
-               netr_String OEMInfo;
-               NTTIME forcedlogoff;
-               uint16 min_password_len;
-               uint16 password_history_len;
-               uint64 password_must_change_time;
-               uint64 password_can_change_time;
-               uint64 sequence_num;
+               lsa_String domain_name;
+               lsa_String oem_information; /* comment */
+               dlong force_logoff_time;
+               uint16 min_password_length;
+               uint16 password_history_length;
+               /* yes, these are signed. They are in negative 100ns */
+               dlong  max_password_age;
+               dlong  min_password_age;
+               udlong sequence_num;
                NTTIME domain_create_time;
                uint32 SecurityInformation;
                sec_desc_buf sdbuf;
                netr_AcctLockStr account_lockout;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
-               uint32 unknown5;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
+               uint32 logon_to_chgpass;
                uint32 unknown6;
                uint32 unknown7;
                uint32 unknown8;
        } netr_DELTA_DOMAIN;
 
        typedef struct {
-               netr_String groupname;
-               netr_GroupMembership group_membership;
-               netr_String comment;
+               lsa_String group_name;
+               uint32 rid;
+               uint32 attributes;
+               lsa_String description;
                uint32 SecurityInformation;
                sec_desc_buf sdbuf;
-               netr_String unknown1;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
+               lsa_String unknown1;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
                uint32 unknown5;
                uint32 unknown6;
                uint32 unknown7;
@@ -391,12 +474,12 @@ interface netlogon
        } netr_DELTA_GROUP;
 
        typedef struct {
-               netr_String OldName;
-               netr_String NewName;
-               netr_String unknown1;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
+               lsa_String OldName;
+               lsa_String NewName;
+               lsa_String unknown1;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
                uint32 unknown5;
                uint32 unknown6;
                uint32 unknown7;
@@ -414,14 +497,14 @@ interface netlogon
        } netr_DELTA_GROUP_MEMBER;
 
        typedef struct {
-               netr_String alias_name;
+               lsa_String alias_name;
                uint32 rid;
                uint32 SecurityInformation;
                sec_desc_buf sdbuf;
-               netr_String unknown1;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
+               lsa_String description;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
                uint32 unknown5;
                uint32 unknown6;
                uint32 unknown7;
@@ -448,20 +531,20 @@ interface netlogon
        typedef struct {
                uint32 maxlogsize;
                NTTIME auditretentionperiod;
-               bool8 auditingmode;
+               boolean8 auditingmode;
                uint32 maxauditeventcount;
                [size_is(maxauditeventcount+1)] uint32 *eventauditoptions;
-               netr_String primarydomainname;
+               lsa_String primary_domain_name;
                dom_sid2 *sid;
                netr_QUOTA_LIMITS quota_limits;
-               uint64 sequence_num;
+               udlong sequence_num;
                NTTIME db_create_time;
                uint32 SecurityInformation;
                sec_desc_buf sdbuf;
-               netr_String unknown1;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
+               lsa_String unknown1;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
                uint32 unknown5;
                uint32 unknown6;
                uint32 unknown7;
@@ -469,20 +552,20 @@ interface netlogon
        } netr_DELTA_POLICY;
 
        typedef struct {
-               netr_String DomainName;
+               lsa_String domain_name;
                uint32 num_controllers;
-               [size_is(num_controllers)] netr_String *controller_names;
+               [size_is(num_controllers)] lsa_String *controller_names;
                uint32 SecurityInformation;
                sec_desc_buf sdbuf;
-               netr_String unknown1;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
-               uint32 unknown5;
+               lsa_String unknown1;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
+               uint32 posix_offset;
                uint32 unknown6;
                uint32 unknown7;
                uint32 unknown8;
-       } netr_DELTA_TRUSTED_DOMAINS;
+       } netr_DELTA_TRUSTED_DOMAIN;
 
        typedef struct {
                uint16 unknown;
@@ -492,20 +575,20 @@ interface netlogon
                uint32 privilege_entries;
                uint32 privilege_control;
                [size_is(privilege_entries)] uint32 *privilege_attrib;
-               [size_is(privilege_entries)] netr_String *privilege_name;
+               [size_is(privilege_entries)] lsa_String *privilege_name;
                netr_QUOTA_LIMITS quotalimits;
                uint32 system_flags;
                uint32 SecurityInformation;
                sec_desc_buf sdbuf;
-               netr_String unknown1;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
+               lsa_String unknown1;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
                uint32 unknown5;
                uint32 unknown6;
                uint32 unknown7;
                uint32 unknown8;
-       } netr_DELTA_ACCOUNTS;
+       } netr_DELTA_ACCOUNT;
 
        typedef struct {
                uint16 unknown;
@@ -528,10 +611,10 @@ interface netlogon
                NTTIME old_cipher_set_time;
                uint32 SecurityInformation;
                sec_desc_buf sdbuf;
-               netr_String unknown1;
-               netr_String unknown2;
-               netr_String unknown3;
-               netr_String unknown4;
+               lsa_String unknown1;
+               lsa_String unknown2;
+               lsa_String unknown3;
+               lsa_String unknown4;
                uint32 unknown5;
                uint32 unknown6;
                uint32 unknown7;
@@ -552,9 +635,9 @@ interface netlogon
                NETR_DELTA_RENAME_ALIAS     = 11,
                NETR_DELTA_ALIAS_MEMBER     = 12,
                NETR_DELTA_POLICY           = 13,
-               NETR_DELTA_TRUSTED_DOMAINS  = 14,
+               NETR_DELTA_TRUSTED_DOMAIN   = 14,
                NETR_DELTA_DELETE_TRUST     = 15,
-               NETR_DELTA_ACCOUNTS         = 16,
+               NETR_DELTA_ACCOUNT          = 16,
                NETR_DELTA_DELETE_ACCOUNT   = 17,
                NETR_DELTA_SECRET           = 18,
                NETR_DELTA_DELETE_SECRET    = 19,
@@ -563,7 +646,7 @@ interface netlogon
                NETR_DELTA_MODIFY_COUNT     = 22
        } netr_DeltaEnum;
 
-       typedef union {
+       typedef [switch_type(netr_DeltaEnum)] union {
                [case(NETR_DELTA_DOMAIN)]          netr_DELTA_DOMAIN          *domain;
                [case(NETR_DELTA_GROUP)]           netr_DELTA_GROUP           *group;
                [case(NETR_DELTA_DELETE_GROUP)]    ; /* rid only */
@@ -577,18 +660,18 @@ interface netlogon
                [case(NETR_DELTA_RENAME_ALIAS)]    netr_DELTA_RENAME          *rename_alias;
                [case(NETR_DELTA_ALIAS_MEMBER)]    netr_DELTA_ALIAS_MEMBER    *alias_member;
                [case(NETR_DELTA_POLICY)]          netr_DELTA_POLICY          *policy;
-               [case(NETR_DELTA_TRUSTED_DOMAINS)] netr_DELTA_TRUSTED_DOMAINS *trusted_domains;
-               [case(NETR_DELTA_DELETE_TRUST)]    netr_DELTA_DELETE_TRUST    delete_trust;
-               [case(NETR_DELTA_ACCOUNTS)]        netr_DELTA_ACCOUNTS        *accounts;
-               [case(NETR_DELTA_DELETE_ACCOUNT)]  netr_DELTA_DELETE_ACCOUNT  delete_account;
+               [case(NETR_DELTA_TRUSTED_DOMAIN)]  netr_DELTA_TRUSTED_DOMAIN   *trusted_domain;
+               [case(NETR_DELTA_DELETE_TRUST)]    netr_DELTA_DELETE_TRUST     delete_trust;
+               [case(NETR_DELTA_ACCOUNT)]         netr_DELTA_ACCOUNT         *account;
+               [case(NETR_DELTA_DELETE_ACCOUNT)]  netr_DELTA_DELETE_ACCOUNT   delete_account;
                [case(NETR_DELTA_SECRET)]          netr_DELTA_SECRET          *secret;
-               [case(NETR_DELTA_DELETE_SECRET)]   netr_DELTA_DELETE_SECRET   delete_secret;
+               [case(NETR_DELTA_DELETE_SECRET)]   netr_DELTA_DELETE_SECRET    delete_secret;
                [case(NETR_DELTA_DELETE_GROUP2)]   netr_DELTA_DELETE_USER     *delete_group;
                [case(NETR_DELTA_DELETE_USER2)]    netr_DELTA_DELETE_USER     *delete_user;
-               [case(NETR_DELTA_MODIFY_COUNT)]    uint64                     *modified_count;
+               [case(NETR_DELTA_MODIFY_COUNT)]    udlong                     *modified_count;
        } netr_DELTA_UNION;
 
-       typedef union {
+       typedef [switch_type(netr_DeltaEnum)] union {
                [case(NETR_DELTA_DOMAIN)]          uint32 rid;
                [case(NETR_DELTA_GROUP)]           uint32 rid;
                [case(NETR_DELTA_DELETE_GROUP)]    uint32 rid;
@@ -602,19 +685,19 @@ interface netlogon
                [case(NETR_DELTA_RENAME_ALIAS)]    uint32 rid;
                [case(NETR_DELTA_ALIAS_MEMBER)]    uint32 rid;
                [case(NETR_DELTA_POLICY)]          dom_sid2 *sid;
-               [case(NETR_DELTA_TRUSTED_DOMAINS)] dom_sid2 *sid;
+               [case(NETR_DELTA_TRUSTED_DOMAIN)]  dom_sid2 *sid;
                [case(NETR_DELTA_DELETE_TRUST)]    dom_sid2 *sid;
-               [case(NETR_DELTA_ACCOUNTS)]        dom_sid2 *sid;
+               [case(NETR_DELTA_ACCOUNT)]         dom_sid2 *sid;
                [case(NETR_DELTA_DELETE_ACCOUNT)]  dom_sid2 *sid;
-               [case(NETR_DELTA_SECRET)]          unistr *name;
-               [case(NETR_DELTA_DELETE_SECRET)]   unistr *name;
+               [case(NETR_DELTA_SECRET)]          [string,charset(UTF16)] uint16 *name;
+               [case(NETR_DELTA_DELETE_SECRET)]   [string,charset(UTF16)] uint16 *name;
                [case(NETR_DELTA_DELETE_GROUP2)]   uint32 rid;
                [case(NETR_DELTA_DELETE_USER2)]    uint32 rid;
                [case(NETR_DELTA_MODIFY_COUNT)]    ;
        } netr_DELTA_ID_UNION;
 
        typedef struct {
-               uint16 delta_type;
+               netr_DeltaEnum delta_type;
                [switch_is(delta_type)] netr_DELTA_ID_UNION delta_id_union;
                [switch_is(delta_type)] netr_DELTA_UNION delta_union;
        } netr_DELTA_ENUM;
@@ -626,14 +709,14 @@ interface netlogon
 
 
        NTSTATUS netr_DatabaseDeltas(
-               [in]      unistr logon_server,
-               [in]      unistr computername,
+               [in]      [string,charset(UTF16)] uint16 logon_server[],
+               [in]      [string,charset(UTF16)] uint16 computername[],
                [in]      netr_Authenticator credential,
                [in,out]  netr_Authenticator return_authenticator,
-               [in]      uint32 database_id,
-               [in,out]  uint64 sequence_num,
+               [in]      netr_SamDatabaseID database_id,
+               [in,out]  udlong sequence_num,
                [in]      uint32 preferredmaximumlength,
-               [out]     netr_DELTA_ENUM_ARRAY *delta_enum_array
+               [out,unique] netr_DELTA_ENUM_ARRAY *delta_enum_array
                );
 
 
@@ -641,14 +724,14 @@ interface netlogon
        /* Function 0x08 */
 
        NTSTATUS netr_DatabaseSync(
-               [in]     unistr logon_server,
-               [in]     unistr computername,
+               [in]     [string,charset(UTF16)] uint16 logon_server[],
+               [in]     [string,charset(UTF16)] uint16 computername[],
                [in]     netr_Authenticator credential,
                [in,out] netr_Authenticator return_authenticator,
-               [in]     uint32 database_id,
+               [in]     netr_SamDatabaseID database_id,
                [in,out] uint32 sync_context,
                [in]     uint32 preferredmaximumlength,
-               [out]    netr_DELTA_ENUM_ARRAY *delta_enum_array
+               [out,unique] netr_DELTA_ENUM_ARRAY *delta_enum_array
                );
 
 
@@ -668,8 +751,8 @@ interface netlogon
        } netr_AccountBuffer;
 
        NTSTATUS netr_AccountDeltas(
-               [in]     unistr *logon_server,
-               [in]     unistr computername,
+               [in,unique] [string,charset(UTF16)] uint16 *logon_server,
+               [in]     [string,charset(UTF16)] uint16 computername[],
                [in]     netr_Authenticator credential,
                [in,out] netr_Authenticator return_authenticator,
                [in]     netr_UAS_INFO_0 uas,
@@ -687,8 +770,8 @@ interface netlogon
        /* Function 0x0A */
 
        NTSTATUS netr_AccountSync(
-               [in]      unistr *logon_server,
-               [in]      unistr computername,
+               [in,unique] [string,charset(UTF16)] uint16 *logon_server,
+               [in]      [string,charset(UTF16)] uint16 computername[],
                [in]      netr_Authenticator credential,
                [in,out]  netr_Authenticator return_authenticator,
                [in]      uint32 reference,
@@ -705,14 +788,12 @@ interface netlogon
        /*****************/
        /* Function 0x0B */
 
-       NTSTATUS netr_GetDcName(
-               [in]  unistr logon_server,
-               [in]  unistr *domainname,
-               [out] unistr *dcname
+       WERROR netr_GetDcName(
+               [in]  [string,charset(UTF16)] uint16 logon_server[],
+               [in,unique] [string,charset(UTF16)] uint16 *domainname,
+               [out,unique] [string,charset(UTF16)] uint16 *dcname
                );
 
-
-
        /*****************/
        /* Function 0x0C */
 
@@ -724,7 +805,7 @@ interface netlogon
        typedef struct {
                uint32 flags;
                uint32 pdc_connection_status;
-               unistr trusted_dc_name;
+               [string,charset(UTF16)] uint16 trusted_dc_name[];
                uint32 tc_connection_status;
        } netr_NETLOGON_INFO_2;
 
@@ -745,14 +826,16 @@ interface netlogon
        } netr_CONTROL_QUERY_INFORMATION;
 
        /* function_code values */
-       const int NETLOGON_CONTROL_REDISCOVER       = 5;
-       const int NETLOGON_CONTROL_TC_QUERY         = 6;
-       const int NETLOGON_CONTROL_TRANSPORT_NOTIFY = 7;
-       const int NETLOGON_CONTROL_SET_DBFLAG       = 65534;
+       typedef [v1_enum] enum {
+               NETLOGON_CONTROL_REDISCOVER       = 5,
+               NETLOGON_CONTROL_TC_QUERY         = 6,
+               NETLOGON_CONTROL_TRANSPORT_NOTIFY = 7,
+               NETLOGON_CONTROL_SET_DBFLAG       = 65534
+       } netr_LogonControlCode;
 
        WERROR netr_LogonControl(
-               [in]   unistr *logon_server,
-               [in]   uint32 function_code,
+               [in,unique] [string,charset(UTF16)] uint16 *logon_server,
+               [in]   netr_LogonControlCode function_code,
                [in]   uint32 level,
                [out,switch_is(level)]  netr_CONTROL_QUERY_INFORMATION info
                );
@@ -762,9 +845,9 @@ interface netlogon
        /* Function 0x0D */
 
        WERROR netr_GetAnyDCName(
-               [in]  unistr *logon_server,
-               [in]  unistr *domainname,
-               [out] unistr *dcname
+               [in,unique] [string,charset(UTF16)] uint16 *logon_server,
+               [in,unique] [string,charset(UTF16)] uint16 *domainname,
+               [out,unique] [string,charset(UTF16)] uint16 *dcname
                );
 
 
@@ -772,14 +855,14 @@ interface netlogon
        /* Function 0x0E */
 
        typedef union {
-               [case(NETLOGON_CONTROL_REDISCOVER)]        unistr *domain;
-               [case(NETLOGON_CONTROL_TC_QUERY)]          unistr *domain;
-               [case(NETLOGON_CONTROL_TRANSPORT_NOTIFY)]  unistr *domain;
+               [case(NETLOGON_CONTROL_REDISCOVER)]        [string,charset(UTF16)] uint16 *domain;
+               [case(NETLOGON_CONTROL_TC_QUERY)]          [string,charset(UTF16)] uint16 *domain;
+               [case(NETLOGON_CONTROL_TRANSPORT_NOTIFY)]  [string,charset(UTF16)] uint16 *domain;
                [case(NETLOGON_CONTROL_SET_DBFLAG)]        uint32 debug_level;
        } netr_CONTROL_DATA_INFORMATION;
 
        WERROR netr_LogonControl2(
-               [in]    unistr *logon_server,
+               [in,unique] [string,charset(UTF16)] uint16 *logon_server,
                [in]    uint32 function_code,
                [in]    uint32 level,
                [in][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION  data,
@@ -787,14 +870,21 @@ interface netlogon
                );
 
 
+       /* If this flag is not set, then the passwords and LM session keys are
+        * encrypted with DES calls.  (And the user session key is
+        * unencrypted) */ 
+       const int NETLOGON_NEG_ARCFOUR  = 0x00000004;
+       const int NETLOGON_NEG_128BIT   = 0x00004000;
+       const int NETLOGON_NEG_SCHANNEL = 0x40000000;
+
        /*****************/
        /* Function 0x0F */
 
        NTSTATUS netr_ServerAuthenticate2(
-               [in]         unistr *server_name,
-               [in]         unistr account_name,
-               [in]         uint16 secure_channel_type,
-               [in]         unistr computer_name,
+               [in,unique]  [string,charset(UTF16)] uint16 *server_name,
+               [in]         [string,charset(UTF16)] uint16 account_name[],
+               [in]         netr_SchannelType secure_channel_type,
+               [in]         [string,charset(UTF16)] uint16 computer_name[],
                [in,out,ref] netr_Credential *credentials,
                [in,out,ref] uint32 *negotiate_flags
                );
@@ -804,15 +894,15 @@ interface netlogon
        /* Function 0x10 */
 
        NTSTATUS netr_DatabaseSync2(
-               [in]     unistr logon_server,
-               [in]     unistr computername,
+               [in]     [string,charset(UTF16)] uint16 logon_server[],
+               [in]     [string,charset(UTF16)] uint16 computername[],
                [in]     netr_Authenticator credential,
                [in,out] netr_Authenticator return_authenticator,
-               [in]     uint32 database_id,
+               [in]     netr_SamDatabaseID database_id,
                [in]     uint16 restart_state,
                [in,out] uint32 sync_context,
                [in]     uint32 preferredmaximumlength,
-               [out]    netr_DELTA_ENUM_ARRAY *delta_enum_array
+               [out,unique] netr_DELTA_ENUM_ARRAY *delta_enum_array
                );
 
 
@@ -822,13 +912,13 @@ interface netlogon
        /* i'm not at all sure how this call works */
 
        NTSTATUS netr_DatabaseRedo(
-               [in]     unistr logon_server,
-               [in]     unistr computername,
+               [in]     [string,charset(UTF16)] uint16 logon_server[],
+               [in]     [string,charset(UTF16)] uint16 computername[],
                [in]     netr_Authenticator credential,
                [in,out] netr_Authenticator return_authenticator,
-               [in][size_is(change_log_entry_size)] uint8 *change_log_entry,
+               [in,unique][size_is(change_log_entry_size)] uint8 *change_log_entry,
                [in]     uint32 change_log_entry_size,
-               [out]    netr_DELTA_ENUM_ARRAY *delta_enum_array
+               [out,unique]    netr_DELTA_ENUM_ARRAY *delta_enum_array
                );
 
 
@@ -836,7 +926,7 @@ interface netlogon
        /* Function 0x12 */
 
        WERROR netr_LogonControl2Ex(
-               [in]   unistr *logon_server,
+               [in,unique] [string,charset(UTF16)] uint16 *logon_server,
                [in]   uint32 function_code,
                [in]   uint32 level,
                [in][switch_is(function_code)] netr_CONTROL_DATA_INFORMATION  data,
@@ -845,39 +935,115 @@ interface netlogon
 
        /*****************/
        /* Function 0x13 */
-       WERROR netr_NETRENUMERATETRUSTEDDOMAINS() ;
+       typedef struct {
+               uint32 length;
+               [size_is(length)] uint8 *data;
+       } netr_Blob;
+
+       WERROR netr_NetrEnumerateTrustedDomains(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [out,ref] netr_Blob *trusted_domains_blob
+               );
 
        /*****************/
-       /* Function 0x14 */             
-       WERROR netr_DSRGETDCNAME() ;
+       /* Function 0x14 */
+
+       /* two unkown bits still: DS_IP_VERSION_AGNOSTIC and
+        * DS_TRY_NEXTCLOSEST_SITE - Guenther */
+
+       typedef [bitmap32bit] bitmap {
+               DS_FORCE_REDISCOVERY            = 0x00000001,
+               DS_DIRECTORY_SERVICE_REQUIRED   = 0x00000010,
+               DS_DIRECTORY_SERVICE_PREFERRED  = 0x00000020,
+               DS_GC_SERVER_REQUIRED           = 0x00000040,
+               DS_PDC_REQUIRED                 = 0x00000080,
+               DS_BACKGROUND_ONLY              = 0x00000100,
+               DS_IP_REQUIRED                  = 0x00000200,
+               DS_KDC_REQUIRED                 = 0x00000400,
+               DS_TIMESERV_REQUIRED            = 0x00000800,
+               DS_WRITABLE_REQUIRED            = 0x00001000,
+               DS_GOOD_TIMESERV_PREFERRED      = 0x00002000,
+               DS_AVOID_SELF                   = 0x00004000,
+               DS_ONLY_LDAP_NEEDED             = 0x00008000,
+               DS_IS_FLAT_NAME                 = 0x00010000,
+               DS_IS_DNS_NAME                  = 0x00020000,
+               DS_RETURN_DNS_NAME              = 0x40000000,
+               DS_RETURN_FLAT_NAME             = 0x80000000
+       } netr_DsRGetDCName_flags;
+
+       typedef [v1_enum] enum {
+               DS_ADDRESS_TYPE_INET            = 1,
+               DS_ADDRESS_TYPE_NETBIOS         = 2
+       } netr_DsRGetDCNameInfo_AddressType;
+
+       typedef [bitmap32bit] bitmap {
+               DS_SERVER_PDC            = NBT_SERVER_PDC,
+               DS_SERVER_GC             = NBT_SERVER_GC,
+               DS_SERVER_LDAP           = NBT_SERVER_LDAP,
+               DS_SERVER_DS             = NBT_SERVER_DS,
+               DS_SERVER_KDC            = NBT_SERVER_KDC,
+               DS_SERVER_TIMESERV       = NBT_SERVER_TIMESERV,
+               DS_SERVER_CLOSEST        = NBT_SERVER_CLOSEST,
+               DS_SERVER_WRITABLE       = NBT_SERVER_WRITABLE,
+               DS_SERVER_GOOD_TIMESERV  = NBT_SERVER_GOOD_TIMESERV,
+               DS_SERVER_NDNC           = 0x00000400,
+               DS_DNS_CONTROLLER        = 0x20000000,
+               DS_DNS_DOMAIN            = 0x40000000,
+               DS_DNS_FOREST            = 0x80000000
+       } netr_DsR_DcFlags;
+
+       typedef struct {
+               [string,charset(UTF16)] uint16 *dc_unc;
+               [string,charset(UTF16)] uint16 *dc_address;
+               netr_DsRGetDCNameInfo_AddressType dc_address_type;
+               GUID domain_guid;
+               [string,charset(UTF16)] uint16 *domain_name;
+               [string,charset(UTF16)] uint16 *forest_name;
+               netr_DsR_DcFlags dc_flags;
+               [string,charset(UTF16)] uint16 *dc_site_name;
+               [string,charset(UTF16)] uint16 *client_site_name;
+       } netr_DsRGetDCNameInfo;
+
+       WERROR netr_DsRGetDCName(
+               [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+               [in,unique] [string,charset(UTF16)] uint16 *domain_name,
+               [in,unique] GUID *domain_guid,
+               [in,unique] GUID *site_guid,
+               [in] netr_DsRGetDCName_flags flags,
+               [out,unique] netr_DsRGetDCNameInfo *info
+               );
 
        /*****************/
        /* Function 0x15 */
-       WERROR netr_NETRLOGONDUMMYROUTINE1();
+       [todo] WERROR netr_NETRLOGONDUMMYROUTINE1();
 
        /****************/
        /* Function 0x16 */
-       WERROR netr_NETRLOGONSETSERVICEBITS();
+       [todo] WERROR netr_NETRLOGONSETSERVICEBITS();
 
        /****************/
        /* Function 0x17 */
-       WERROR netr_NETRLOGONGETTRUSTRID();
+       WERROR netr_LogonGetTrustRid(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in,unique] [string,charset(UTF16)] uint16 *domain_name,
+               [out,ref] uint32 *rid
+       );
 
        /****************/
        /* Function 0x18 */
-       WERROR netr_NETRLOGONCOMPUTESERVERDIGEST();
+       [todo] WERROR netr_NETRLOGONCOMPUTESERVERDIGEST();
 
        /****************/
        /* Function 0x19 */
-       WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST();
+       [todo] WERROR netr_NETRLOGONCOMPUTECLIENTDIGEST();
 
        /****************/
        /* Function 0x1a */
-       NTSTATUS netr_ServerAuthenticate3(
-               [in]         unistr *server_name,
-               [in]         unistr account_name,
-               [in]         uint16 secure_channel_type,
-               [in]         unistr computer_name,
+       [public] NTSTATUS netr_ServerAuthenticate3(
+               [in,unique]         [string,charset(UTF16)] uint16 *server_name,
+               [in]         [string,charset(UTF16)] uint16 account_name[],
+               [in]         netr_SchannelType secure_channel_type,
+               [in]         [string,charset(UTF16)] uint16 computer_name[],
                [in,out,ref] netr_Credential *credentials,
                [in,out,ref] uint32 *negotiate_flags,
                [out,ref]    uint32 *rid
@@ -885,20 +1051,26 @@ interface netlogon
 
        /****************/
        /* Function 0x1b */
-       WERROR netr_DSRGETDCNAMEX();
+
+       WERROR netr_DsRGetDCNameEx(
+               [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+               [in,unique] [string,charset(UTF16)] uint16 *domain_name,
+               [in,unique] GUID *domain_guid,
+               [in,unique] [string,charset(UTF16)] uint16 *site_name,
+               [in] netr_DsRGetDCName_flags flags,
+               [out,unique] netr_DsRGetDCNameInfo *info
+               );
 
        /****************/
        /* Function 0x1c */
-       WERROR netr_DSRGETSITENAME();
+       WERROR netr_DsRGetSiteName(
+               [in,unique] [string,charset(UTF16)] uint16 *computer_name,
+               [out,unique] [string,charset(UTF16)] uint16 *site
+               );
 
        /****************/
        /* Function 0x1d */
 
-       typedef struct {
-               uint32 length;
-               [size_is(length)] uint8 *data;
-       } netr_Blob;
-
        typedef [flag(NDR_PAHEX)] struct {
                uint16 length;
                uint16 size;
@@ -907,17 +1079,17 @@ interface netlogon
 
        typedef struct {
                netr_Blob blob;
-               unistr *workstation_domain;
-               unistr *workstation_site;
-               unistr *unknown1;
-               unistr *unknown2;
-               unistr *unknown3;
-               unistr *unknown4;
+               [string,charset(UTF16)] uint16 *workstation_domain;
+               [string,charset(UTF16)] uint16 *workstation_site;
+               [string,charset(UTF16)] uint16 *unknown1;
+               [string,charset(UTF16)] uint16 *unknown2;
+               [string,charset(UTF16)] uint16 *unknown3;
+               [string,charset(UTF16)] uint16 *unknown4;
                netr_BinaryString blob2;
-               netr_String product;
-               uint32 unknown5;
-               unistr *unknown6;
-               uint32 unknown7[6];
+               lsa_String product;
+               lsa_String unknown5;
+               lsa_String unknown6;
+               uint32 unknown7[4];
        } netr_DomainQuery1;
 
        typedef union {
@@ -926,9 +1098,9 @@ interface netlogon
        } netr_DomainQuery;
 
        typedef struct {
-               netr_String domainname;
-               netr_String fulldomainname;
-               netr_String forest;
+               lsa_String domainname;
+               lsa_String fulldomainname;
+               lsa_String forest;
                GUID        guid;
                dom_sid2    *sid;
                netr_BinaryString unknown1[4];
@@ -948,119 +1120,249 @@ interface netlogon
        } netr_DomainInfo;
        
        NTSTATUS netr_LogonGetDomainInfo(
-               [in]         unistr server_name,
-               [in]         unistr *computer_name,
-               [in,out,ref] netr_Authenticator *credential,
-               [in]         uint32 unknown1,
-               [in]         uint32 i1[2],
+               [in]         [string,charset(UTF16)] uint16 server_name[],
+               [in,unique]  [string,charset(UTF16)] uint16 *computer_name,
+               [in,ref]     netr_Authenticator *credential,
+               [in,out,ref] netr_Authenticator *return_authenticator,
                [in]         uint32 level,
                [in,switch_is(level)] netr_DomainQuery query,
                [out,switch_is(level)] netr_DomainInfo info
                );
 
-       /****************/
+       typedef [flag(NDR_PAHEX)] struct {
+               uint8 data[512];
+               uint32 length;
+       } netr_CryptPassword;
+
+       /*****************/
        /* Function 0x1e */
-       WERROR netr_NETRSERVERPASSWORDSET2();
+       NTSTATUS netr_ServerPasswordSet2(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in]  [string,charset(UTF16)] uint16 account_name[],
+               [in]  netr_SchannelType secure_channel_type,
+               [in]  [string,charset(UTF16)] uint16 computer_name[],
+               [in]  netr_Authenticator credential,
+               [in]  netr_CryptPassword new_password,
+               [out] netr_Authenticator return_authenticator
+               );
 
        /****************/
        /* Function 0x1f */
-       WERROR netr_NETRSERVERPASSWORDGET();
+       WERROR netr_ServerPasswordGet(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in]  [string,charset(UTF16)] uint16 account_name[],
+               [in]  netr_SchannelType secure_channel_type,
+               [in]  [string,charset(UTF16)] uint16 computer_name[],
+               [in,ref] netr_Authenticator *credential,
+               [out,ref] netr_Authenticator *return_authenticator,
+               [out,ref] samr_Password *password
+               );
 
        /****************/
        /* Function 0x20 */
-       WERROR netr_NETRLOGONSENDTOSAM();
+       [todo] WERROR netr_NETRLOGONSENDTOSAM();
 
        /****************/
        /* Function 0x21 */
-       WERROR netr_DSRADDRESSTOSITENAMESW();
+       typedef struct {
+               uint32 count;
+               [size_is(count)] lsa_String *sitename;
+       } netr_DsRAddressToSitenamesWCtr;
+
+       typedef struct {
+               [size_is(size)] uint8 *buffer;
+               uint32 size;
+       } netr_DsRAddress;
+
+       WERROR netr_DsRAddressToSitenamesW(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in] [range(0,32000)] uint32 count,
+               [in] [size_is(count)] [ref] netr_DsRAddress *addresses,
+               [out] [ref] netr_DsRAddressToSitenamesWCtr **ctr
+               );
 
        /****************/
        /* Function 0x22 */
-       WERROR netr_DSRGETDCNAMEEX2();
+       WERROR netr_DsRGetDCNameEx2(
+               [in,unique] [string,charset(UTF16)] uint16 *server_unc,
+               [in,unique] [string,charset(UTF16)] uint16 *client_account,
+               [in] samr_AcctFlags mask,
+               [in,unique] [string,charset(UTF16)] uint16 *domain_name,
+               [in,unique] GUID *domain_guid,
+               [in,unique] [string,charset(UTF16)] uint16 *site_name,
+               [in] netr_DsRGetDCName_flags flags,
+               [out,unique] netr_DsRGetDCNameInfo *info
+               );
 
        /****************/
        /* Function 0x23 */
-       WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN();
+       [todo] WERROR netr_NETRLOGONGETTIMESERVICEPARENTDOMAIN();
 
        /****************/
        /* Function 0x24 */
-       WERROR netr_NETRENUMERATETRUSTEDDOMAINSEX();
+       typedef [bitmap32bit] bitmap {
+               NETR_TRUST_FLAG_IN_FOREST = 0x00000001,
+               NETR_TRUST_FLAG_OUTBOUND  = 0x00000002,
+               NETR_TRUST_FLAG_TREEROOT  = 0x00000004,
+               NETR_TRUST_FLAG_PRIMARY   = 0x00000008,
+               NETR_TRUST_FLAG_NATIVE    = 0x00000010,
+               NETR_TRUST_FLAG_INBOUND   = 0x00000020
+       } netr_TrustFlags;
+
+       typedef [v1_enum] enum {
+               NETR_TRUST_TYPE_DOWNLEVEL       = 1,
+               NETR_TRUST_TYPE_UPLEVEL         = 2,
+               NETR_TRUST_TYPE_MIT             = 3,
+               NETR_TRUST_TYPE_DCE             = 4
+       } netr_TrustType;
+
+       typedef [bitmap32bit] bitmap {
+               NETR_TRUST_ATTRIBUTE_NON_TRANSITIVE     = 0x00000001,
+               NETR_TRUST_ATTRIBUTE_UPLEVEL_ONLY       = 0x00000002,
+               NETR_TRUST_ATTRIBUTE_QUARANTINED_DOMAIN = 0x00000004,
+               NETR_TRUST_ATTRIBUTE_FOREST_TRANSITIVE  = 0x00000008,
+               NETR_TRUST_ATTRIBUTE_CROSS_ORGANIZATION = 0x00000010,
+               NETR_TRUST_ATTRIBUTE_WITHIN_FOREST      = 0x00000020,
+               NETR_TRUST_ATTRIBUTE_TREAT_AS_EXTERNAL  = 0x00000040
+       } netr_TrustAttributes;
+
+       typedef struct {
+               [string,charset(UTF16)] uint16                  *netbios_name;
+               [string,charset(UTF16)] uint16                  *dns_name;
+               netr_TrustFlags         trust_flags;
+               uint32                  parent_index;
+               netr_TrustType          trust_type;
+               netr_TrustAttributes    trust_attributes;
+               dom_sid2                *sid;
+               GUID                    guid;
+       } netr_DomainTrust;
+
+        typedef struct {
+                uint32 count;
+                [size_is(count)] netr_DomainTrust *array;
+        } netr_DomainTrustList;
+
+       WERROR netr_NetrEnumerateTrustedDomainsEx(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [out,ref] netr_DomainTrustList *dom_trust_list
+       );
 
        /****************/
        /* Function 0x25 */
-       WERROR netr_DSRADDRESSTOSITENAMESEXW();
+       typedef struct {
+               uint32 count;
+               [size_is(count)] lsa_String *sitename;
+               [size_is(count)] lsa_String *subnetname;
+       } netr_DsRAddressToSitenamesExWCtr;
+
+       WERROR netr_DsRAddressToSitenamesExW(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in] [range(0,32000)] uint32 count,
+               [in] [size_is(count)] [ref] netr_DsRAddress *addresses,
+               [out] [ref] netr_DsRAddressToSitenamesExWCtr **ctr
+               );
 
        /****************/
        /* Function 0x26 */
-       WERROR netr_DSRGETDCSITECOVERAGEW();
+
+       typedef struct {
+               uint32 num_sites;
+               [size_is(num_sites)] [unique] lsa_String *sites;
+       } DcSitesCtr;
+
+       WERROR netr_DsrGetDcSiteCoverageW(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [out,unique] DcSitesCtr *ctr
+               );
 
        /****************/
        /* Function 0x27 */
-       WERROR netr_NETRLOGONSAMLOGONEX();
+       NTSTATUS netr_LogonSamLogonEx(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in,unique] [string,charset(UTF16)] uint16 *computer_name,
+               [in]  uint16 logon_level,
+               [in]  [switch_is(logon_level)] netr_LogonLevel logon,
+               [in]  uint16 validation_level,
+               [out] [switch_is(validation_level)] netr_Validation validation,
+               [out] uint8 authoritative,
+               [in,out] uint32 flags
+               );
 
        /****************/
        /* Function 0x28 */
 
-       const int NETR_TRUST_FLAG_IN_FOREST = 0x01;
-       const int NETR_TRUST_FLAG_OUTBOUND  = 0x02;
-       const int NETR_TRUST_FLAG_TREEROOT  = 0x04;
-       const int NETR_TRUST_FLAG_PRIMARY   = 0x08;
-       const int NETR_TRUST_FLAG_NATIVE    = 0x10;
-       const int NETR_TRUST_FLAG_INBOUND   = 0x20;
-
-       typedef struct {
-               unistr *netbios_name;
-               unistr *dns_name;
-               uint32 trust_flags;
-               uint32 parent_index;
-               uint32 trust_type;
-               uint32 trust_attributes;
-               dom_sid2 *sid;
-               GUID   guid;
-       } netr_DomainTrust;
-
        WERROR netr_DsrEnumerateDomainTrusts(
-               [in]                 unistr           *server_name,
-               [in]                 uint32           trust_flags,
+               [in,unique]          [string,charset(UTF16)] uint16           *server_name,
+               [in]                 netr_TrustFlags  trust_flags,
                [out]                uint32           count,
-               [out,size_is(count)] netr_DomainTrust *trusts
+               [out,unique,size_is(count)] netr_DomainTrust *trusts
                );
 
 
        /****************/
        /* Function 0x29 */
-       WERROR netr_DSRDEREGISTERDNSHOSTRECORDS();
+       WERROR netr_DsrDeregisterDNSHostRecords(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in,unique] [string,charset(UTF16)] uint16 *domain,
+               [in,unique] GUID *domain_guid,
+               [in,unique] GUID *dsa_guid,
+               [in,ref] [string,charset(UTF16)] uint16 *dns_host
+               );
 
        /****************/
        /* Function 0x2a */
-       WERROR netr_NETRSERVERTRUSTPASSWORDSGET();
+       NTSTATUS netr_ServerTrustPasswordsGet(
+               [in,unique]  [string,charset(UTF16)] uint16 *server_name,
+               [in]  [string,charset(UTF16)] uint16 account_name[],
+               [in]  netr_SchannelType secure_channel_type,
+               [in]  [string,charset(UTF16)] uint16 computer_name[],
+               [in,ref] netr_Authenticator *credential,
+               [out,ref] netr_Authenticator *return_authenticator,
+               [out,ref] samr_Password *password,
+               [out,ref] samr_Password *password2
+       );
 
        /****************/
        /* Function 0x2b */
-       WERROR netr_DSRGETFORESTTRUSTINFORMATION();
+
+       const int DS_GFTI_UPDATE_TDO = 0x1;
+
+       WERROR netr_DsRGetForestTrustInformation(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in,unique] [string,charset(UTF16)] uint16 *trusted_domain_name,
+               [in] uint32 flags,
+               [out,ref] lsa_ForestTrustInformation **forest_trust_info
+               );
 
        /****************/
        /* Function 0x2c */
-       WERROR netr_NETRGETFORESTTRUSTINFORMATION();
+       WERROR netr_GetForestTrustInformation(
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in,ref] [string,charset(UTF16)] uint16 *trusted_domain_name,
+               [in,ref] netr_Authenticator *credential,
+               [out,ref] netr_Authenticator *return_authenticator,
+               [in] uint32 flags,
+               [out,ref] lsa_ForestTrustInformation **forest_trust_info
+               );
 
        /****************/
        /* Function 0x2d */
 
        /* this is the ADS varient. I don't yet know what the "flags" are for */
        NTSTATUS netr_LogonSamLogonWithFlags(
-               [in] unistr *server_name,
-               [in] unistr *workstation,
-               [in] netr_Authenticator *credential,
-               [in][out] netr_Authenticator *return_authenticator,
+               [in,unique] [string,charset(UTF16)] uint16 *server_name,
+               [in,unique] [string,charset(UTF16)] uint16 *computer_name,
+               [in,unique] netr_Authenticator *credential,
+               [in,out,unique] netr_Authenticator *return_authenticator,
                [in]  uint16 logon_level,
                [in]  [switch_is(logon_level)] netr_LogonLevel logon,
                [in]  uint16 validation_level,
                [out] [switch_is(validation_level)] netr_Validation validation,
-               [out] uint32 authoritative,
+               [out] uint8 authoritative,
                [in,out] uint32 flags
                );
 
        /****************/
        /* Function 0x2e */
-       WERROR netr_NETRSERVERGETTRUSTINFO();
+       [todo] WERROR netr_NETRSERVERGETTRUSTINFO();
 }