1

I have an ASP.NET application that uses Forms Authentication.

I need to call the Sharepoint search.asmx web service to retrieve a list of files from the network satisfying the search criteria (there's a good reason for me doing this outside of Sharepoint)

I'm not sure of the security information I need to pass the search.asmx. I've tried: queryService.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials queryService.ClientCredentials.Windows.AllowedImpersonationLevel = Security.Principal.TokenImpersonationLevel.Impersonation

-which works in my development environment as my user has access to the File Shares Sharepoint is accessing. What I can't understand, and can't infer from debugging or event viewers, etc. is what credentials are passed in the above code once I deploy this code on a server.

Will it pass the windows credentials of the user who opened the IE window prior to using forms authentication. Will it pass the credentials of the account that is running the asp.net components i.e. the account of the AppPool I'm running in, or will it pass something else?

I can't seem to get Sharepoint to return any files and I guess it's because the credentials being passed don't have access to the File Share.

Thanks Andy

1 Answer 1

1

To get this working quickly you can access the SharePoint webservices with your username & password. This isn't the best solution long term obviously.

Set the Credentials property on the SharePoint webservice proxy to your username & password:

spProxy.Credentials = new NetworkCredential("username", "password", "domain");

You'll need to make sure the credentials property is set before you call the webservice.

I'm not a SharePoint expert (I've only used it as a developer), but I believe it only uses Windows authentication to secure the webservices. So forms authentication isn't going to help you out here if you want to access the webservices as the logged in user (unless you're validating the username & password manually with LDAP). ASP.NET Impersonation & Delegation only makes sense if you are using Windows authentication.

As stated by pseudocoder you might want to setup a special account to access SharePoint from the web server.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. I should have said my Forms Authentication is going away to authenticate against Active Directory, so in theory I should be able to get a handle to a 'real' user (I use Forms Authentication because users need to log on to the app at machines where they may not be logged on themselves)
I had the exact same scenario. You can store the username & password when the user logs in (possibly in the userData string in the forms ticket or in session state). When you're ready to call the webservice put the values in the networkcredential object. Please mark this as the answer if it has helped you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.