/// <summary>
        ///  NetrAccountSync IDL method. Opnum: 10 
        /// </summary>
        /// <param name="primaryName">
        ///  PrimaryName parameter.
        /// </param>
        /// <param name="computerName">
        ///  ComputerName parameter.
        /// </param>
        /// <param name="authenticator">
        ///  Authenticator parameter.
        /// </param>
        /// <param name="returnAuthenticator">
        ///  ReturnAuthenticator parameter.
        /// </param>
        /// <param name="reference">
        ///  Reference parameter.
        /// </param>
        /// <param name="level">
        ///  Level parameter.
        /// </param>
        /// <param name="buffer">
        ///  Buffer parameter.
        /// </param>
        /// <param name="bufferSize">
        ///  BufferSize parameter.
        /// </param>
        /// <param name="countReturned">
        ///  CountReturned parameter.
        /// </param>
        /// <param name="totalEntries">
        ///  TotalEntries parameter.
        /// </param>
        /// <param name="nextReference">
        ///  NextReference parameter.
        /// </param>
        /// <param name="lastRecordId">
        ///  LastRecordId parameter.
        /// </param>
        /// <returns>
        /// The method returns 0x00000000 on success; 
        /// otherwise, it returns a nonzero error code.
        /// </returns>
        public NtStatus NetrAccountSync(
            string primaryName,
            string computerName,
            _NETLOGON_AUTHENTICATOR? authenticator,
            ref _NETLOGON_AUTHENTICATOR? returnAuthenticator,
            uint reference,
            uint level,
            out byte[] buffer,
            uint bufferSize,
            out uint? countReturned,
            out uint? totalEntries,
            out uint? nextReference,
            out _UAS_INFO_0? lastRecordId)
        {
            NtStatus status = rpc.NetrAccountSync(
                primaryName,
                computerName,
                authenticator,
                ref returnAuthenticator,
                reference,
                level,
                out buffer,
                bufferSize,
                out countReturned,
                out totalEntries,
                out nextReference,
                out lastRecordId);

            context.ConnectionStatus = status;
            return status;
        }
        /// <summary>
        ///  NetrAccountSync IDL method. Opnum: 10 
        /// </summary>
        /// <param name="PrimaryName">
        ///  PrimaryName parameter.
        /// </param>
        /// <param name="ComputerName">
        ///  ComputerName parameter.
        /// </param>
        /// <param name="Authenticator">
        ///  Authenticator parameter.
        /// </param>
        /// <param name="ReturnAuthenticator">
        ///  ReturnAuthenticator parameter.
        /// </param>
        /// <param name="Reference">
        ///  Reference parameter.
        /// </param>
        /// <param name="Level">
        ///  Level parameter.
        /// </param>
        /// <param name="Buffer">
        ///  Buffer parameter.
        /// </param>
        /// <param name="BufferSize">
        ///  BufferSize parameter.
        /// </param>
        /// <param name="CountReturned">
        ///  CountReturned parameter.
        /// </param>
        /// <param name="TotalEntries">
        ///  TotalEntries parameter.
        /// </param>
        /// <param name="NextReference">
        ///  NextReference parameter.
        /// </param>
        /// <param name="LastRecordId">
        ///  LastRecordId parameter.
        /// </param>
        public NtStatus NetrAccountSync(
            string PrimaryName,
            string ComputerName,
            _NETLOGON_AUTHENTICATOR? Authenticator,
            ref _NETLOGON_AUTHENTICATOR? ReturnAuthenticator,
            uint Reference,
            uint Level,
            out byte[] Buffer,
            uint BufferSize,
            out uint? CountReturned,
            out uint? TotalEntries,
            out uint? NextReference,
            out _UAS_INFO_0? LastRecordId)
        {
            const ushort opnum = 10;

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

            SafeIntPtr pPrimaryName = Marshal.StringToHGlobalUni(PrimaryName);
            SafeIntPtr pComputerName = Marshal.StringToHGlobalUni(ComputerName);
            SafeIntPtr pAuthenticator = TypeMarshal.ToIntPtr(Authenticator);
            SafeIntPtr pReturnAuthenticatorIn = TypeMarshal.ToIntPtr(ReturnAuthenticator);

            paramList = new Int3264[] {
                pPrimaryName,
                pComputerName,
                pAuthenticator,
                pReturnAuthenticatorIn,
                Reference,
                Level,
                IntPtr.Zero,
                BufferSize,
                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 pReturnAuthenticatorOut = outParamList[3];
                ReturnAuthenticator = TypeMarshal.ToNullableStruct<_NETLOGON_AUTHENTICATOR>(pReturnAuthenticatorOut);

                IntPtr pBuffer = outParamList[6];
                Buffer = IntPtrUtility.PtrToArray<byte>(pBuffer, BufferSize);

                CountReturned = TypeMarshal.ToNullableStruct<uint>(outParamList[8]);

                TotalEntries = TypeMarshal.ToNullableStruct<uint>(outParamList[9]);

                NextReference = TypeMarshal.ToNullableStruct<uint>(outParamList[10]);

                IntPtr pLastRecordId = outParamList[11];
                LastRecordId = TypeMarshal.ToNullableStruct<_UAS_INFO_0>(pLastRecordId);

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

            pPrimaryName.Dispose();
            pComputerName.Dispose();
            pAuthenticator.Dispose();
            pReturnAuthenticatorIn.Dispose();

            return (NtStatus)retVal;
        }
        public _UAS_INFO_0 CreateUasInfo0(
            string computerName,
            uint timeCreated,
            uint serialNumber)
        {
            const int COMPUTER_NAME_LENGTH = 16;

            if (computerName == null)
            {
                throw new ArgumentNullException("computerName");
            }
            if (computerName.Length > COMPUTER_NAME_LENGTH)
            {
                throw new ArgumentException("computerName exceeded its max length (16 bytes).", "computerName");
            }

            _UAS_INFO_0 uasInfo0 = new _UAS_INFO_0();
            uasInfo0.ComputerName = ArrayUtility.ConcatenateArrays(
                Encoding.ASCII.GetBytes(computerName),
                new byte[COMPUTER_NAME_LENGTH - computerName.Length]);
            uasInfo0.TimeCreated = timeCreated;
            uasInfo0.SerialNumber = serialNumber;
            return uasInfo0;
        }