I have been searching through the forums and came across this code.. All i want to do is to find who is loggin when when the open my company's intranet. Only problem is that we use a thin desktop client. We do have windows login, but they might not be the person logging onto the intranet. Since they have to log in to Citrix before then can access the intranet.
Can this code be edited for Citrix??
1 /// <summary>
2 /// Gets the windows login for the currently logged in user in the client computer i.e
3 /// the person requesting the page
4 /// </summary>
5 /// <returns>The username of the user requesting the page, might contain domain</returns>
6 public string GetCurrentUserWindowsLogin()
9 string windowsLogin = Page.User.Identity.Name;
10 //Normally if the domain is present you get a string like DOMAINNAME\username, remove the domain
11 int hasDomain = windowsLogin.IndexOf(@"\");
12 if (hasDomain > 0)
14 windowsLogin = windowsLogin.Remove(0, hasDomain + 1);
15 } //end if
16 return windowsLogin;
17 } //end GetCurrentUserWindowsLogin
One thing you can do is to use integrated security in your intranet. That way, the browser (IE) will automagically send your windows credentials for authentication against the server, so you will be able to tell on the server who is accessing the web. Then this code should work for you, regardless of thin clients.
Do you need the code specifically in a web, or in a console app?
Regarding Citrix, it depends on how you are using it. But everywhere you use integrated security, it will give you the current windows user, even if running in Citrix.
If this post was useful to you, please mark it as answer. Thank you!