IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Services Web Discussion :

[C#] Web service : authentification.


Sujet :

Services Web

  1. #1
    Membre habitué Avatar de Pynouz
    Profil pro
    Inscrit en
    Juin 2010
    Messages
    274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2010
    Messages : 274
    Points : 177
    Points
    177
    Par défaut [C#] Web service : authentification.
    Bonjour,

    Je réouvre un sujet sur mon web service car j'ai un serveur IIS sans SSL cette fois-ci. Ne trouvant pas de solution à mon problème liée au SSL, j'ai voulu commencer à pouvoir développer mon web service car je perdait trop de temps au niveau développement. Je verrais donc plus tard pour implémenter le SSL.

    Bref.. Mon web service est bien sur IIS mais lorsque j'essaie de faire appel à ses méthodes par le biais de mon client (sous visual studio 2008) j'ai le message :

    La demande HTTP n’est pas autorisée avec un modèle d’authentification client « Anonymous ». L’en-tête d’authentification reçu du serveur était « Negotiate,NTLM ».
    Si quelqu'un aurait une idée? Je peux fournir les codes de fichiers .config si cela est nécessaire.

    Merci pour votre attention.

  2. #2
    Invité
    Invité(e)
    Par défaut
    Salut,

    Citation Envoyé par Pynouz Voir le message
    Si quelqu'un aurait une idée?
    on en a beaucoup et les lister prendrait trop de notre temps.

    Citation Envoyé par Pynouz Voir le message
    Je peux fournir les codes de fichiers .config si cela est nécessaire.
    Indispensable pour savoir comment t'as configurer l'authentification deton service web.
    Dernière modification par Deepin ; 31/01/2011 à 11h27.

  3. #3
    Membre habitué Avatar de Pynouz
    Profil pro
    Inscrit en
    Juin 2010
    Messages
    274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2010
    Messages : 274
    Points : 177
    Points
    177
    Par défaut
    Alors voilà le code du fichier app.config (côté client) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00"
                        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="">
                                <extendedProtectionPolicy policyEnforcement="Never" />
                            </transport>
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                    <binding name="Service1Soap1" closeTimeout="00:01:00" openTimeout="00:01:00"
                        receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
                        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                            <transport clientCredentialType="Basic" proxyCredentialType="None"
                                realm="">
                                <extendedProtectionPolicy policyEnforcement="Never" />
                            </transport>
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://192.168.42.204/WBsansSSL/Service1.asmx"
                    binding="basicHttpBinding" bindingConfiguration="Service1Soap"
                    contract="ServiceReference1.Service1Soap" name="Service1Soap" />
                <endpoint address="http://192.168.42.204/WBsansSSL/Service1.asmx"
                    binding="basicHttpBinding" bindingConfiguration="Service1Soap1"
                    contract="ServiceReference1.Service1Soap" name="Service1Soap1" />
            </client>
        </system.serviceModel>
    </configuration>
    Voici le code du fichier web.config (côté serveur):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    <?xml version="1.0" encoding="utf-8"?>
     
    <configuration>
     
     
        <configSections>
          <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
              <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
              <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
                <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
                <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
              </sectionGroup>
            </sectionGroup>
          </sectionGroup>
        </configSections>  
     
     
        <appSettings/>
        <connectionStrings/>
     
        <system.web>
            <!-- 
                Définissez compilation debug="true" pour insérer des symboles 
                de débogage dans la page compilée. Comme ceci 
                affecte les performances, définissez cette valeur à true uniquement 
                lors du développement.
            -->
            <compilation debug="false">
     
              <assemblies>
                <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
              </assemblies>
     
            </compilation>
            <!--
                La section <authentication> permet la configuration 
                du mode d'authentification de sécurité utilisé par 
                ASP.NET pour identifier un utilisateur entrant. 
            -->
            <authentication mode="Windows" />
            <!--
                La section <customErrors> permet de configurer 
                les actions à exécuter si/quand une erreur non gérée se produit 
                lors de l'exécution d'une demande. Plus précisément, 
                elle permet aux développeurs de configurer les pages d'erreur html 
                pour qu'elles s'affichent à la place d'une trace de la pile d'erreur.
     
            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
            -->
     
          <pages>
            <controls>
              <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
              <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            </controls>
          </pages>
     
          <httpHandlers>
            <remove verb="*" path="*.asmx"/>
            <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
          </httpHandlers>
          <httpModules>
            <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          </httpModules>
     
     
        </system.web>
     
        <system.codedom>
          <compilers>
            <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
                      type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
              <providerOption name="CompilerVersion" value="v3.5"/>
              <providerOption name="WarnAsError" value="false"/>
            </compiler>
          </compilers>
        </system.codedom>
     
        <!-- 
            La section system.webServer est requise pour exécuter ASP.NET AJAX sur Internet
            Information Services 7.0.  Elle n'est pas nécessaire pour les versions précédentes d'IIS.
        -->
        <system.webServer>
          <validation validateIntegratedModeConfiguration="false"/>
          <modules>
            <remove name="ScriptModule" />
            <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          </modules>
          <handlers>
            <remove name="WebServiceHandlerFactory-Integrated"/>
            <remove name="ScriptHandlerFactory" />
            <remove name="ScriptHandlerFactoryAppServices" />
            <remove name="ScriptResource" />
            <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
                 type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
                 type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
            <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
          </handlers>
        </system.webServer>
     
        <runtime>
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
              <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
              <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
            </dependentAssembly>
            <dependentAssembly>
              <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
              <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
            </dependentAssembly>
          </assemblyBinding>
        </runtime>
     
    </configuration>
    Si il y a besoin d'autre chose..

  4. #4
    Invité
    Invité(e)
    Par défaut
    Dans la configuration de ton binding côté client modifie l'élément transport en utilisant l'authentification Ntlm :
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm" realm="">

  5. #5
    Membre habitué Avatar de Pynouz
    Profil pro
    Inscrit en
    Juin 2010
    Messages
    274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2010
    Messages : 274
    Points : 177
    Points
    177
    Par défaut
    C'est fait j'ai toujours malheureusement le même message d'erreur.

  6. #6
    Invité
    Invité(e)
    Par défaut
    Est tu sûr d'avoir modifié la bonne configuration de binding (Service1Soap ou Service1Soap1) concernant ton endpoint ?

    Modifies les deux pour être sûr que t'as modifié la bonne config.

  7. #7
    Membre habitué Avatar de Pynouz
    Profil pro
    Inscrit en
    Juin 2010
    Messages
    274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2010
    Messages : 274
    Points : 177
    Points
    177
    Par défaut
    Oui j'ai modifier les deux pour être sûre de pas faire une erreur justement

  8. #8
    Invité
    Invité(e)
    Par défaut
    Bon essaie ça en remplaçant complètement l'élément sécurité :
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    <security mode="TransportCredentialOnly">
          <transport clientCredentialType="Ntlm"/>
    </security>

    Pour plus d'infos ce bloggeur a réussi à résoudre le même problème que toi.

  9. #9
    Membre habitué Avatar de Pynouz
    Profil pro
    Inscrit en
    Juin 2010
    Messages
    274
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2010
    Messages : 274
    Points : 177
    Points
    177
    Par défaut
    Yes ! Ça fonctionne !

    Je te remercie vraiment pour ton aide très précieuse !

    Bonne journée à toi !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Nexus + web service + authentification
    Par Techniv dans le forum Services Web
    Réponses: 0
    Dernier message: 19/04/2011, 18h22
  2. [SOAP] acces web service Authentification
    Par sebxid dans le forum XML/XSL et SOAP
    Réponses: 1
    Dernier message: 25/11/2010, 09h03
  3. Spring security + Web service: Authentification
    Par Toinou87 dans le forum Services Web
    Réponses: 1
    Dernier message: 11/07/2009, 15h32
  4. WEB SERVICES & authentification
    Par mickael.guilbert dans le forum Glassfish et Payara
    Réponses: 7
    Dernier message: 07/07/2008, 15h58
  5. [Web Service] Authentification
    Par Stef_D dans le forum Delphi
    Réponses: 9
    Dernier message: 15/02/2007, 17h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo