我在连接到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)
答案 0 :(得分:0)
这通常意味着
凭据管理
连接字符串中的参数是正确的很重要,如果您使用了authentication = default,则可以尝试使用authentication = ntlm,并记住检查并重新检查您的用户是否具有指定SharePoint Server和Site的访问权限
允许连接
在Windows内部发生了一种称为“环回错误”的事情。有很多关于如何使用它的文章;我们更喜欢使用PowerShell
来解决这个问题的简单方法在每个SharePoint前端服务器上执行以下PowerShell命令。
New-ItemProperty HKLM:\System\CurrentControlSet\Control\Lsa -Name "DisableLoopbackCheck" -Value "1" -PropertyType dword
在极少数情况下,您可能需要重置IIS。
微软更多阅读