authentication - WCF - can't get Identity.UserName inside service -


i'm trying make wp7 app has interact wcf service.
want pass username/password , see in wcf service.

        service1client proxy = new service1client();         proxy.clientcredentials.username.username= "abc@email.com";         proxy.clientcredentials.username.password = "abc"; 

code tried in service authenticated name(but got windows identity instead - mypc\mylogin)

httpcontext.current.user.identity.name 

here client config

<configuration> <system.servicemodel>     <bindings>         <basichttpbinding>             <binding name="basichttpbinding_iservice1" maxbuffersize="2147483647"                 maxreceivedmessagesize="2147483647">                 <!--<security mode="none" />-->               <security mode="transportcredentialonly">                 <!--<transport clientcredentialtype="basic" />-->                                  </security>             </binding>         </basichttpbinding>     </bindings>     <client>         <endpoint address="http://localhost:45148/service1.svc" binding="basichttpbinding"             bindingconfiguration="basichttpbinding_iservice1" contract="servicereference1.iservice1"             name="basichttpbinding_iservice1" />     </client> </system.servicemodel> 

and here server config

        <?xml version="1.0"?>         <configuration>            <system.web>             <compilation debug="true" targetframework="4.0" />           </system.web>           <system.servicemodel>             <behaviors>               <servicebehaviors >                 <behavior>                   <!-- avoid disclosing metadata information, set value below false , remove metadata endpoint above before deployment -->                   <servicemetadata httpgetenabled="true"/>                   <!-- receive exception details in faults debugging purposes, set value below true.  set false before deployment avoid disclosing exception information -->                   <servicedebug includeexceptiondetailinfaults="true"/>                   <servicecredentials>                     <usernameauthentication usernamepasswordvalidationmode="custom"                      customusernamepasswordvalidatortype="wp7service.wpfcustomvalidator, wp7service" />                   </servicecredentials>                 </behavior>               </servicebehaviors>             </behaviors>             <bindings>               <basichttpbinding>                 <binding name="basichttpbinding_iservice1">                   <security mode="transportcredentialonly">                     <transport clientcredentialtype="none" />                   </security>                 </binding>               </basichttpbinding>             </bindings>             <servicehostingenvironment multiplesitebindingsenabled="true" aspnetcompatibilityenabled="true" />           </system.servicemodel>           <system.webserver>             <modules runallmanagedmodulesforallrequests="true"/>           </system.webserver>         </configuration> 

also have cutom username validator, never called

    public class wpfcustomvalidator :       system.identitymodel.selectors.usernamepasswordvalidator {     public override void validate(string username, string password)     {         if (username == null || password == null)         {             throw new argumentnullexception();         }         var rf = windsoraccessor.initializerepositoryfactory(username);          if (!validatelogon(rf, username, password))         {             throw new faultexception("incorrect username or password");         }     } } 

i want answer show how configure client , service able see clientcredentials.username.username in service via httpcontext.current.user.identity.name or via current thread identity(or other way).

dominick baier shows how do this on blog.

your custom validator code not called because service configured clientcredentialtype="none" - i.e. no authentication.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -