I am running a web application scoped webservice (WCF).
The webservice runs a method to read credentials from the secure store.
The method fails with the message:
Credentials were not found for the current user within the target application 'AppID' ...
Running the SPContext.Current.Web.CurrentUser in my method gives me: SHAREPOINT\system. This seems strange considering the fact that the hosting web application runs under it's own identity.
The Secure Store is configured according to here. I took different approaches to get credentials, but the latest code is:
SecureStoreCredentialCollection credentials = null; SPServiceContext context = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default); SecureStoreServiceProxy ssp = new SecureStoreServiceProxy(); ISecureStore iss = ssp.GetSecureStore(context); credentials = iss.GetCredentials(appId);
I also tried to run this using the context of Centeral Administration Site or SPContext.Current.Site.
The secure store application Target Application Administrators and Members include all farm administrator accounts and the application pool identity. The same also applies to the Secure Store Service Administrators and Permissions.
My questions are: Is the way application runs under system account (SHAREPOINT\system) the reason for access error to the secure store?
Is it normal to have a web application scoped webservice running under system account by default? Is there possibly a missing part in my web application setup?
Any help is greatly appreciated.