none
Want WCF to get the Active Directory user making the request from a silverlight app RRS feed

  • Question

  • Now I basically want to confirm that the user is logged into Active directory and get their username.

    I don't think I can get this in Silverlight.  So I think I have to call a WCF service and passback the AD username...

    So, in my wcf service do I use:

      WindowsIdentity wi = HttpContext.Current.User.Identity as WindowsIdentity;

      wi.username and  wi.IsAuthenticated?

    I think I also have to add to the WCF service webconfig

        <system.serviceModel>
        <services>
        <service name="MyService.Auth2"
                   behaviorConfiguration="ServBehave">
            <endpoint
               address=""
                binding="basicHttpBinding"
                bindingConfiguration="basicBind"
                contract="MyService.IAuth2"/>
          </service>
    
    </services>
        <bindings>
          <basicHttpBinding>
            <binding name="basicBind">
              <security mode="None">
                <transport clientCredentialType="Windows"/>
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>
        <behaviors>
              <behavior name="ServBehave">
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="True"/>
              </behavior>
    
            
            <behavior name="">
              <serviceMetadata httpGetEnabled="true"/>
              <serviceDebug includeExceptionDetailInFaults="true"/>
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
      </system.serviceModel>

    Do I have to change anything in IIS, like some windows auth?


    dan

    Monday, December 2, 2013 11:25 PM

Answers

  • Hi,

    I see that you have used the following:

    <basicHttpBinding>
            <binding name="basicBind">
              <security mode="None">
                <transport clientCredentialType="Windows"/>
              </security>
            </binding>
    </basicHttpBinding>

    If security mode is None, then System.ServiceModel.ServiceSecurityContext.Current will be null.

    So please try to change your security mode to transport.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by danparker276 Friday, December 6, 2013 3:00 PM
    Friday, December 6, 2013 6:22 AM
    Moderator

All replies

  • Hi,

    I see that you have used the following:

    <basicHttpBinding>
            <binding name="basicBind">
              <security mode="None">
                <transport clientCredentialType="Windows"/>
              </security>
            </binding>
    </basicHttpBinding>

    If security mode is None, then System.ServiceModel.ServiceSecurityContext.Current will be null.

    So please try to change your security mode to transport.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by danparker276 Friday, December 6, 2013 3:00 PM
    Friday, December 6, 2013 6:22 AM
    Moderator
  • Yeah, that's what did it.  I also had to change IIS to accept windows credentials for that site.


    dan

    Friday, December 6, 2013 3:01 PM