WCF Configuration using TransportWithMessageLevel Credential and Forms Authentication


/ Published in: C#
Save to your folder(s)

this thing is a pain to configure


Copy this code and paste it in your HTML
  1. <configuration>
  2. <connectionStrings>
  3. <remove name="LocalSqlServer"/>
  4. <add name="LocalSqlServer"
  5. connectionString="Data Source=msapps-qa;Initial Catalog=aspnetdb;UID=blah; Password=blah" providerName="System.Data.SqlClient" />
  6. <add name="blah"
  7. connectionString="data source=.;Integrated Security=false;UID=blah;Password=blah;Initial Catalog=library;" providerName="System.Data.SqlClient"/>
  8. </connectionStrings>
  9. <system.web>
  10. <compilation debug="true" />
  11. <customErrors mode="Off" />
  12. <membership defaultProvider="SqlMembershipProvider" userIsOnlineTimeWindow="15">
  13. <providers>
  14. <clear />
  15. <add
  16. name="SqlMembershipProvider"
  17. type="System.Web.Security.SqlMembershipProvider"
  18. connectionStringName="LocalSqlServer"
  19. applicationName="/"
  20. enablePasswordRetrieval="false"
  21. enablePasswordReset="false"
  22. requiresQuestionAndAnswer="false"
  23. requiresUniqueEmail="true"
  24. passwordFormat="Hashed" />
  25. </providers>
  26. </membership>
  27.  
  28. <!-- Configure the Sql Role Provider -->
  29. <roleManager enabled="true" defaultProvider="SqlRoleProvider">
  30. <providers>
  31. <add connectionStringName="LocalSqlServer" applicationName="/" name="SqlRoleProvider"
  32. type="System.Web.Security.SqlRoleProvider" />
  33. </providers>
  34. </roleManager>
  35.  
  36. <authentication mode="Forms"></authentication>
  37. </system.web>
  38.  
  39. <system.serviceModel>
  40.  
  41. <protocolMapping>
  42. <add scheme="http" binding="wsHttpBinding" />
  43. </protocolMapping>
  44.  
  45. <behaviors>
  46. <serviceBehaviors>
  47. <behavior name="ServiceBehavior">
  48. <serviceAuthorization principalPermissionMode="UseAspNetRoles"
  49. roleProviderName="SqlRoleProvider" />
  50. <serviceCredentials>
  51. <!-- Configure user name authentication to use the Membership Provider -->
  52. <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
  53. membershipProviderName="SqlMembershipProvider" />
  54.  
  55. <!-- Configure the service certificate -->
  56. <serviceCertificate
  57.  
  58. storeLocation="LocalMachine"
  59. storeName="My"
  60. x509FindType="FindBySubjectName"
  61. findValue="WMSvc-MSAPPS-QA" /> <!--Enter your Server Certificate Name in here-->
  62. </serviceCredentials>
  63. <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
  64. <serviceDebug includeExceptionDetailInFaults="true" />
  65. </behavior>
  66. </serviceBehaviors>
  67. </behaviors>
  68.  
  69. <serviceHostingEnvironment multipleSiteBindingsEnabled="True">
  70. </serviceHostingEnvironment>
  71. <services>
  72. <service name="WCFLibraryService.LibraryService" behaviorConfiguration="ServiceBehavior">
  73. <endpoint address=""
  74. binding="wsHttpBinding"
  75. bindingConfiguration="MembershipBinding"
  76. contract="WCFLibraryService.ILibraryService"
  77. name="ASPmemberUserName"/>
  78. <endpoint address="mex"
  79. binding="mexHttpsBinding"
  80. contract="IMetadataExchange"
  81. bindingConfiguration="">
  82. </endpoint>
  83. </service>
  84. </services>
  85.  
  86. <bindings>
  87. <wsHttpBinding>
  88. <binding name="MembershipBinding" maxReceivedMessageSize="20000000" maxBufferPoolSize="20000000">
  89. <security mode="TransportWithMessageCredential">
  90. <transport clientCredentialType="None" proxyCredentialType="None"></transport>
  91. <message clientCredentialType="UserName" negotiateServiceCredential="true"/>
  92. </security>
  93. </binding>
  94. </wsHttpBinding>
  95. </bindings>
  96.  
  97. </system.serviceModel>
  98. <system.webServer>
  99. <directoryBrowse enabled="true" />
  100. </system.webServer>
  101.  
  102. </configuration>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.