views:

331

answers:

1

Hello colleagues. I've created wcf service with transport security over HTTPS. Also I use UserName authentication as described at http://msdn.microsoft.com/en-us/library/cc949025.aspx, so I can use my Membership,RoleProvider. When I work with this service with ASP.NET all is OK

  var client = new RegistratorClient();
  client.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["registratorLogin"];
  client.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["registratorPassword"];

But at my SilverLight appliation I can't do the same. When I try setup credntials and call wcf I get standard browser window with username and password. When I insert it SL application works well, but this message is so annoyed. I can't use clientCredentialType="Basic" at my SL config.

What should I do for silence calling my WCF.

Big thanks

A: 

Are you using basicHttpBinding? and are the sl app and svc on the same domain?

i have (i think) a similar setup - silverlight 3.0 / wcf hosted over https using forms authentication.

i'll copy in all my related configs, in case you're missing something.

ServiceReferences.ClientConfig (had to remove the 'configuration' tag, otherwise the whole block disappears):

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_PassportService" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
                textEncoding="utf-8">
                <security mode="Transport">
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="https://domain/service.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_PassportService"
            contract="PassportService.PassportService" name="BasicHttpBinding_PassportService" />
    </client>
</system.serviceModel>

serviceModel in web.config:

<system.serviceModel>
    <behaviors>
        <serviceBehaviors>
            <behavior name="ProjectPassport.Web.PassportServiceBehavior">
                <serviceMetadata httpGetEnabled="true" httpGetUrl="http://domain/service.svc" />
                <serviceDebug includeExceptionDetailInFaults="true" />
                <dataContractSerializer maxItemsInObjectGraph="2147483647" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <basicHttpBinding>
            <binding name="basicHttpsBinding">
                <security mode="Transport">
                    <transport clientCredentialType="None"/>
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <services>
        <service behaviorConfiguration="ProjectPassport.Web.PassportServiceBehavior"
         name="ProjectPassport.Web.PassportService">
            <endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpsBinding"
                contract="ProjectPassport.Web.PassportService" />
        </service>
    </services>
</system.serviceModel>

and my authentication/authorization/membership config:

    <authentication mode="Forms">
        <forms loginUrl="Home.aspx" protection="All" timeout="80" name="AppName" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="Manage.aspx" cookieless="UseCookies" enableCrossAppRedirects="false"/>
    </authentication>

    <authorization>
        <deny users="?"/>
        <!---->
        <allow users="*"/>
    </authorization>
    <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
        <providers>
            <clear/>
            <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" applicationName="MyApplication" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="50" passwordStrengthRegularExpression=""/>
        </providers>
    </membership>

also, don't forget that js/clientBin/wcf service locations should be authorized. add location tags:

<location path="ClientBin">
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>
<location path="service.svc">
    <system.web>
        <authorization>
            <allow users="*"/>
        </authorization>
    </system.web>
</location>

etc...

Edit: that link you refer to is targeted at winforms. if i'm not mistaken, you're building a silverlight 3 app. have a look at these instead:

http://msdn.microsoft.com/en-us/library/dd560704%28VS.95%29.aspx

http://www.eggheadcafe.com/tutorials/aspnet/7cc2760f-50f2-492d-9d62-48ad5c7f70b4/aspnet-membership-and-ro.aspx

Kevin