I have been developing on SP 2010 for a while now. Mostly I have been working with the Client Object Model.

Though I am at a point where I need to read out the UserProfiles from inside SharePoint.

I see no other way to do this than to make a custom WCFService and deploy it to SharePoint.

So that is what I did. I made an "Empty SharePoint Project" and added the mapped "ISAPI" folder.

The code from the WCF Service:

public string GetUserByName(string _name)
        string server = "http://esddev72";
        UserProfileManager profileManager;
        string s = "";
        string u = "";
             using (SPSite site = new SPSite(server))
                 SPServiceContext context = SPServiceContext.GetContext(site);
                 profileManager = new UserProfileManager(context, true);
                 s += "AccountNames: ";
                 u += "firstNames: ";
                 foreach (UserProfile profile in profileManager)
                     if (profile["AccountName"] != null)
                         s += profile["AccountName"] + " - ";
                     if (profile["FirstName"] != null)

        return s;

This service gives a TimeOut error... When I delete the following line the TimeOut is fixed

if (profile["FirstName"] != null)

So I can only read out the AccountName... Does anyone know a solution to this?

I've read things about putting the timeout times higher, but it didn't work for me... Or maybe I did someting wrong, so if you could explain that part as well ;)

Thanks !

  • Frederik: I saw your moderator request and I just tweeted a link to this for you. Sorry I don't have any idea about the answer; hopefully someone else will. Also try the MSDN Forums if you don't get and answer here. May 12, 2010 at 12:31
  • Thanks Marc. I would realy want to know what is going wrong. I needed it in a project but since it kept failing i replaced it with an asmx webservice. But still, it should have to be possible to get a wcf service to work i guess... May 26, 2010 at 7:33

4 Answers 4


Well at this moment i solved it by using .asmx webservices... But still no idea how to solve the WCF TimeOut tho...


Try PropertyConstants.



  • Thanks for the response, but i have already tried PropertyConstants and it did not work... I'll say again: The code IS working when i run it through a console application. But i need to get the UserProfiles in Silverlight so i have to use a WCF Custom Service to fetch the UserProfiles. And its here that it is going wrong ... May 25, 2010 at 10:33

Did you deploy the service in the recommended SharePoint way? i.e. write the code and deploy a .svc file that references that class but uses the out of the box SharePoint factory i.e:

<%@ ServiceHost Language="C#" Debug="true" Service="YOURCLASS, YOURASSEMBLY, Version=, Culture=neutral, PublicKeyToken=TOKEN" Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>

Yould also decorate your service class wit the following attributes

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
[ServiceBehavior(Namespace = "http://servicenamespace/", IncludeExceptionDetailInFaults=true)] // IncludeExceptionDetailInFaults not required of course

By doing this the service will be running as if it were in SharePoint and you can even use SPCOntext.Current. Security is also automatically done because it will be run by SharePoint.


<binding name="BasicHttpBinding_myWCF" receiveTimeout="00:20:00" openTimeout="00:20:00" closeTimeout="00:20:00"

sendTimeout="00:20:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">

<security mode="None" />


and in the web.config of the WCF service:



<binding name="Binding1" receiveTimeout="00:20:00" sendTimeout="00:20:00" openTimeout="00:20:00" closeTimeout="00:20:00"

maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>



the web service method still times out after 1 minute and raises an exception in the client.

Also the

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  • So you're suggesting the solution is to increase the timeout to be 20 minutes?
    – Benny Skogberg
    Sep 5, 2014 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.