Pregunta

Tengo una página de ASPX en la carpeta Diseños.Un TimeJob realiza un HTTPWebRequest en esta página y la respuesta-HTML se guarda como un PDF. El HTTPWEBREQUEST funciona bien, cuando no se llama en un temporizador (ex. En otra página de diseño), BBUT cuando ejecuto el método GetReponse () - En el TimerJob obtengo un error 401 (no autorizado).

Con este código funciona en w3wp.exe

request.Method = "GET";
request.UseDefaultCredentials = true;
request.PreAuthenticate = true;
request.Credentials = CredentialCache.DefaultNetworkCredentials;

La única forma en que lo hice funcionar en OWSTIMER.EXE está con

request.Credentials = new NetworkCredential(user, password, domain);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Pero no podemos albergar al Passwort en algún lugar en el texto letra.

¿Cómo puedo hacer que funcione en OWSTIMER.EXE sin proporcionar las credenciales?

¿Fue útil?

Solución

Disclaimer: While this won't bypass the need to provide a set of user credential, at least will somehow avoid to store them as clear text.

The general idea is to use the Secure Store Service to store a set of credential that will be used in the request. You need to define an "app" and then access that application via codebehind from the timer job instance.

This sample from msdn should give you a quick start on the implementation. I have actually done this to provide site collection creation from a SPLongOperation context.

(note: I will add some more info/screens - have some network problem now. In the meantime free to ask further info as required)

Licenciado bajo: CC-BY-SA con atribución
scroll top