Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Current User Name

Status
Not open for further replies.

AtomicChip

Programmer
May 15, 2001
622
CA
I'm developing an intranet site, and I'm looking into ways of getting the user's name without requiring them to log in with their Windows username and password. The way that I'm doing this right now is:

Web.Config file:

<configuration>
<system.web>
<authentication mode=&quot;Windows&quot; />
</system.web>
</configuration>

index.aspx file:

<%@ Page Language=&quot;c#&quot; %>
<%@ Import Namespace=&quot;System.Security.Principal&quot; %>

<script runat=&quot;server&quot;>

private void Page_Load(System.Object sender, System.EventArgs e)
{

WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());

Response.Write (wp.Identity.Name);

}

</script>

<body>

This is pulling the machine name, but I'm trying to get the user name. Am I close here, or am I barking up the wrong tree? Any help would be definitely appreciated. -----------------------------------------------
&quot;The night sky over the planet Krikkit is the least interesting sight in the entire universe.&quot;
-Hitch Hiker's Guide To The Galaxy
 
I've very little experience with this but I seem to remember using the syntax System.Environment.User (or Username) and retrieving the name of the user logged onto the client machine.
Admiteddly this was in a standard desktop windows application using C# - but the code should still stand.
Hope that this helps.
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top