/// <summary>
 ///  The NetrGetForestTrustInformationSupported in windows_2000_server,
 ///  windows_xp, windows_server_2003, windows_vista, and
 ///  windows_server_2008, windows_7, and windows_server_7.
 ///  method retrieves the trust information for the forest
 ///  of which the member's domain is itself a member. Opnum: 44 
 /// </summary>
 /// <param name="serverName">
 ///  The custom RPC binding handle.
 /// </param>
 /// <param name="computerName">
 ///  The null-terminated Unicode string that contains the
 ///  client computer NetBIOS name.
 /// </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="flags">
 ///  MUST be set to zero and MUST be ignored on receipt.
 /// </param>
 /// <param name="forestTrustInfo">
 ///  A pointer to an LSA_FOREST_TRUST_INFORMATION structure,
 ///  as specified in [MS-LSAD], that contains data
 ///  for each foresttrust.
 /// </param>
 /// <returns>
 /// The method returns 0x00000000 on success; 
 /// otherwise, it returns a nonzero error code.
 /// </returns>
 public NtStatus NetrGetForestTrustInformation(
     string serverName,
     string computerName,
     _NETLOGON_AUTHENTICATOR? authenticator,
     out _NETLOGON_AUTHENTICATOR? returnAuthenticator,
     uint flags,
     out _LSA_FOREST_TRUST_INFORMATION? forestTrustInfo)
 {
     return rpc.NetrGetForestTrustInformation(
         serverName,
         computerName,
         authenticator,
         out returnAuthenticator,
         flags,
         out forestTrustInfo);
 }
        /// <summary>
        ///  The DsrGetForestTrustInformation methodSupported in
        ///  windows_xpwindows_server_2003, windows_vista, windows_server_2008,
        ///  windows_7, and windows_server_7. retrieves the trust
        ///  information for the forest of the specified domain
        ///  controller, or for a forest trusted by the forest of
        ///  the specified DC. Opnum: 43 
        /// </summary>
        /// <param name="ServerName">
        ///  The custom RPC binding handle, as specified in section
        ///  .
        /// </param>
        /// <param name="TrustedDomainName">
        ///  The optional null-terminated Unicode string that contains
        ///  the DNS or NetBIOS name of the trusted domain for which
        ///  the forest trust information is to be gathered.
        /// </param>
        /// <param name="Flags">
        ///  A set of bit flags that specify additional applications
        ///  for the forest trust information. A flag is TRUE (or
        ///  set) if its value is equal to 1.
        /// </param>
        /// <param name="ForestTrustInfo">
        ///  A pointer to an LSA_FOREST_TRUST_INFORMATION structure,
        ///  as specified in [MS-LSAD] section , that contains data
        ///  for each foresttrust.
        /// </param>
        public NetApiStatus DsrGetForestTrustInformation(
            string ServerName,
            string TrustedDomainName,
            uint Flags,
            out _LSA_FOREST_TRUST_INFORMATION? ForestTrustInfo)
        {
            const ushort opnum = 43;

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

            SafeIntPtr pServerName = Marshal.StringToHGlobalUni(ServerName);
            SafeIntPtr pTrustedDomainName = Marshal.StringToHGlobalUni(TrustedDomainName);

            paramList = new Int3264[] {
                pServerName,
                pTrustedDomainName,
                Flags,
                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 pForestTrustInfo = outParamList[3];
                pForestTrustInfo = Marshal.ReadIntPtr(pForestTrustInfo);
                ForestTrustInfo = TypeMarshal.ToNullableStruct<_LSA_FOREST_TRUST_INFORMATION>(pForestTrustInfo);

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

            pServerName.Dispose();
            pTrustedDomainName.Dispose();

            return (NetApiStatus)retVal;
        }
 /// <summary>
 ///  The DsrGetForestTrustInformation methodSupported in
 ///  windows_xpwindows_server_2003, windows_vista, windows_server_2008,
 ///  windows_7, and windows_server_7. retrieves the trust
 ///  information for the forest of the specified domain
 ///  controller, or for a forest trusted by the forest of
 ///  the specified DC. Opnum: 43 
 /// </summary>
 /// <param name="serverName">
 ///  The custom RPC binding handle.
 /// </param>
 /// <param name="trustedDomainName">
 ///  The optional null-terminated Unicode string that contains
 ///  the DNS or NetBIOS name of the trusted domain for which
 ///  the forest trust information is to be gathered.
 /// </param>
 /// <param name="flags">
 ///  A set of bit flags that specify additional applications
 ///  for the forest trust information. A flag is TRUE (or
 ///  set) if its value is equal to 1.
 /// </param>
 /// <param name="forestTrustInfo">
 ///  A pointer to an LSA_FOREST_TRUST_INFORMATION structure,
 ///  as specified in [MS-LSAD], that contains data
 ///  for each foresttrust.
 /// </param>
 /// <returns>
 /// The method returns 0x00000000 on success; 
 /// otherwise, it returns a nonzero error code.
 /// </returns>
 public NetApiStatus DsrGetForestTrustInformation(
     string serverName,
     string trustedDomainName,
     NrpcDsrGetForestTrustInformationFlags flags,
     out _LSA_FOREST_TRUST_INFORMATION? forestTrustInfo)
 {
     return rpc.DsrGetForestTrustInformation(
         serverName,
         trustedDomainName,
         (uint)flags,
         out forestTrustInfo);
 }