static void SendOneWayQuery(string query) { #region Authorizing on remote machine // Get rights to access remote machine. // // If you use anonymous conection than you need to apply server's LSA (LocalSecurityAuthority) rules: // - permit Guest connection over network. // - activate Guest user. // Without this conection will terminated by server. // // Relative to setting of pipes also could be required: // - anonymous access to named pipes // // ATTENTION: Message will not be encrypted before post. // User SetRoutingInstruction (whrer instruction has RSAEncryption fields as true) instead TryLogon. bool logonResult = General.TryToLogonAtRemoteDevice( routingInstruction.logonConfig, out SafeAccessTokenHandle safeTokenHandle); if (!logonResult) { Console.WriteLine("Logon failed. Connection not possible.\nPress any key..."); Console.ReadKey(); return; } #endregion // Create transmission line. TransmissionLine lineProcessor = OpenOutTransmissionLineViaPP(SERVER_NAME, SERVER_PIPE_NAME); // Set impersonate token. lineProcessor.accessToken = safeTokenHandle; // Add sample query to queue. You can use this way if you not need answer from server. lineProcessor.EnqueueQuery(new Query(query)); }
/// <summary> /// Adds a query to the queue. /// Opens a backward line that will calls an answer handler. /// </summary> /// <param name="line">Line proccessor that control queries posting to target server.</param> /// <param name="query">Query that will sent to server.</param> /// <param name="answerHandler">Callback that will recive answer.</param> public static void EnqueueDuplexQueryViaPP( TransmissionLine line, UniformQueries.Query query, Action <TransmissionLine, UniformQueries.Query> answerHandler) { // Add our query to line processor queue. line.EnqueueQuery(query); // Open backward chanel to recive answer from server. ReceiveDelayedAnswerViaPP(line, query, answerHandler); }