none
How to determine username of the logged in client user RRS feed

  • Question

  • I have a web service with 3 methods. The web service is used by a website to make backend calls. Out of the three methods, in one of the methods I need to determine the username of the user who made that action on the website which triggered the web service call. Is there a way to do this without passing in the username as a parameter to the web service? I am using wshttp binding and it is possible for me to change it if required.

    Thanks.

    Friday, January 24, 2014 7:10 PM

All replies

  • Hi,

    If you want just the username:

    OperationContext.Current.ServiceSecurityContext.PrimaryIdentity.Name

    If you want both the username and password, Rory Primrose explains it in his article WCF Security: Getting the password of the user .

    Also please try to check this similar thread:
    http://stackoverflow.com/questions/16762651/finding-the-identity-of-someone-logged-on-a-website-through-wcf .

    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.

    Monday, January 27, 2014 2:37 AM
    Moderator
  • Thanks for the reply Amy. I tried the property you provided but it looks like it always returns the user with which the website was installed rather than the user using the website.Here is my client config:

    <binding name="zzz" closeTimeout="00:01:00"
              openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
              allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
              maxBufferPoolSize="524288" maxReceivedMessageSize="6553600"
              messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
              <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                maxBytesPerRead="4096" maxNameTableCharCount="16384" />
              <security mode="Message">
                <transport clientCredentialType="Windows" />
                <message clientCredentialType="Windows" />
              </security>
            </binding>
          </wsHttpBinding>

    Any thoughts on what I might need to tweak?

    Thanks

    Wednesday, January 29, 2014 12:13 AM