title: Authentication error sending messages to Windows Service Bus 1.0 on AWS
body: <p>I am trying to send and receive messages from a local workgroup machine (Windows 7), call it the 'client', to Service Bus 1.0 set up on a workgroup server (hosted on AWS EC2). After many trials and research I'm unable to send messages from the client machine to the server. I've followed a number of articles that appear to indicate that it is possible to do, but I cannot resolve the authentication issue I'm seeing.</p>
  
  <p><a href="https://stackoverflow.com/questions/12462894/connecting-to-windows-server-service-bus-on-aws">Connecting to Windows Server Service Bus on AWS</a></p>
  
  <p><a href="https://stackoverflow.com/questions/15398665/microsoft-service-bus-on-a-windows-workgroup">Microsoft Service Bus on a Windows Workgroup</a></p>
  
  <p>I note the Microsoft system requirements appears to indicate that it is "not supported" and "not possible". My question is can this be done, and has anyone had success? Any help would be greatly appreciated.</p>
  
  <p>msdn.microsoft.com/en-us/library/windowsazure/jj193011(v=azure.10).aspx</p>
  
  <p>My attempts include using either the WindowsTokenProvider and OAuthTokenProvider. I get the same result:</p>
  
  <p>System.UnauthorizedAccessException: The token provider was unable to provide a security token while accessing '<a href="https://xx.xx.xx.xx:9355/ServiceBusDefaultNamespace/" rel="nofollow noreferrer">https://xx.xx.xx.xx:9355/ServiceBusDefaultNamespace/</a>$STS/Windows/'. Token provider returned message: ''. ---> System.IdentityModel.Tokens.SecurityTokenException: The token provider was unable to provide a security token while accessing '<a href="https://xx.xx.xx.xx:9355/ServiceBusDefaultNamespace/" rel="nofollow noreferrer">https://xx.xx.xx.xx:9355/ServiceBusDefaultNamespace/</a>$STS/Windows/'. Token provider returned message: ''. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.</p>
  
  <p>The Service Bus namespace is set up with AddressingScheme "Path" for a workgroup install. And the client side connection string includes the IP to reach the server, and I've set a RemoteCertificateValidationCallback before creating the queues.</p>
  
  <pre><code>Endpoint=sb://xx.xx.xx.xx/ServiceBusDefaultNamespace;StsEndpoint=https://xx.xx.xx.xx:9355/ServiceBusDefaultNamespace;RuntimePort=9354;ManagementPort=9355;WindowsUsername=SBUser;WindowsDomain=[NotUsed];WindowsPassword=[Password]
  </code></pre>
  
  <p>Code to attach to the remote queue and send a message is as follows:</p>
  
  <pre><code>ServiceBusConnectionStringBuilder connBuilder = new ServiceBusConnectionStringBuilder(ConfigurationManager.AppSettings["Microsoft.ServiceBus.ConnectionString"]); // Gets the connection string above
  TokenProvider tokenProvider = WindowsTokenProvider.CreateWindowsTokenProvider(connBuilder.StsEndpoints, new NetworkCredential(connBuilder.WindowsCredentialUsername, connBuilder.WindowsCredentialPassword));
  MessagingFactorySettings messagingFactorySettings = new MessagingFactorySettings();
  messagingFactorySettings.TokenProvider = tokenProvider;
  MessagingFactory messagingFactory = MessagingFactory.Create(connBuilder.GetAbsoluteRuntimeEndpoints(), messagingFactorySettings);
  requestQueue = messagingFactory.CreateQueueClient("RequestQueue");
  ...
  requestQueue.Send(sendMessage);  // Fails here
  </code></pre>
  
  <p>The server account is SBUser with a password and I have left the domain/host specified blank on the token provider. I note that the Event Viewer on the server shows the authentication being attempted is the client's user account not the one from the token provider. Why is this? I'm obviously missing something in order to authenticate on the server.</p>
  
  <pre><code>An account failed to log on.
  
  Subject:
    Security ID: NULL SID
    Account Name: -
    Account Domain: -
    Logon ID: 0x0
  
  Logon Type: 3
  
  Account For Which Logon Failed:
    Security ID: NULL SID
    Account Name: [ClientLogin]
    Account Domain: [ClientMahcine]
  
  Failure Information:
    Failure Reason: Unknown user name or bad password.
    Status: 0xc000006d
    Sub Status: 0xc0000064
  </code></pre>
  
  <p>Appreciate any help. Thanks.</p>