views:

222

answers:

2

We have a .NET ActiveX control which is embedded inside a custom SharePoint page. The user has to authenticate (Windows Authentication not Forms Authentication) to access this page.

Our ActiveX control is making web service calls back to the SharePoint server. Because the SharePoint server does not allow anonymous access, we need to provide credentials as part of the web services call. If the user is checking the 'Remember Password' checkbox when prompted for credentials, then we can access those credentials via the CredentialCache.DefaultNetworkCredentials. However, if they do not check that checkbox, we need another mechanism to get a hold of valid credentials (which must exist since we are embedded in a page that can only be accessed via authentication).

How can we access the credential information (probably stored in a cookie) we need to authenticate against SharePoint so we can access the web services?

A: 

There is a method in the SPUtility class called EnsureAuthentication, you can also hit the /_layouts/Authenticate.aspx page to log the user automatically in sharepoint.

You can also encapsulate your call with Impersonation.

F.Aquino
The EnsureAuthentication seems to be a server-side method, but we are looking for a method to execute client-side, inside our ActiveX control hosted on the client machine. As for the Authenticate.asmx, we are looking for a mechanism to grab the credentials the user already provided when navigating to the hosting page and not re-prompt the user for credentials.
Philipp Schmid
I use similar approaches to access SharePoint from a Silverlight Application. My request is something like: Silverlight calls ASHX file (under SharePoint), ASHX file impersonates the request with RunWithElevatedPrivileges and outputs the return. I sent you the win32 impersonation so you could build that less sharepoint-centric. The Authenticate.aspx idea is that the request will get the current user and pass on the windows account and authenticate it, automatically, transferring the request to the actual webservice
F.Aquino
A: 

You can send a message to your ashx like you do it from Silverlight using XMLHTP.

Mauricio
Sending that message with the correct credentials is exactly what I am trying to solve here.
Philipp Schmid