Enabling Windows Authentication in REST services?I'm implementing a set of REST services using the ServiceHostFactory approach described in Flanders' _Restful.NET_ book (Chapter 5); however the default binding supports only anonymous login to IIS and I must disable Windows Integrated Auth. to get it to work under IIS. I'm trying to figure out how to enable Windows Authentication on the endpoint, but I'm starting with a WebServiceHost instance and don't see how to get at the Endpoint(s) associated with the host. Is it already too late once the host is created? Is there some magic I can use to change the authentication method? Here's my svc file:<br/><br/> <pre lang="x-c#">&lt;%@ ServiceHost Language=&quot;C#&quot; Debug=&quot;true&quot; Service=&quot;PMSAWebServices.Service&quot; Factory=&quot;PMSAWebServices.AppServiceHostFactory&quot;%&gt; using System; using System.ServiceModel; using System.ServiceModel.Activation; using Microsoft.ServiceModel.Web.SpecializedServices; namespace PMSAWebServices { class AppServiceHostFactory : WebServiceHostFactory { protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { System.ServiceModel.Web.WebServiceHost serviceHost = base.CreateServiceHost(serviceType, baseAddresses) as System.ServiceModel.Web.WebServiceHost; return serviceHost; } } }</pre> Thanks in advance.<br/><br/>Bill<hr class="sig">Bill Cohagan© 2009 Microsoft Corporation. All rights reserved.Thu, 16 Jul 2009 20:30:44 Z84245c34-5b45-459c-8daa-52aa137a55c3http://social.msdn.microsoft.com/Forums/en-US/netservices/thread/84245c34-5b45-459c-8daa-52aa137a55c3#84245c34-5b45-459c-8daa-52aa137a55c3http://social.msdn.microsoft.com/Forums/en-US/netservices/thread/84245c34-5b45-459c-8daa-52aa137a55c3#84245c34-5b45-459c-8daa-52aa137a55c3Bill Cohaganhttp://social.msdn.microsoft.com/Profile/en-US/?user=Bill%20CohaganEnabling Windows Authentication in REST services?I'm implementing a set of REST services using the ServiceHostFactory approach described in Flanders' _Restful.NET_ book (Chapter 5); however the default binding supports only anonymous login to IIS and I must disable Windows Integrated Auth. to get it to work under IIS. I'm trying to figure out how to enable Windows Authentication on the endpoint, but I'm starting with a WebServiceHost instance and don't see how to get at the Endpoint(s) associated with the host. Is it already too late once the host is created? Is there some magic I can use to change the authentication method? Here's my svc file:<br/><br/> <pre lang="x-c#">&lt;%@ ServiceHost Language=&quot;C#&quot; Debug=&quot;true&quot; Service=&quot;PMSAWebServices.Service&quot; Factory=&quot;PMSAWebServices.AppServiceHostFactory&quot;%&gt; using System; using System.ServiceModel; using System.ServiceModel.Activation; using Microsoft.ServiceModel.Web.SpecializedServices; namespace PMSAWebServices { class AppServiceHostFactory : WebServiceHostFactory { protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { System.ServiceModel.Web.WebServiceHost serviceHost = base.CreateServiceHost(serviceType, baseAddresses) as System.ServiceModel.Web.WebServiceHost; return serviceHost; } } }</pre> Thanks in advance.<br/><br/>Bill<hr class="sig">Bill CohaganSat, 04 Jul 2009 03:35:41 Z2009-07-04T03:35:41Zhttp://social.msdn.microsoft.com/Forums/en-US/netservices/thread/84245c34-5b45-459c-8daa-52aa137a55c3#27a726d1-dcf7-4250-916c-76679c26a4b1http://social.msdn.microsoft.com/Forums/en-US/netservices/thread/84245c34-5b45-459c-8daa-52aa137a55c3#27a726d1-dcf7-4250-916c-76679c26a4b1Yi-Lun Luohttp://social.msdn.microsoft.com/Profile/en-US/?user=Yi-Lun%20LuoEnabling Windows Authentication in REST services?Hello, are you using service bus? If you're using service bus, currenlty there's no support for Windows Authentication. The only workaround is to use federation. You deploy a Geneva Server in your company, and add the Geneva Server as a trusted issuer to ACS. Then services hosted on service bus will be able to use ACS to authenticate the client.<br/><br/>By the way, service bus does not support svc, so you can't use WebServiceHostFactory. You just create a normal ServiceHost. The listener is on the cloud, not on your local machine. It is only the messages are relayed to your local machine for processing. Even with a normal WCF REST service, WebServiceHostFactory is generally only used in scenarios where you can't use configuration files (for example, the services are constructed dynamically). When hosting a normal WCF service using WebHttpBinding, in most scenarios, it is recommended to use web.config. Windows authentication is supported in the normal WebHttpBinding. But the security for WebHttpBinding is only supported on the transport level, not the message level.<hr class="sig">Lante, shanaolanxing This posting is provided &quot;AS IS&quot; with no warranties, and confers no rights.Mon, 06 Jul 2009 04:15:31 Z2009-07-06T04:15:31Zhttp://social.msdn.microsoft.com/Forums/en-US/netservices/thread/84245c34-5b45-459c-8daa-52aa137a55c3#cda0d3b3-a905-43e0-9db4-1086551ad858http://social.msdn.microsoft.com/Forums/en-US/netservices/thread/84245c34-5b45-459c-8daa-52aa137a55c3#cda0d3b3-a905-43e0-9db4-1086551ad858Bill Cohaganhttp://social.msdn.microsoft.com/Profile/en-US/?user=Bill%20CohaganEnabling Windows Authentication in REST services?<blockquote>Hello, are you using service bus? If you're using service bus, currenlty there's no support for Windows Authentication. The only workaround is to use federation. You deploy a Geneva Server in your company, and add the Geneva Server as a trusted issuer to ACS. Then services hosted on service bus will be able to use ACS to authenticate the client.<br/><br/>By the way, service bus does not support svc, so you can't use WebServiceHostFactory. You just create a normal ServiceHost. The listener is on the cloud, not on your local machine. It is only the messages are relayed to your local machine for processing. Even with a normal WCF REST service, WebServiceHostFactory is generally only used in scenarios where you can't use configuration files (for example, the services are constructed dynamically). When hosting a normal WCF service using WebHttpBinding, in most scenarios, it is recommended to use web.config. Windows authentication is supported in the normal WebHttpBinding. But the security for WebHttpBinding is only supported on the transport level, not the message level. <hr class=sig> Lante, shanaolanxing This posting is provided &quot;AS IS&quot; with no warranties, and confers no rights.</blockquote> <br/>Thank you for your response and I apologize for taking so long to respond. Since I don't know what &quot;service bus&quot; and &quot;Geneva Server&quot; are I don't think I'm using them. I'm just setting up a REST service (per the book/chapter I referenced) and it all works fine (modulo the authentication problem described.) In this case the listener is in fact on my machine, not the cloud as I'm hosting the service using IIS.<br/><br/>So, I think perhaps you've misunderstood my problem.<br/><br/>Regards,<br/> Bill<hr class="sig">Bill CohaganFri, 10 Jul 2009 17:49:56 Z2009-07-10T17:49:56Zhttp://social.msdn.microsoft.com/Forums/en-US/netservices/thread/84245c34-5b45-459c-8daa-52aa137a55c3#c7e1f926-8a14-440f-ba9e-2347615e1140http://social.msdn.microsoft.com/Forums/en-US/netservices/thread/84245c34-5b45-459c-8daa-52aa137a55c3#c7e1f926-8a14-440f-ba9e-2347615e1140Yi-Lun Luohttp://social.msdn.microsoft.com/Profile/en-US/?user=Yi-Lun%20LuoEnabling Windows Authentication in REST services?So you're working with normal WCF. In this case, it is better to post your question in the <a href="http://social.msdn.microsoft.com/Forums/en-US/wcf/threads">WCF forum</a>. This forum is for .NET Services questions.<br/><br/>Anyway, you can enable Windows authentication in a normal WCF REST service by the following configuration:<br/><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"><font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>&lt;</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span> <p><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">bindings</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>&lt;</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span></p> <p><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">webHttpBinding</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>&lt;</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span></p> <p><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">binding</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">name</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">webBinding</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>&lt;</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span></p> <p><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">security</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>&lt;</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span></p> <p><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">transport</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small"> </span></span><span style="color:#ff0000;font-size:x-small"><span style="color:#ff0000;font-size:x-small">clientCredentialType</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">=</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">Windows</span></span><span style="font-size:x-small">&quot;</span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">/&gt;<font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>&lt;/</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span></p> <p><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">security</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>&lt;/</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span></p> <p><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">binding</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>&lt;/</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span></p> <p><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">webHttpBinding</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;<font size=2 color="#0000ff"><font size=2 color="#0000ff"> <p>&lt;/</p> </font></font></span><font size=2 color="#0000ff"> <p> </p> </font></span></p> <p><span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small">bindings</span></span><span style="color:#0000ff;font-size:x-small"><span style="color:#0000ff;font-size:x-small">&gt;</span></span></p><hr class="sig">Lante, shanaolanxing This posting is provided &quot;AS IS&quot; with no warranties, and confers no rights.Mon, 13 Jul 2009 06:39:48 Z2009-07-13T06:39:48Zhttp://social.msdn.microsoft.com/Forums/en-US/netservices/thread/84245c34-5b45-459c-8daa-52aa137a55c3#7c4e3718-129f-4591-ba70-7b9d2ff88e46http://social.msdn.microsoft.com/Forums/en-US/netservices/thread/84245c34-5b45-459c-8daa-52aa137a55c3#7c4e3718-129f-4591-ba70-7b9d2ff88e46Bill Cohaganhttp://social.msdn.microsoft.com/Profile/en-US/?user=Bill%20CohaganEnabling Windows Authentication in REST services?Thanks for the response. Sorry for the misdirection on using this forum.  I actually found it without traversing the tree -- so didn't realize it was Azure specific.<br/><br/>Regards,<br/> Bill<hr class="sig">Bill CohaganThu, 16 Jul 2009 20:30:44 Z2009-07-16T20:30:44Z