SharePoint Office 365使用CSOM登录问题 [英] SharePoint Office365 Signin issue using CSOM

查看:119
本文介绍了SharePoint Office 365使用CSOM登录问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接并从中检索列表我通过CSOM获得Office365 sharepoint门户。在jquery的document.ready函数中,我调用了一个ajax调用。
我使用下面的代码并且工作正常。

[WebMethod]
public static List<myClass> GetDataOnPageLoad()
{
    List<myClass> objmyClass = new List<myClass>();
    string strSiteCollection = "<Site Url>";
    string login = "<username>";
    string password = "<password>";
    SecureString securePassword = new SecureString();
    foreach (char c in password)
        securePassword.AppendChar(c);
    try
    {
        ClientContext Clientcontext = new ClientContext(strSiteCollection);
        Clientcontext.Credentials = new SharePointOnlineCredentials(login, securePassword);
        DataTable dtData = new DataTable();
        dtData.Columns.Add("ID", typeof(string));
        dtData.Columns.Add("UserEmail", typeof(string));
        dtData.Columns.Add("InstalledVersion", typeof(string));
        if (Clientcontext != null)
        {
            List docList = Clientcontext.Web.Lists.GetByTitle("<List Name>");
            Microsoft.SharePoint.Client.ListItemCollection items = docList.GetItems(CamlQuery.CreateAllItemsQuery());
            Clientcontext.Load(items);
            Clientcontext.ExecuteQuery();
            foreach (var item in items)
                dtData.Rows.Add(item["ID"].ToString(), item["UserEmail"].ToString(), item["InstalledVersion"].ToString());
        }
        if (dtData != null && dtData.Rows.Count > 0)
        {
            for (int i = 0; i < dtData.Rows.Count; i++)
            {
                //binding list
            }
        }
    }
    catch (Exception ex)
    {

    }
    return objmyClass;
}





直到现在都很好。


All good till now.


现在我在另一个项目中需要相同的代码。所以我将其复制并粘贴到新项目中。包含sharepoint客户端DLL。从ajax调用这个。现在,当我运行这个新项目时,它给出了Clientcontext.ExecuteQuery();例外
表示:  合作伙伴返回了错误的登录名或密码错误。有关更多信息,请参阅
联合错误处理方案。


我搜索了这个错误,但没有帮助。我正在并排运行这两个项目。旧的运行完美,但新的运行正在解决上述错误。请帮忙。

I searched for this error but it didn't helped. I'm running the two projects side by side. The old one is running perfectly but the new one is getting the above said error. Please help.


谢谢&问候。

Thanks & Regards.

关心Pradeep(PKM)

Regards Pradeep(PKM)

推荐答案

建议你可以通过CSOM调试服务。

Suggest that you can debug the service by CSOM.


这篇关于SharePoint Office 365使用CSOM登录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆