I am running c# code on farm1 to get user profile picture from mysite web app which is hosted in farm2.
siteUrl = "https://mysite";
url = "https://mysite/User%20Photos/Profile%20Pictures/USER1_SThumb.jpg"
using (SPSite site = new SPSite(siteUrl, SPUserToken.SystemAccount))
{
using (SPWeb web = site.OpenWeb())
{
file = web.GetFile(url);
if (file.Exists)
{
strBase64 = "\n" + Convert.ToBase64String(file.OpenBinary()) + "\n";
}
else
{
//get Default image base64 sample
strBase64 = "\n/9j/4AAQSkZJRgABAQEAYABg........oA//2Q==\n";
}
}
}
new SPSite(siteUrl, SPUserToken.SystemAccount) gives me system.io.filenotfoundexception. the web applicationhttps://mysite could not be found. Verify that you have typed the url correctly. if the url should be serving existin content, the system administrator may need to add a new request url mapping to the intended application.
I am running this code on http://webapp1 and it cannot reach the mysite webapp. Please advise how to pass the credentials. Note that the Timer service account of webapp1 has read access to mysiteqa and all user pictures
I don't want to type the password/username in the code. Both web applications are using windows authentication.