Get a User ID from Active Directory

Hello,

 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?? 

Rich

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()
7    {
8   
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)
13   {
14   windowsLogin = windowsLogin.Remove(0, hasDomain + 1);
15   } //end if
16   return windowsLogin;
17   } //end GetCurrentUserWindowsLogin

0
Rich11
8/31/2007 4:20:11 PM
asp.net.active-directory-ldap 2291 articles. 0 followers. Follow

1 Replies
648 Views

Similar Articles

[PageSpeed] 32

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.

Good luck! 


If this post was useful to you, please mark it as answer. Thank you!
0
johram
8/31/2007 9:21:20 PM
Reply: