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.