Link to home
Start Free TrialLog in
Avatar of ktrimmer
ktrimmer

asked on

ASP.Net and FullName

My goal is to retreive the FullName of the user logged into the computer.
I have done this in ASP but I can't get it to work in ASP.Net

This is what I have done in ASP
<%
'This pulls the Username of whoever is signed on and trims off the empty space
      strUsername = Trim(Request.Servervariables("Logon_User"))

'Separate the domain and the username
'The "\" is the separator between the domain and username
      Position = InStr(strUsername,"\")
'The we create two variables from Username
      DomainName = Left(strUsername,Position-1)
      UserAccount = Mid(strUsername,Position+1)

'Now we will use ADSI to retrive the Full Username as described on the server
      Set objUser = GetObject("WinNT://" & DomainName & "/" & UserAccount)
Session("FullName") = objUser.Fullname

%>

How can I do this in ASP.Net
Avatar of nishikanth
nishikanth

use System.UserName
response.write(System.UserName)

Try this

strUsername = Trim(Request.ServerVariables("AUTH_USER"))

Avatar of ktrimmer

ASKER

Okay, What I need to be returned is the Full Name.

Fraserdickson, the answer you gave returns the Username of the person.
Nishikanth. I am not sure what you ment by System.Username. I tried the code like you posted but it returned an error. So, I  added

<%@ Import Namespace="System.Security.Principal" %>

 Fullname=User.Identity.Name

Which i think is what you ment byt the system.username. but I am not sure.
anyway, both of them returned just the username.

any more ideas?
ASKER CERTIFIED SOLUTION
Avatar of nishikanth
nishikanth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for the dely in posting a reply.
nishikanth,
The posting above do I place that in <Script> Tags?
I am assuming it runs at the client side.
I have not worked with C# although its on my list of things to learn.  Are you able to post it in VB.net. If not I will try this out
that's a server side coe... pls place it in the code behind...
just change the syntax... it should work fine for vb.net