/// <summary>
        /// The DsrUpdateReadOnlyServerDnsRecords method will allow an RODC to send a control 
        /// command to a normal (writable) DC for site-specific and CName types of DNS records 
        /// update. For registration, site-specific records should be for the site in which 
        /// RODC resides. For the types of DNS records, see [MS-ADTS] section 7.3.2. Opnum: 48
        /// </summary>
        /// <param name="ServerName">
        /// The custom RPC binding handle (as specified in section 3.5.5.1) that represents 
        /// the connection to the normal (writable) DC.
        /// </param>
        /// <param name="ComputerName">
        /// A null-terminated Unicode string that contains the client computer NetBIOS name.
        /// </param>
        /// <param name="Authenticator">
        /// A pointer to a NETLOGON_AUTHENTICATOR structure (as specified in section 2.2.1.1.5) 
        /// that contains the client authenticator that will be used to authenticate the client.
        /// </param>
        /// <param name="ReturnAuthenticator">
        /// A pointer to a NETLOGON_AUTHENTICATOR structure that contains the server return 
        /// authenticator.
        /// </param>
        /// <param name="SiteName">
        /// A pointer to a null-terminated Unicode string that contains the site name where 
        /// the RODC resides.
        /// </param>
        /// <param name="DnsTtl">
        /// The Time To Live value, in seconds, for DNS records.
        /// </param>
        /// <param name="DnsNames">
        /// A pointer to an NL_DNS_NAME_INFO_ARRAY (section 2.2.1.2.6) structure that contains 
        /// an array of NL_DNS_NAME_INFO structures.
        /// </param>
        public NtStatus DsrUpdateReadOnlyServerDnsRecords(
            string ServerName,
            string ComputerName,
            _NETLOGON_AUTHENTICATOR? Authenticator,
            out _NETLOGON_AUTHENTICATOR? ReturnAuthenticator,
            string SiteName,
            uint DnsTtl,
            ref _NL_DNS_NAME_INFO_ARRAY? DnsNames)
        {
            NtStatus status = rpc.DsrUpdateReadOnlyServerDnsRecords(
                ServerName,
                ComputerName,
                Authenticator,
                out ReturnAuthenticator,
                SiteName,
                DnsTtl,
                ref DnsNames);

            context.ConnectionStatus = status;
            return status;
        }
        /// <summary>
        /// The DsrUpdateReadOnlyServerDnsRecords method will allow an RODC to send a control 
        /// command to a normal (writable) DC for site-specific and CName types of DNS records 
        /// update. For registration, site-specific records should be for the site in which 
        /// RODC resides. For the types of DNS records, see [MS-ADTS] section 7.3.2. Opnum: 48
        /// </summary>
        /// <param name="ServerName">
        /// The custom RPC binding handle (as specified in section 3.5.5.1) that represents 
        /// the connection to the normal (writable) DC.
        /// </param>
        /// <param name="ComputerName">
        /// A null-terminated Unicode string that contains the client computer NetBIOS name.
        /// </param>
        /// <param name="Authenticator">
        /// A pointer to a NETLOGON_AUTHENTICATOR structure (as specified in section 2.2.1.1.5) 
        /// that contains the client authenticator that will be used to authenticate the client.
        /// </param>
        /// <param name="ReturnAuthenticator">
        /// A pointer to a NETLOGON_AUTHENTICATOR structure that contains the server return 
        /// authenticator.
        /// </param>
        /// <param name="SiteName">
        /// A pointer to a null-terminated Unicode string that contains the site name where 
        /// the RODC resides.
        /// </param>
        /// <param name="DnsTtl">
        /// The Time To Live value, in seconds, for DNS records.
        /// </param>
        /// <param name="DnsNames">
        /// A pointer to an NL_DNS_NAME_INFO_ARRAY (section 2.2.1.2.6) structure that contains 
        /// an array of NL_DNS_NAME_INFO structures.
        /// </param>
        public NtStatus DsrUpdateReadOnlyServerDnsRecords(
            string ServerName,
            string ComputerName,
            _NETLOGON_AUTHENTICATOR? Authenticator,
            out _NETLOGON_AUTHENTICATOR? ReturnAuthenticator,
            string SiteName,
            uint DnsTtl,
            ref _NL_DNS_NAME_INFO_ARRAY? DnsNames)
        {
            const ushort opnum = 48;

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

            SafeIntPtr pServerName = Marshal.StringToHGlobalUni(ServerName);
            SafeIntPtr pComputerName = Marshal.StringToHGlobalUni(ComputerName);
            SafeIntPtr pAuthenticator = TypeMarshal.ToIntPtr(Authenticator);
            SafeIntPtr pSiteName = Marshal.StringToHGlobalUni(SiteName);
            SafeIntPtr pDnsNamesIn = TypeMarshal.ToIntPtr(DnsNames);

            paramList = new Int3264[] {
                pServerName,
                pComputerName,
                pAuthenticator,
                IntPtr.Zero,
                pSiteName,
                DnsTtl,
                pDnsNamesIn,
                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[3];
                ReturnAuthenticator = TypeMarshal.ToNullableStruct<_NETLOGON_AUTHENTICATOR>(pReturnAuthenticator);

                IntPtr pDnsNamesOut = outParamList[6];
                DnsNames = TypeMarshal.ToNullableStruct<_NL_DNS_NAME_INFO_ARRAY>(pDnsNamesOut);

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

            pServerName.Dispose();
            pComputerName.Dispose();
            pAuthenticator.Dispose();
            pSiteName.Dispose();
            pDnsNamesIn.Dispose();

            return (NtStatus)retVal;
        }
 public _NL_DNS_NAME_INFO_ARRAY CreateNlDnsNameInfoArray(params _NL_DNS_NAME_INFO[] nlDnsNameInfoArray)
 {
     _NL_DNS_NAME_INFO_ARRAY array = new _NL_DNS_NAME_INFO_ARRAY();
     array.EntryCount = (uint)nlDnsNameInfoArray.Length;
     array.DnsNamesInfo = nlDnsNameInfoArray;
     return array;
 }