SharePoint 2010 Custom WCF Service - Windows and FBA Authentication -
i have sharepoint 2010 configured claims based authentication both windows , forms based authentication (fba) external users. need develop custom wcf services. issue want windows credentials passed wcf service(s); however, cannot seem windows credentials passed services. custom wcf service appears using anonymous authentication (which has enabled in iis in order display fba login screen).
the example have tried follow found @ http://msdn.microsoft.com/en-us/library/ff521581.aspx.
the wcf service gets deployed _vti_bin (isapi folder).
here code .svc file
<%@ servicehost language="c#" debug="true" service="mycompany.customerportal.sharepoint.ui.isapi.mycompany.services.librarymanagers.libraryuploader, $sharepoint.project.assemblyfullname$" factory="microsoft.sharepoint.client.services.multiplebaseaddressbasichttpbindingservicehostfactory, microsoft.sharepoint.client.serverruntime, version=14.0.0.0, culture=neutral, publickeytoken=71e9bce111e9429c" codebehind="libraryuploader.svc.cs" %>
here code behind .svc file
[servicecontract] public interface ilibraryuploader { [operationcontract] string sitename(); } [basichttpbindingservicemetadataexchangeendpoint] [aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.required)] public class libraryuploader : ilibraryuploader { //just try return site title right now… public string sitename() { windowsidentity identity = servicesecuritycontext.current.windowsidentity; claimsidentity claimsidentity = new claimsidentity(identity); return spcontext.current.web.title; } }
the wcf test client have test out (wpf app) uses following code call wcf service...
private void button1click(object sender, routedeventargs e) { basichttpbinding binding = new basichttpbinding(); binding.security.mode = basichttpsecuritymode.transportcredentialonly; binding.security.transport.clientcredentialtype = httpclientcredentialtype.ntlm; endpointaddress endpoint = new endpointaddress( "http://dev.portal.data-image.local/_vti_bin/mycompany.services/librarymanagers/libraryuploader.svc"); libraryuploaderclient libraryuploader = new libraryuploaderclient(binding, endpoint); libraryuploader.clientcredentials.windows.allowedimpersonationlevel = system.security.principal.tokenimpersonationlevel.impersonation; messagebox.show(libraryuploader.sitename()); }
i inexperienced iis security settings/configurations when comes claims , trying use both windows , fba. inexperienced when comes wcf configurations security. develop internal biz apps , let visual studio decide use because security concern.
i think figured out answer. key create web.config file , deploy in same folder .svc file. web.config file needs specify binding use "wshttpbinding" instead of "basichttpbinding". removed factory attribute in .svc declaration , basichttpbindingservicemetadataexchangeendpoint attribute on class.
Comments
Post a Comment