.NET Framework Bookmark and Share   
 index > Windows Communication Foundation > Custom WCF Service in SharePoint - Authentication Problems
 

Custom WCF Service in SharePoint - Authentication Problems

Hi, I couldn't find the answer to this question in this forum but apologies if it exists.

I have a WCF service, using basicHttpBinding, which talks to the sharepoint object model toget some search queries back. Thisworks inthe virtual hosting environment. I have hosted the .svc file in a virtual directory (called "_wcf")on the SharePoint server, with the DLL for the service in the GAC. When I put in http://servername/_wcf/servicename.svc i can seethe service.

To make matters more yucky, I have a Silverlight application hosted in this SharePoint in a web part. The silverlight application references the above service, however when it comes to using it (at runtime)it prompts me for a login box. Do I need to pass some sort of authentication in the config file? If so, the client config or the service config?! Also, could it maybe a possibility that I just have a bug in the DLL of my service and it's trying to find authentication to debug it? (The last one might be something I just made up)

Hope this makes sense, TIA

M.
Michael Dent
Yeah, I was using Windows instead of Ntlm (not sure what or why the difference is), when it got down to it this was the most important part:

<basicHttpBinding>
<binding name="myBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>

in the service config.

Thanks for all your help.
Michael Dent
Windows Authentication is also named NTLM. It just turns out that different section of the config calls it differently.

Glad to hear it works now!
Christopher Scrosati, Software Design Engineer, WCF Silverlight, Microsoft Corp.
Christopher Scrosati - MSFT
You might want to investigate the security implication of accessing your service. If you use NTLM, or Basic or anything else, you will have to authenticate at some point.

Silverlight will default to asking the user credential when Basic is the authentication method. There are other scenarios. Take a look at this article:

http://msdn.microsoft.com/en-us/library/dd560705(VS.95).aspx
Christopher Scrosati, Software Design Engineer, WCF Silverlight, Microsoft Corp.
Christopher Scrosati - MSFT
Yeah I don't want to doit this way butwe have been told Silverlight is shiny, therefore we can't have the in-built sharepoint search it has to be in silverlight.

It was pretty much a given that it would ask me for authentication, however what I was getting at is how would I authenticate - do I put any parameters in the client/service config? The articles you sent me were quite helpful. Would it just be a case <authentication mode="Windows"/> in the service config? This seems too easy. Ideally I would like the serviceto run as the currently logged in user in sharepoint (our instance just uses windows authentication), although I'm not sure how I would do this as it can't get the current context.

Cheers again, Mike.
Michael Dent
Also, why does the service work in a console application, but in the silverlight app it prompts me for a windows authentication?! I assume because the console app is running as the current windows user, but it's really frustrating trying to get the Silverlight app to do the same. I may be being slow but this is massively important to me, any suggestions would be greatly appreciated.
Michael Dent
Yep, enabling Windows Authentication (NTLM) is as simple as that if your web host is ASP.NET.

Assuming you tried to use the solution proposed in the article, it would then seems to me like your browser might not be transferring the Windows credentials properly.

Double check IE settings asproposed at the end of the Windows Authentication article. There is also ways to enable NTLM authentication in other browsers, so if you test within these, check that this is also enable in there.
Christopher Scrosati, Software Design Engineer, WCF Silverlight, Microsoft Corp.
Christopher Scrosati - MSFT
Yeah, I was using Windows instead of Ntlm (not sure what or why the difference is), when it got down to it this was the most important part:

<basicHttpBinding>
<binding name="myBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>

in the service config.

Thanks for all your help.
Michael Dent
Windows Authentication is also named NTLM. It just turns out that different section of the config calls it differently.

Glad to hear it works now!
Christopher Scrosati, Software Design Engineer, WCF Silverlight, Microsoft Corp.
Christopher Scrosati - MSFT

You can use google to search for other answers

Custom Search

More Threads

• NetDataContractSerializer, inheritance, assemblies.
• How to find the no. of Clients using my WCF Service
• MSMQ and WCF (client and service on different machines)
• Proxy Generation Problem
• Viewing WCF enrypted message
• Slow WCF Async Implementation?
• WCF WebService: Constructor?
• Sending large strings to a WCF web service
• Trouble implementing custom exception
• ChannelFactory Connection Trouble