Authenticate MSMQ message with alternate credentials?

I wrote a C # application that puts an XML object in an MSMQ queue. The queue requires authentication.

MessageQueue queue = GetQueue();
var message = new Message();
message.Formatter = new CustomXMLFormatter();
message.Body = xml.ToString();
message.Label = "From my application";
message.UseAuthentication = true;
queue.Send(message, MessageQueueTransactionType.Single);

It all works today, but now I need to make changes to the authentication method. Currently, messages are authenticated using the user starting the application. However, I want to use the istead static AD user. (The reason is that the system receiving the messages needs all messages to be added by one user account).

Is there a way to change which user authenticates?

+3
source share
1 answer

Impersonator. , , . - , AD Directory.

, :

using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) )
{
   ...

   <code that executes under the new context>

   ...
}
0

Source: https://habr.com/ru/post/1736378/


All Articles