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.Servervariabl es("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
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.Servervariabl
'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-
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
Try this
strUsername = Trim(Request.ServerVariabl es("AUTH_U SER"))
strUsername = Trim(Request.ServerVariabl
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.Nam e
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?
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
Fullname=User.Identity.Nam
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
just change the syntax... it should work fine for vb.net
response.write(System.User