用代码访问sharepoint link时,提示Identity Client Runtime Library (IDCRL) could not look up the realm information for a federated sign-in.

骏 高 1 信誉分
2025-09-18T04:54:24.3433333+00:00

使用C#编写了以下代码,试图访问sharepoint的link,

程序执行过程中提示错误:

Identity Client Runtime Library (IDCRL) could not look up the realm information for a federated sign-in.

程序代码:

using Microsoft.SharePoint.Client;

using System;

using (ClientContext context = new ClientContext(SiteURL)

            {

                try

                {

                    // 初始化保存账号密码的变量并保存密码

                    var securePassword = new System.Security.SecureString();

                    foreach (char c in password)

                    {

                        securePassword.AppendChar(c);

                    }

                    // 通过API生成访问sharepoint的凭据

                    context.Credentials = new SharePointOnlineCredentials(userName, securePassword);

                    Web web = context.Web;

                    context.Load(web);

                    context.ExecuteQuery();  -》这里执行时报错。参考程序执行时的错误内容

                }

                catch (Exception ex)

                {

                    CommonUtils.Log(clazzName + ": checkStandardFileLinkAccessToVisit():Error :" + ex.Message);

                    Console.WriteLine(ex.Message);

                    return false;

                }

            }

程序执行时的错误内容:

Identity Client Runtime Library (IDCRL) could not look up the realm information for a federated sign-in.

希望回复的内容:

1.以上代码执行时出错的原因是什么?

2.如何解决?使代码可以成功访问sharepoint link?

希望回复期限:

2025/9/18 17:00(该问题比较着急,希望能尽快回复。)

Microsoft 365 和 Office | SharePoint | 商业版 | Windows
0 个注释 无注释