Authentication and Authorization
The SharePoint server must authenticate the Excel user before you can call any of the Lists Web Service methods. If the user has not been authenticated, a “Maximum retry on connection exceeded” error occurs. In Visual Basic .NET or C# .NET, you authenticate the user from code by creating a Credentials object for the user. For example, the following .NET code passes the user’s default credentials to a web service:
wsAdapter.Credentials = System.Net.CredentialCache.DefaultCredentials
Unfortunately, you can’t do that directly in Excel. Instead, you must use one of the following techniques to connect to the SharePoint server through Excel:
Update or refresh a worksheet list that is shared on the server.
Insert an existing SharePoint list on a worksheet. This can even be a dummy list placed on the server solely for the purpose of establishing connections.
Navigate to the SharePoint server in code as described earlier in this chapter in "Share a List.”
Any of these techniques displays a SharePoint authentication dialog box and establishes a user session for Excel. Afterward, you can call Lists methods and they will be authorized using the current session.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access