Any suggestions would be helpful...
I am attemting to access an external list using the Server OM. The external list is configured to use pass through credentials. The list functions perfectly in the SharePoint UI.
When I run this code in a console app:
using (SPSite site = new SPSite("http://DOM-dev.DOM.net/sites/plm"))
{
SPServiceContext context = SPServiceContext.GetContext(site);
SPServiceContextScope contextScope = new SPServiceContextScope(context);
using (SPWeb web = site.RootWeb)
{
SPList list = web.Lists["Industries"];
Console.WriteLine(list.Title);
SPListItemCollection items = list.GetItems();
foreach (SPListItem item in items)
{
Console.WriteLine(item["Industry"].ToString());
}
}
}
I get this error:
System.UnauthorizedAccessException was unhandled Message=Attempted to perform an unauthorized operation. Source=Microsoft.SharePoint
StackTrace: at Microsoft.SharePoint.SPListDataSource.CheckUserIsAuthorized(SPBasePermissions perms) at Microsoft.SharePoint.SPListDataSource.GetFilteredEntityInstances(XmlDocument xdQueryView, Boolean fFormatDates, Boolean fUTCToLocal, String firstRowId, Boolean fBackwardsPaging, String& bdcidFirstRow, String& bdcidNextPageRow, List1& lstColumnNames, Dictionary2& dictColumnsUsed, List1& mapRowOrdering, List1& lstEntityData) at Microsoft.SharePoint.SPListItemCollection.EnsureEntityDataViewAndOrdering(String& bdcidFirstRow, String& bdcidNextPageFirstRow) at Microsoft.SharePoint.SPListItemCollection.EnsureListItemsData() at Microsoft.SharePoint.SPListItemCollection.get_Count() at Microsoft.SharePoint.SPEntityInstanceEnumerator.System.Collections.IEnumerator.MoveNext() at TestExternalList.Program.Main(String[] args) in c:\Users\rkauche\Desktop\IT\TestExternalList\TestExternalList\Program.cs:line 28 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: