Principales respuestas
Acceder a los Servicios Web de SharePoint utilizando los proveedores de autenticación tanto NTLM (autenticación de Windows) y FBA (autenticación basada en formularios)

Pregunta
-
Buenos días a tod@s.
Cuando creo una aplicación web y le digo que utilizo la autenticación basada en Windows; hago referencia al servicio web para listas y la función funciona correctamente.
Dim
listWebService As New ServicioWebListas.Lists()listWebService.Url = http://pruebas.2010/_vti_bin/Lists.asmx
Dim credentials As New System.Net.NetworkCredential("usuario", "password", "domain")
listWebService.Credentials = credentials
Dim nodeListItems As XmlNode = listWebService.GetListItems(guidListaBib, String.Empty, xNdQuery, xNdViewFields, String.Empty, xNdQueryOptions, Nothing)
Esto me lo hace correctamente.
En cuanto modifico el proveedor de autenticación con el fin de poder validarme tanto por el usuario del dominio como el usuario de .NET.
En la parte Web, he probado a validarme por ambos proveedores y todo funciona bien; incluso accedo al asmx de http://pruebas.2010/_vti_bin/Lists.asmx donde me aparecen todos los métodos a utilizar por el servicio web.
Pero en cuanto, ejecuto de nuevo el código, me devuelve el error de que el servidor no puede procesar la solicitud--> Acceso denegado.
Espero que me puedan ayudar.
Gracias de antemano.
- Editado David Uru viernes, 7 de octubre de 2011 11:59
Respuestas
-
Hola David,
cuando utilizas Form Auth, tienes que utilizar un servicio web de autenticación que tiene SharePoint (_vti_bin/authentication.aspx) y establecer una cookie con la autenticación, algo así:
// Autenticamos y guardamos la cookie SPAuthenticationService.Authentication authService = new SPAuthenticationService.Authentication(); authService.CookieContainer = new System.Net.CookieContainer(); authService.AllowAutoRedirect = true; SPAuthenticationService.LoginResult result = authService.Login("fbausername", "password"); if (result.ErrorCode == SPAuthenticationService.LoginErrorCode.NoError) { MyService service = new MyService(); // Utilizamos esa cookie para pasarle la autenticación al servicio service.CookieContainer = authService.CookieContainer; string str = service.TestFunction(); }
Alberto Diaz Martin twitter://@adiazcan | http://geeks.ms/blogs/adiazmartin | MVP SharePoint Server- Propuesto como respuesta Santiago Porras RodríguezMVP, Moderator viernes, 7 de octubre de 2011 15:15
- Marcado como respuesta David Uru jueves, 13 de octubre de 2011 9:20
Todas las respuestas
-
Hola David,
cuando utilizas Form Auth, tienes que utilizar un servicio web de autenticación que tiene SharePoint (_vti_bin/authentication.aspx) y establecer una cookie con la autenticación, algo así:
// Autenticamos y guardamos la cookie SPAuthenticationService.Authentication authService = new SPAuthenticationService.Authentication(); authService.CookieContainer = new System.Net.CookieContainer(); authService.AllowAutoRedirect = true; SPAuthenticationService.LoginResult result = authService.Login("fbausername", "password"); if (result.ErrorCode == SPAuthenticationService.LoginErrorCode.NoError) { MyService service = new MyService(); // Utilizamos esa cookie para pasarle la autenticación al servicio service.CookieContainer = authService.CookieContainer; string str = service.TestFunction(); }
Alberto Diaz Martin twitter://@adiazcan | http://geeks.ms/blogs/adiazmartin | MVP SharePoint Server- Propuesto como respuesta Santiago Porras RodríguezMVP, Moderator viernes, 7 de octubre de 2011 15:15
- Marcado como respuesta David Uru jueves, 13 de octubre de 2011 9:20
-