Did not get a response from the Login server (IDCRL) - SharePoint

Braian Anderson 20 Reputation points
2024-08-22T16:58:09.3033333+00:00

Hello, I tried this CSOM code to upload files to my SharePoint:

var securePassword = new SecureString();
  foreach (char c in password)
  {
      securePassword.AppendChar(c);
  }
  using (var clientContext = new ClientContext(siteUrl))
  {
      clientContext.Credentials = new SharePointOnlineCredentials(email, securePassword);
      Web web = clientContext.Web;
      clientContext.Load(web, a => a.ServerRelativeUrl);
      clientContext.ExecuteQuery();
      Microsoft.SharePoint.Client.List documentsList = clientContext.Web.Lists.GetByTitle(driveId);
      var fileCreationInformation = new FileCreationInformation();
      //Assign to content byte[] i.e. documentStream
      fileCreationInformation.Content = System.IO.File.ReadAllBytes(filePath);
      //Allow owerwrite of document
      fileCreationInformation.Overwrite = true;
      //Upload URL
      fileCreationInformation.Url = siteUrl + driveId + fileName;
        
      Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(fileCreationInformation);
      //Update the metadata for a field having name "DocType"
      uploadFile.ListItemAllFields["Title"] = "UploadedviaCSOM";
      uploadFile.ListItemAllFields.Update();
      clientContext.ExecuteQuery();
  }

but I'm encountering the following error: 'Identity Client Runtime Library (IDCRL) did not get a response from the Login server.' when attempting to execute the first clientContext.ExecuteQuery();.

Could you please advise on what needs to be done to resolve this error? Is there any modification required on the account to grant access?

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,030 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Ling Zhou_MSFT 18,095 Reputation points Microsoft Vendor
    2024-08-23T02:16:45.1733333+00:00

    Hi @Braian Anderson,

    Thank you for posting in this community.

    Based on the information you provided about the problem, it seems that the problem is on your login credentials, please follow these steps to gradually narrow down the cause of the problem:

    1.Please check the account of user is similar to user@yourdomain.onmicrosoft.com. (I know it's simple, but sometimes the wrong suffix can cause this problem.)

    2.Make sure that your users have access to the site, you can check the user's permissions according to this article: 2 ways to see what users have access to in SharePoint.

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link. 

    3.Multi-Factor Authentication (MFA):

    If MFA is enabled on your user, then you can refer to this article to use MFA to log in to your site:

    Connect MFA enabled SharePoint site using CSOM

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link. 

    Or you can choose to turn off MFA for your user: Turn off per-user MFA.

    4.Network Issues: Check if there are any network issues that might be preventing your client from reaching the login server. This could include firewall settings or proxy configurations.

    5.Are other users with same permissions facing the same problem? View through another computer or account.

    6.Whether all SharePoint sites have the same problem? You could create a new SharePoint site to check.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.


  2. Ling Zhou_MSFT 18,095 Reputation points Microsoft Vendor
    2024-08-26T01:40:59.5333333+00:00

    Hi @Braian Anderson,

    I noticed that you are using SharePointOnlineCredentials, but your tag indicates that you are having a problem with the SharePoint server.

    You are using SharePointOnlineCredentials which is meant to be used when connecting to Office 365 tenants. You should connect to SharePoint on-premise by other means, depending on the authentication methods available on your server.

    So you should instead assign ClientContext.Credentials with an instance of NetworkCredential, see NetworkCredential on MSDN.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.


  3. Ling Zhou_MSFT 18,095 Reputation points Microsoft Vendor
    2024-08-27T01:31:29.9466667+00:00

    Hi @Braian Anderson,

    According to the definition of NetworkCredential, its three parameters are, username, password, and domain name. You can try the code below.

    User's image

    using System;
    using System.Net;
    using Microsoft.SharePoint.Client;
    namespace SharePointCSOM
    {
        class Program
        {
            static void Main(string[] args)
            {
                string siteUrl = "https://yoursharepointsite.com";
                string username = "yourusername";
                string password = "yourpassword";
                string domain = "yourdomain";
                NetworkCredential credentials = new NetworkCredential(username, password, domain);
                using (ClientContext context = new ClientContext(siteUrl))
                {
                    context.Credentials = credentials;
                    Web web = context.Web;
                    context.Load(web);
                    context.ExecuteQuery();
                    Console.WriteLine("Title: " + web.Title);
                }
            }
        }
    }
    

    If the answer is helpful, please click"Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    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.


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.