Bonjour,

Ma question va sans doute paraître bête et la réponse est probablement très simple mais je sèche depuis déjà de trop nombreuses heures :'(.

Dans mon service WCF, je souhaite utiliser le type d'authentification "Form" afin de gérer dans mon client la saisie d'un username et d'un password.

Ayant une architecture "particulière", j'ai créé mon propre RoleProvider et mon propre MembershipProvider.
J'ai impacté mon fichier de configuration afin de prendre en compte ces modifications et j'ai activité le mode "Form".

Je lance mon client dans VS2010, ce dernier auto héberge mon service WCF et... paf le chien !

Lorsque je regarde "ServiceSecurityContext.Current.AuthorizationContext.Properties..... je vois AuthentificationType = "NTLM" / Name = MaMachine\\MonCompteWindows

Alors que sur le client :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
            _townServiceClient = new TownServiceClient();
            _townServiceClient.ClientCredentials.UserName.UserName = "Laurent";
            _townServiceClient.ClientCredentials.UserName.Password = "p@ssw0rd";
Du coup, je viens de perdre beaucoup de temps là dessus : //

Le fichier de configuration cotés 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
<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="Mcel.WcfServiceLibrary.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <!-- Lors du déploiement du projet de bibliothèque du service, le contenu du fichier de configuration doit être ajouté au fichier app.config  
  de l'hôte. System.Configuration ne prend pas en charge les fichiers de configuration pour les bibliothèques. -->
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <bindings />
    <services>
      <service name="Mcel.WcfServiceLibrary.TownManagementService.TownService">
        <endpoint address="ws" binding="wsHttpBinding" contract="Mcel.WcfServiceLibrary.TownManagementService.ITownService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- Pour éviter la divulgation des informations sur les métadonnées, 
          définissez la valeur ci-dessous sur false et supprimez le point de terminaison des métadonnées ci-dessus avant le déploiement -->
          <serviceMetadata httpGetEnabled="True" />
          <!-- Pour recevoir les détails d'exception des erreurs à des fins de débogage, 
          définissez la valeur ci-dessous sur true.  Définissez-la sur false avant le déploiement 
          pour éviter la divulgation des informations d'exception -->
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="McelRoleProvider" />          
          <serviceCredentials>            
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="McelMembershipProvider" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
  <system.web>
    <authentication mode="Forms"/>   
    <compilation debug="true" />
    <membership defaultProvider="McelMembershipProvider">
      <providers>
        <clear />
        <add name="McelMembershipProvider" type="Mcel.WcfServiceLibrary.Authentification.McelMembershipProvider, Mcel.WcfServiceLibrary" />
      </providers>
    </membership>
    <roleManager enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" defaultProvider="McelRoleProvider">
      <providers>
        <clear />
        <add name="McelRoleProvider" type="Mcel.WcfServiceLibrary.Authentification.McelRoleProvider, Mcel.WcfServiceLibrary" />
      </providers>
    </roleManager>
  </system.web>
  <applicationSettings>
    <Mcel.WcfServiceLibrary.Properties.Settings>
      <setting name="MinRequiredPasswordLength" serializeAs="String">
        <value>6</value>
      </setting>
      <setting name="ApplicationName" serializeAs="String">
        <value>Mcel</value>
      </setting>
    </Mcel.WcfServiceLibrary.Properties.Settings>    
  </applicationSettings>
</configuration>
Le fichier généré cotés 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
 
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_ITownService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                    allowCookies="false">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="Message">
                        <transport clientCredentialType="Windows" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" />
                    </security>
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:8732/Design_Time_Addresses/WcfServiceLibrary/ws"
                binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITownService"
                contract="Service.Wcf.ITownService" name="WSHttpBinding_ITownService">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>
Une idée ?

Merci