/// <summary>
        ///  The NetrServerGetTrustInfo method Supported in windows_xp
        ///  and windows_server_2003, windows_vista, windows_server_2008,
        ///  windows_7, windows_server_7. returns an information
        ///  block from a specified server. The information includes
        ///  encrypted current and previous passwords for a particular
        ///  account and additional trust data. The account name
        ///  requested MUST be the name used when the secure channel
        ///  was created, unless the method is called on a PDC by
        ///  a domain controller, in which case it can be any valid
        ///  account name. Opnum: 46 
        /// </summary>
        /// <param name="TrustedDcName">
        ///  The custom RPC binding handle, as specified in section
        ///  .
        /// </param>
        /// <param name="AccountName">
        ///  The null-terminated Unicode string that contains the
        ///  name of the client account in the domain.
        /// </param>
        /// <param name="SecureChannelType">
        ///  A NETLOGON_SECURE_CHANNEL_TYPE enumerated value, as
        ///  specified in section , that indicates the type of the
        ///  secure channel being established by this call.
        /// </param>
        /// <param name="ComputerName">
        ///  The null-terminated Unicode string that contains the
        ///  NetBIOS name of the client computer, for which the
        ///  trust information MUST be returned.
        /// </param>
        /// <param name="Authenticator">
        ///  A pointer to a NETLOGON_AUTHENTICATOR structure, as
        ///  specified in section , that contains the client authenticator.
        /// </param>
        /// <param name="ReturnAuthenticator">
        ///  A pointer to a NETLOGON_AUTHENTICATOR structure, as
        ///  specified in section , that contains the server return
        ///  authenticator.
        /// </param>
        /// <param name="EncryptedNewOwfPassword">
        ///  A pointer to an ENCRYPTED_NT_OWF_PASSWORD structure,
        ///  as specified in section , that contains the NTOWFv1
        ///  (as specified in NTLM v1 Authentication in [MS-NLMP]
        ///  section) of the current password, encrypted as specified
        ///  in [MS-SAMR] section , Encrypting an NT Hash or LM
        ///  Hash Value with a Specified Key. The session key is
        ///  the specified 16-byte key that is used to derive its
        ///  keys via the 16-byte value process, as specified in
        ///  [MS-SAMR] section.
        /// </param>
        /// <param name="EncryptedOldOwfPassword">
        ///  A pointer to an ENCRYPTED_NT_OWF_PASSWORD structure,
        ///  as specified in section , that contains the NTOWFv1
        ///  (as specified in NTLM v1 Authentication in [MS-NLMP]
        ///  section) of the old password, encrypted as specified
        ///  in [MS-SAMR] section , Encrypting an NT Hash or LM
        ///  Hash Value with a Specified Key. The session key is
        ///  the specified 16-byte key that is used to derive its
        ///  keys via the 16-byte value process, as specified in
        ///  [MS-SAMR] section.
        /// </param>
        /// <param name="TrustInfo">
        ///  A pointer to an NL_GENERIC_RPC_DATA structure, as specified
        ///  in section , that contains a block of generic RPC data
        ///  with trust information for the specified server.
        /// </param>
        public NtStatus NetrServerGetTrustInfo(
            string TrustedDcName,
            string AccountName,
            _NETLOGON_SECURE_CHANNEL_TYPE SecureChannelType,
            string ComputerName,
            _NETLOGON_AUTHENTICATOR? Authenticator,
            out _NETLOGON_AUTHENTICATOR? ReturnAuthenticator,
            out _NT_OWF_PASSWORD? EncryptedNewOwfPassword,
            out _NT_OWF_PASSWORD? EncryptedOldOwfPassword,
            out _NL_GENERIC_RPC_DATA? TrustInfo)
        {
            const ushort opnum = 46;

            byte[] requestStub;
            byte[] responseStub;
            Int3264[] paramList;
            int retVal;

            SafeIntPtr pTrustedDcName = Marshal.StringToHGlobalUni(TrustedDcName);
            SafeIntPtr pAccountName = Marshal.StringToHGlobalUni(AccountName);
            SafeIntPtr pComputerName = Marshal.StringToHGlobalUni(ComputerName);
            SafeIntPtr pAuthenticator = TypeMarshal.ToIntPtr(Authenticator);

            paramList = new Int3264[] {
                pTrustedDcName,
                pAccountName,
                (uint)SecureChannelType,
                pComputerName,
                pAuthenticator,
                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero,
                IntPtr.Zero,
                0 // retVal
            };

            requestStub = RpceStubEncoder.ToBytes(
                     RpceStubHelper.GetPlatform(),
                    NrpcRpcStubFormatString.TypeFormatString,
                    new RpceStubExprEval[] { new RpceStubExprEval(logon__NETLOGON_DELTA_USERExprEval_0000) },
                    NrpcRpcStubFormatString.ProcFormatString,
                    NrpcRpcStubFormatString.ProcFormatStringOffsetTable[opnum],
                    true,
                    paramList);

            rpceClientTransport.Call(opnum, requestStub, rpceTimeout, out responseStub);

            using (RpceInt3264Collection outParamList = RpceStubDecoder.ToParamList(
                     RpceStubHelper.GetPlatform(),
                    NrpcRpcStubFormatString.TypeFormatString,
                    new RpceStubExprEval[] { new RpceStubExprEval(logon__NETLOGON_DELTA_USERExprEval_0000) },
                    NrpcRpcStubFormatString.ProcFormatString,
                    NrpcRpcStubFormatString.ProcFormatStringOffsetTable[opnum],
                    true,
                    responseStub,
                    paramList))
            {
                IntPtr pReturnAuthenticator = outParamList[5];
                ReturnAuthenticator = TypeMarshal.ToNullableStruct<_NETLOGON_AUTHENTICATOR>(pReturnAuthenticator);

                IntPtr pEncryptedNewOwfPassword = outParamList[6];
                EncryptedNewOwfPassword = TypeMarshal.ToNullableStruct<_NT_OWF_PASSWORD>(pEncryptedNewOwfPassword);

                IntPtr pEncryptedOldOwfPassword = outParamList[7];
                EncryptedOldOwfPassword = TypeMarshal.ToNullableStruct<_NT_OWF_PASSWORD>(pEncryptedOldOwfPassword);

                IntPtr pTrustInfo = outParamList[8];
                pTrustInfo = Marshal.ReadIntPtr(pTrustInfo);
                TrustInfo = TypeMarshal.ToNullableStruct<_NL_GENERIC_RPC_DATA>(pTrustInfo);

                retVal = outParamList[9].ToInt32();
            }

            pTrustedDcName.Dispose();
            pAccountName.Dispose();
            pComputerName.Dispose();
            pAuthenticator.Dispose();

            return (NtStatus)retVal;
        }
        /// <summary>
        ///  The NetrServerGetTrustInfo method Supported in windows_xp
        ///  and windows_server_2003, windows_vista, windows_server_2008,
        ///  windows_7, windows_server_7. returns an information
        ///  block from a specified server. The information includes
        ///  encrypted current and previous passwords for a particular
        ///  account and additional trust data. The account name
        ///  requested MUST be the name used when the secure channel
        ///  was created, unless the method is called on a PDC by
        ///  a domain controller, in which case it can be any valid
        ///  account name. Opnum: 46 
        /// </summary>
        /// <param name="trustedDcName">
        ///  The custom RPC binding handle.
        /// </param>
        /// <param name="accountName">
        ///  The null-terminated Unicode string that contains the
        ///  name of the client account in the domain.
        /// </param>
        /// <param name="secureChannelType">
        ///  A NETLOGON_SECURE_CHANNEL_TYPE enumerated value, 
        ///  that indicates the type of the
        ///  secure channel being established by this call.
        /// </param>
        /// <param name="computerName">
        ///  The null-terminated Unicode string that contains the
        ///  NetBIOS name of the client computer, for which the
        ///  trust information MUST be returned.
        /// </param>
        /// <param name="authenticator">
        ///  A pointer to a NETLOGON_AUTHENTICATOR structure, 
        ///  that contains the client authenticator.
        /// </param>
        /// <param name="returnAuthenticator">
        ///  A pointer to a NETLOGON_AUTHENTICATOR structure, 
        ///  that contains the server return
        ///  authenticator.
        /// </param>
        /// <param name="encryptedNewOwfPassword">
        ///  A pointer to an ENCRYPTED_NT_OWF_PASSWORD structure,
        ///  that contains the NTOWFv1
        ///  (as specified in NTLM v1 Authentication in [MS-NLMP])
        ///  of the current password, encrypted as specified
        ///  in [MS-SAMR], Encrypting an NT Hash or LM
        ///  Hash Value with a Specified Key. The session key is
        ///  the specified 16-byte key that is used to derive its
        ///  keys via the 16-byte value process, as specified in
        ///  [MS-SAMR].
        /// </param>
        /// <param name="encryptedOldOwfPassword">
        ///  A pointer to an ENCRYPTED_NT_OWF_PASSWORD structure,
        ///  that contains the NTOWFv1
        ///  (as specified in NTLM v1 Authentication in [MS-NLMP])
        ///  of the old password, encrypted as specified
        ///  in [MS-SAMR], Encrypting an NT Hash or LM
        ///  Hash Value with a Specified Key. The session key is
        ///  the specified 16-byte key that is used to derive its
        ///  keys via the 16-byte value process, as specified in
        ///  [MS-SAMR].
        /// </param>
        /// <param name="trustInfo">
        ///  A pointer to an NL_GENERIC_RPC_DATA structure, 
        ///  that contains a block of generic RPC data
        ///  with trust information for the specified server.
        /// </param>
        /// <returns>
        /// The method returns 0x00000000 on success; 
        /// otherwise, it returns a nonzero error code.
        /// </returns>
        public NtStatus NetrServerGetTrustInfo(
            string trustedDcName,
            string accountName,
            _NETLOGON_SECURE_CHANNEL_TYPE secureChannelType,
            string computerName,
            _NETLOGON_AUTHENTICATOR? authenticator,
            out _NETLOGON_AUTHENTICATOR? returnAuthenticator,
            out _NT_OWF_PASSWORD? encryptedNewOwfPassword,
            out _NT_OWF_PASSWORD? encryptedOldOwfPassword,
            out _NL_GENERIC_RPC_DATA? trustInfo)
        {
            NtStatus status = rpc.NetrServerGetTrustInfo(
                trustedDcName,
                accountName,
                secureChannelType,
                computerName,
                authenticator,
                out returnAuthenticator,
                out encryptedNewOwfPassword,
                out encryptedOldOwfPassword,
                out trustInfo);

            context.ConnectionStatus = status;
            return status;
        }