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 = "";
SPSecurity.RunWithElevatedPrivileges(delegate
{
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 !