locked
Creating a WCF RIA Service for Visual Studio LightSwitch 2013 RRS feed

All replies

  • Hi ADefwebserver,

    Well Done!

    It is very kind of you for sharing this to us.

    Thank you.

    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, October 7, 2013 8:51 AM
    Moderator
  • Hi ADefwebserver!

    I have a qeustion. Is there any way to get windows  user in WCF RIA service who is running the app?

    In WCF RIA service I have a web service call and I need to pass a user to the service. Environment.UserName returns  DefaultAppPool inside RIA service.

    Any suggestions?

    Thanks!

    Nick

    Monday, October 7, 2013 11:47 PM
  • Sorry I don't have any examples and I have not done that. Everything I do is web based using forms authentication. I had to do a lot of Googling to get the Forms authentication user in this article:

    LightSwitch Survey: Handling Complex Business Logic Using WCF RIA Services

            public void UpdateQuestionDetailForUser(QuestionDetailForUser objQuestionDetailForUser)
            {
                // Get the current user
                string strCurrentUserName = System.Web.HttpContext.Current.User.Identity.Name;
                // We are under Forms Authentication so if user is blank then we
                // are debugging and we are TestUser
                if (strCurrentUserName == "")
                {
                    strCurrentUserName = "TestUser";
                }
    
    


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com

    Monday, October 7, 2013 11:54 PM
  • I believe the LS server context exposes the current username... Might have to dig around a bit to see exactly where, but I recall something like this.

    Regards, Xander. My Blog

    Tuesday, October 8, 2013 12:57 AM
  • Here is code!

            public static string CurrentUserName
            {
                get
                {
                    System.Security.Principal.IPrincipal _User;
                    _User = System.Web.HttpContext.Current.User;
                    System.Security.Principal.IIdentity _Identity;
                    _Identity = _User.Identity;
                    string _Value;
                    _Value = _Identity.Name.Substring(_Identity.Name.IndexOf(@"\") + 1);
                    return _Value;
                }
            }

    Tuesday, October 8, 2013 2:13 AM