2011-04-22 18 views
6

He tenido muchas dificultades para configurar mi servicio WCF para hablar con los servicios web de Sharepoint, específicamente estoy tratando de usar los servicios Lists.asmx y Copy.asmx.Configuración de la Autenticación NTLM con WCF a los Servicios web de Sharepoint

Lo puse en funcionamiento usando un enlace http para compartir para el desarrollo, pero ahora tenemos que cambiar a un enlace HTTPS. Obtuve la configuración de referencia web y la actualicé para este enlace, pero cuando intenta llamar a un servicio (por ejemplo, GetListItems) se produce un error con el siguiente error: La solicitud falló con el estado HTTP 401: no autorizado.

Intenté ver qué tipo de autenticación usa SharePoint Server, que resulta ser NTLM. Luego traté de configurar el archivo web.config para esto. Aquí está todo el archivo web.config:

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
     <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
      <section name="InventoryService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> 
     </sectionGroup> 
    </configSections> 
    <appSettings/> 
    <connectionStrings/> 
    <system.web> 
     <compilation debug="true" targetFramework="4.0"> 
     </compilation> 
     <!-- 
     The <authentication> section enables configuration 
     of the security authentication mode used by 
     ASP.NET to identify an incoming user. 
    --> 
     <authentication mode="Windows"/> 
     <!-- 
     The <customErrors> section enables configuration 
     of what to do if/when an unhandled error occurs 
     during the execution of a request. Specifically, 
     it enables developers to configure html error pages 
     to be displayed in place of a error stack trace. 

     <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> 
     <error statusCode="403" redirect="NoAccess.htm" /> 
     <error statusCode="404" redirect="FileNotFound.htm" /> 
     </customErrors> 
    --> 
     <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web> 
    <!-- 
     The system.webServer section is required for running ASP.NET AJAX under Internet 
     Information Services 7.0. It is not necessary for previous version of IIS. 
    --> 
    <system.serviceModel> 
     <bindings> 
    <basicHttpBinding> 
    <binding name="NewBinding0"> 
    <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Ntlm" proxyCredentialType="None" /> 
    </security> 
    </binding> 
    </basicHttpBinding> 
    </bindings> 
    <services> 
    <service behaviorConfiguration="InventoryService.Service1Behavior" 
    name="InventoryService.InventoryService"> 
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="NewBinding0" 
    contract="InventoryService.IInventoryService"> 
    <identity> 
     <dns value="localhost" /> 
    </identity> 
    </endpoint> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
    </service> 
    </services> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior name="InventoryService.Service1Behavior"> 
        <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
        <serviceMetadata httpGetEnabled="true"/> 
        <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
        <serviceDebug includeExceptionDetailInFaults="true"/> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
    </system.serviceModel> 
    <applicationSettings> 
     <InventoryService.Properties.Settings> 
    <setting name="InventoryService_WSCopy_Copy" serializeAs="String"> 
    <value>http://site/_vti_bin/Copy.asmx</value> 
    </setting> 
    <setting name="InventoryService_SharepointLists_Lists" serializeAs="String"> 
    <value>https://site/_vti_bin/Lists.asmx</value> 
    </setting> 
    </InventoryService.Properties.Settings> 
    </applicationSettings> 
</configuration> 

Si alguien tiene una idea de si tengo que instalar este archivo de configuración correctamente para NTLM, que sería de gran ayuda.

Si esto se ha configurado correctamente, entonces creo que voy a pasar a la siguiente pregunta acerca de si la configuración de las credenciales correctamente:

inventoryList = new SharepointLists.Lists(); 
inventoryList.Url = "https://fullsiteurl/_vti_bin/Lists.asmx"; 
inventoryList.Credentials = new System.Net.NetworkCredential("user", "pass", "domain"); 

Si alguien podría ir sobre esto, que también sería muy útil.

Una vez más, sé que el archivo de configuración es bastante largo y le agradezco mucho si lo hace, avíseme si configuro correctamente la autenticación NTLM.

Si todo esto sale bien, entonces no tengo idea de por dónde empezar a trabajar en el enlace HTTPS con sharepoint (el enlace HTTP existente para compartir está disponible por el momento, hasta que pueda hacer que el servicio funcione el enlace HTTPS).

+0

Sólo para estar seguro, usted tiene un servicio WCF que pone en un Servicio Web de SharePoint ¿verdad? Primera pregunta: ¿por qué no usa directamente la API Sharepoint dentro de su servicio WCF? Segunda pregunta: ¿Puede navegar por el sitio sharepoint en HTTPS con las credenciales de usuario especificadas? –

+0

Sí, estoy usando un servicio WCF que llama a un servicio web Sharepoint mediante el uso de una referencia web a los sitios lists.asmx url. 1. No puedo usar la API Sharepoint porque el servicio no va a estar en la misma máquina que Sharepoint, Sharepoint API solo se puede usar si se encuentra en la misma máquina que Sharepoint Server. 2. Sí, mis credenciales de usuario funcionan bien con el enlace HTTPS, también puedo agregar la referencia web usando esas credenciales. – PvpMan22

Respuesta

0

Asegúrese de que el usuario especificado tenga acceso a ASMX con el navegador.

Asegúrese de que el usuario tenga (como mínimo) permiso de lectura para la biblioteca de destino.

Además, asegúrese de que el usuario tenga la previsión Use Remote Interfaces (WSS 3.0: Configuración del sitio, Permisos avanzados, Configuración - Niveles de permiso, elija el nivel de permiso correspondiente).

Además, si está utilizando MOSS 2007, el acceso a SOAP se puede deshabilitar en el administrador central.

No tengo Sharepoint 2010 disponible en este momento, así que no puedo verificarlo, pero espero que la configuración sea la correspondiente.

Editar:

Si todo funciona muy bien bajo HTTP normal, me gustaría ver la forma en que se habilitó HTTPS.

Eche un vistazo a este sitio "How to enable SSL on a SharePoint 2010 web application", especialmente la segunda parte (aproximadamente 1/3 de la página, con respecto a agregar una asignación de acceso alternativa).

Espero que esto ayude.

+0

¿Sería aplicable algo de esto si funciona con HTTP? Puedo hacer que obtenga y actualice los datos de la lista cuando lo hago referenciar el enlace HTTP al servicio lists.asmx. El problema ocurre cuando intento usar HTTPS, donde inmediatamente me niega el acceso incluso con credenciales válidas. Así que siento que estoy configurando la seguridad incorrecta para el enlace HTTPS. – PvpMan22

0

Obtiene este error porque no ha especificado que el uso de mexHttpBinding utilice la configuración de enlace 'NewBinding0'. Lo que está sucediendo es que antes de su llamada real de servicio WCF, WCF está intentando obtener cierta información sobre el servicio.Esta solicitud fallará si no transporta ninguna información de credenciales del cliente al servicio, ya que está protegida y recibirá la respuesta 401 del servidor (No autorizado). Asegúrese de que su mexHttpBinding también envíe las credenciales NTLM.

usted podría quitar alternativamente, la mexHttpBinding

Cuestiones relacionadas