Is it strange to access SharePoint Site with HTTPS/ CERT

Will 616 Reputation points
2020-09-11T16:45:14.707+00:00

Hi there,

I have two SharePoint 2019 On Premise Sites (1. Team Site: https://xxx.xxx.xxx; 2. Personal Site: https://yyy.yyy.yyy).

I access two sites by using CSOM sample code from "https://learn.microsoft.com/en-us/archive/blogs/sridhara/working-with-sharepoint-2010-client-object-model-on-an-ssl-enabled-site". It turns out that something weird.

  1. Team Site: Work Well
  2. Personal Site: 401 (Unauthorized)

Does anyone have any idea on it? Thanks

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,347 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,613 questions
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,036 Reputation points
    2020-09-14T07:28:08.95+00:00

    Hi @Will ,

    Per my test, I could not reproduce your issue on my end. I could access mysite normally. My teamsite and Personal site are under same web application.

    You could try to set up the crendentials by below code, check if it works:

    context.Credentials = new NetworkCredential("contoso\\michael", "password");  
    

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Will 616 Reputation points
    2020-09-14T08:10:20.647+00:00

    Hi Michael,

    Thanks for your reply. To be honest, I also used the

    context.Credentials = new NetworkCredential("contoso\michael", "password");

    but cannot get clientContect when we run the clientContext.ExecuteQuery. --> got 401 (Unauthorized). Just only one this My Site Host and try this in four environment (2* standalone and 2* NLB Environments). the problem was happened in one of NLB environment. I list out my code for you to look at. thanks. I think another clue if the client environment settings. (Reverse Proxy).

    ClientContext clientContext = new ClientContext(siteUrl);

            clientContext.Credentials = new NetworkCredential(farmAdmin, password, domain);
            clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
    
            Uri uri = new Uri(siteUrl);
    
            if (uri.Scheme == "https")
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
                ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(customXertificateValidation);
            }
    
            clientContext.Load(clientContext.Site.RootWeb);
            clientContext.ExecuteQuery();
    
            return clientContext;
    
    0 comments No comments

  2. Will 616 Reputation points
    2020-09-14T09:00:21.423+00:00

    Hi Michael,

    I just have it a try to use Server OM to get server context. work well. so no idea on it.?? what do you think?

    thanks

    0 comments No comments

  3. MichaelHan-MSFT 18,036 Reputation points
    2020-09-14T09:51:38.627+00:00

    Hi @Will ,

    I have no idea about this.

    Maybe you could check the IIS log about this issue. Besides, the below similar issue may help you: https://sharepoint.stackexchange.com/questions/10364/http-401-unauthorized-using-the-managed-client-object-model


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  4. sadomovalex 3,631 Reputation points
    2020-09-14T15:21:57.953+00:00

    hello, few questions

    • are you able to open requested sites on NLB environments in browser using the same credentials?
    • is it possible to access these sites on the same env but with disabled NLB? (to check that problem is not related with NLB configuration itself)

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.