/// <summary>
        ///  The DsrAddressToSiteNamesExW method Supported in windows_2000_server,
        ///  windows_xp, windows_server_2003, windows_vista, windows_server_2008,
        ///  windows_7, windows_server_7. translates a list of socket
        ///  addresses into their corresponding site names and subnet
        ///  names. For information about the mapping from socket
        ///  address to subnet/site name, see [MS-ADTS] sections
        ///   and . Opnum: 37 
        /// </summary>
        /// <param name="ComputerName">
        ///  The custom RPC binding handle (section) that represents
        ///  the connection to a domain controller.
        /// </param>
        /// <param name="EntryCount">
        ///  The number of socket addresses specified in SocketAddresses.
        ///  The maximum value for EntryCount is 32000.To avoid
        ///  large memory allocations, the number of 32,000 was
        ///  chosen as a reasonable limit for the maximum number
        ///  of socket addresses that this method accepts.
        /// </param>
        /// <param name="SocketAddresses">
        ///  An array of NL_SOCKET_ADDRESS structures (section )
        ///  that contains socket addresses to translate. The number
        ///  of addresses specified MUST be equal to EntryCount.
        /// </param>
        /// <param name="SiteNames">
        ///  A pointer to an NL_SITE_NAME_EX_ARRAY structure (section
        ///  ) that contains an array of site names and an array
        ///  of subnet names that correspond to socket addresses
        ///  in SocketAddresses. The number of entries returned
        ///  is equal to EntryCount. An entry is returned as NULL
        ///  if the corresponding socket address does not map to
        ///  any site, or if the address family of the socket address
        ///  is not IPV4 or IPV6. The mapping of IP addresses to
        ///  sites is specified in [MS-ADTS] section.
        /// </param>
        public NetApiStatus DsrAddressToSiteNamesExW(
            string ComputerName,
            uint EntryCount,
            _NL_SOCKET_ADDRESS[] SocketAddresses,
            out _NL_SITE_NAME_EX_ARRAY? SiteNames)
        {
            const ushort opnum = 37;

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

            //CLIENT_CALL_RETURN _RetVal;
            //_RetVal = NdrClientCall2(
            //return ( NET_API_STATUS  )_RetVal.Simple;

            SafeIntPtr pComputerName = Marshal.StringToHGlobalUni(ComputerName);
            SafeIntPtr pSocketAddresses = TypeMarshal.ToIntPtr(SocketAddresses);

            paramList = new Int3264[] {
                pComputerName,
                EntryCount,
                Marshal.ReadIntPtr(pSocketAddresses),
                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 pSiteNames;
                pSiteNames = (IntPtr)outParamList[3];
                pSiteNames = Marshal.ReadIntPtr(pSiteNames);
                SiteNames = TypeMarshal.ToNullableStruct<_NL_SITE_NAME_EX_ARRAY>(pSiteNames);

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

            pComputerName.Dispose();
            pSocketAddresses.Dispose();

            return (NetApiStatus)retVal;
        }
Ejemplo n.º 2
0
 /// <summary>
 ///  The DsrAddressToSiteNamesExW method Supported in windows_2000_server,
 ///  windows_xp, windows_server_2003, windows_vista, windows_server_2008,
 ///  windows_7, windows_server_7. translates a list of socket
 ///  addresses into their corresponding site names and subnet
 ///  names. For information about the mapping from socket
 ///  address to subnet/site name, see [MS-ADTS].
 ///  Opnum: 37 
 /// </summary>
 /// <param name="computerName">
 ///  The custom RPC binding handle that represents
 ///  the connection to a domain controller.
 /// </param>
 /// <param name="entryCount">
 ///  The number of socket addresses specified in SocketAddresses.
 ///  The maximum value for EntryCount is 32000.To avoid
 ///  large memory allocations, the number of 32,000 was
 ///  chosen as a reasonable limit for the maximum number
 ///  of socket addresses that this method accepts.
 /// </param>
 /// <param name="socketAddresses">
 ///  An array of NL_SOCKET_ADDRESS structures 
 ///  that contains socket addresses to translate. The number
 ///  of addresses specified MUST be equal to EntryCount.
 /// </param>
 /// <param name="siteNames">
 ///  A pointer to an NL_SITE_NAME_EX_ARRAY structure 
 ///  that contains an array of site names and an array
 ///  of subnet names that correspond to socket addresses
 ///  in SocketAddresses. The number of entries returned
 ///  is equal to EntryCount. An entry is returned as NULL
 ///  if the corresponding socket address does not map to
 ///  any site, or if the address family of the socket address
 ///  is not IPV4 or IPV6. The mapping of IP addresses to
 ///  sites is specified in [MS-ADTS].
 /// </param>
 /// <returns>
 /// The method returns 0x00000000 on success; 
 /// otherwise, it returns a nonzero error code.
 /// </returns>
 public NetApiStatus DsrAddressToSiteNamesExW(
     string computerName,
     uint entryCount,
     _NL_SOCKET_ADDRESS[] socketAddresses,
     out _NL_SITE_NAME_EX_ARRAY? siteNames)
 {
     return rpc.DsrAddressToSiteNamesExW(
         computerName,
         entryCount,
         socketAddresses,
         out siteNames);
 }