0

连接到 SharePoint 时出现错误

我确定我的连接字符串是正确的,这就是我的连接方式

var connectionString = "Server=mysharepointserver.com;User=spuser;Password=******;Authentication=Ntlm;TimeOut=10;SSL=True;RecursiveMode=RecursiveAll;DefaultLimit=1000;CacheTimeout=5";

using (var connection = new SharePointConnection(connectionString)) // This is where it breaks
{
    connection.Open();
    using (var command = new SharePointCommand("SELECT * Tasks", connection))
    {
        using (var reader = command.ExecuteReader())
        {
            while (reader.Read())
            {
                Console.WriteLine(reader["Title"].ToString().PadRight(40) + " : " + reader["Country"].ToString());
            }
        }     
    }
}

将 connectionString 加载到 SharePointConnection 时发生错误

这是完整的错误客户端未经服务器授权。确保 Connection 上的 ConnectionString 属性正确。

at Camelot.SharePointConnector.Data.SharePointCommand.ExecuteReader(CommandBehavior
  behavior, Boolean returnScalar)
at Camelot.SharePointConnector.Data.SharePointCommand.ExecuteDbDataReader(
  CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior
  behavior)
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[]
  datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand
  command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord,
  Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at Camelot.SharePointConnector.Data.Helper.ExecuteDataTable(String query, String
  connectionString)
at Camelot.WebParts.BlogReader.BlogReader.Page_Load(Object sender, EventArgs e)
4

1 回答 1

0

这通常意味着

  • 连接字符串中的凭据错误,或者
  • 不允许来自客户端的连接
  • 来自不同域的客户端的身份验证未成功

凭证管理

连接字符串中的参数正确很重要,如果您使用了 authentication=default,则可以尝试使用 authentication=ntlm 并记住检查并重新检查您的用户是否有权访问指定的 SharePoint Server 和站点

允许连接

Windows 内部会发生一种称为“环回错误”的情况。有很多关于如何使用它的文章;我们更喜欢使用 PowerShell 来解决这个问题的简单方法

在每个 SharePoint 前端服务器上执行以下 PowerShell 命令。

New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck" -Value "1" -PropertyType dword

在极少数情况下,您可能需要重置 IIS。

在微软阅读更多

于 2013-07-16T05:56:42.103 回答