I have install a fresh version of SharePoint 2019 which is on domain A,then i added a second computer to A which will be hosting websites on IIS.
I have created a console application just for testing connection to SharePoint on the second computer using the code below and am getting unauthorized access.Is there anything wrong with the code below?. Note the credentials are correct.
System.Net.NetworkCredential cred = new System.Net.NetworkCredential(@"DoaminNAme\administrator","Password");
using (ClientContext clientContext = new ClientContext("http://10.1.1.1/sharepoint2019/sites/test/"))
{
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
clientContext.Credentials = cred;
Microsoft.SharePoint.Client.ClientResult<System.IO.Stream> stream = null;
KeywordQuery keywordQuery = new KeywordQuery(clientContext);
keywordQuery.QueryText = "SharePoint";
keywordQuery.EnablePhonetic = true;
keywordQuery.EnableOrderingHitHighlightedProperty = true;
//keywordQuery.SummaryLength = 500;
SearchExecutor searchExecutor = new SearchExecutor(clientContext);
ClientResult<ResultTableCollection> results = searchExecutor.ExecuteQuery(keywordQuery);
clientContext.ExecuteQuery();
NetworkCredential
s, too. I have never useddomain\\user
when usingNetworkCredential
. I always usenew NetworkCredential ("user", "password", "domain");
https://sharepoint.server/sites/sitename