Get user first and last name?


 I can use the following to get my users logon name,

If User.Identity.IsAuthenticated Then

Label1.Text = "Welcome, <B>" + User.Identity.Name + "</B>"

Label1.Text = Label1.Text & "Welcome, <B>" + Request.LogonUserIdentity.Name + "</B>"



End If

how do i now get thier first and last names



1/16/2008 2:14:03 PM 27051 articles. 1 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 54

Plz explain  complete requirement and database Entity..? 


Thanks & Regards,
1/16/2008 2:47:30 PM

I am not interacting with a database in any way,

I know my users first and last names are stored as part of thier network ID, i would like to know how to retrieve that information from my network into my webpage, at the moment i can only get their


thanks again


1/16/2008 3:47:08 PM

this works on my local machine but not over my network, any ideas



Dim domainuser As String = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Replace("\", "/")

Dim ADEntry As New System.DirectoryServices.DirectoryEntry("WinNT://" + domainuser)


1/16/2008 4:17:47 PM


In order to communicate with Active Directory and get user's full name on a ASP.NET application, one must have impersonation enabled at the ASP.NET since by default ASP.NET account doesn't have such privileges on the domain, or you'll fall to run this code. Here can find a great little impersonation class on Hope it helps

This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
Best Regards
XiaoYong Dai
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
1/18/2008 9:07:45 AM

Hi , This  may help u


Response.Write(Environment.ProcessorCount + "/" + Environment.MachineName + "/"+ Environment.UserDomainName + "\\" + Environment.UserName + "/" + Environment.GetLogicalDrives().Length +"<BR> MAC Address :");

Response.Write(GetMACAddress()+"<br>Unique Address:");


Response.Write(Request.UserHostAddress + "<br>IP ADDRESS");


private string GetUniqueId()


string macs = "";

// get network interfaces physical addresses

NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();foreach (NetworkInterface ni in interfaces)


PhysicalAddress pa = ni.GetPhysicalAddress();

macs += pa.ToString();



// generate hash

Response.Write("<br>" + macs.ToString() + "<br>");

HMACSHA1 hmac = new HMACSHA1();

hmac.Key = Encoding.ASCII.GetBytes("dummy key");


// convert hash to hex string

StringBuilder sb = new StringBuilder();for (int i = 0; i < hmac.Hash.Length; i++)




// the the final hash as a string

return sb.ToString();


public string GetMACAddress()


string macAddress = null;

ManagementObjectSearcher searcher = new

ManagementObjectSearcher("SELECT MACAddress FROM Win32_NetworkAdapter");foreach (ManagementObject address in searcher.Get())


macAddress = address["MACAddress"] as string;

if ((macAddress != null) && (macAddress != String.Empty))return macAddress;


return String.Empty;


Thanks & Regards,
1/21/2008 4:36:22 AM

Similar Artilces:

Getting first name and last name from Windows logged in user
 I'm sure there must be an easy way of getting the actual first name and last name from an Windows domain\username via the Windows Identity or Principal object, but I can't seem to figure it out. Does anyone have any examples of this? try this: HttpContext.Current.User.Identity.Name  Thanks - tried returns nothing or domain\loginName :( Please check that on the site properties window (in IIS Admin console), in the security tab, click on the modify or edit button in the authentication and anonymous access group and make sure only the "Windows Inte...

How to get domain user's first name, last name and e-mail address
Hi everyone, I am able to retrieve the domain/user ID by setting <authentication mode="Windows"/> in the Web.config file, and with the following code in my Default.aspx.,cs page: string strName = Request.ServerVariables["AUTH_USER"]; I would also like to retrieve the users first name, last name and e-mail address from their domain profile, if possible.  Can anyone help me with a code example?  I'm somewhat new to C#/.NET/OOP so if you have it in "C# for Dummies" format, I would be very thankful! Thanks in advance for any help that i...

Getting the user's first and last name
I'm using the login control and I'm getting the username without a problem (<asp:LoginName ID="LoginName1" runat="server" />) but how do I get the user's first and last name (or any other information)?  I do have the user's information stored in a database.  I'm not utilizing Profile schema either.Thanks. Use the MemberShip class to get the user information.*** If this post helps you, then Mark this post as Answer ***...

Getting user's first and last name from AD
I have an intranet site running with windows authentication, and I would like to greet the user with their full name. What's the best way to find the first and last name values entered in the AD database?I guess it needs a DirectorySearcher object, but my AD knowledge stops there.Thanks,JohnJohn Inflatable Boats You can get the current user's details by parsing their domain name and performing a search for it.  Here is an example - 'sn' and 'givenName' are last name and first name respectively.<%@ Assembly Name="System.DirectoryServices, Version=1.0.5000.0, Cultur...

Get user's first and last name from Active directory.
Hi,I'm trying to get user's first and last name from AD to display in my welcome page. I'm using Visual Studio 2005. In my login page I have login control and I'm using forms authentication against LDAP.So I don't have to store user data. Any help would be greatly appreciated.   DirectoryEntry objOU = new DirectoryEntry(",%20DC=domain,%20DC=something,%20DC=net%20or%20com>/">LDAP://CN=your user name, OU=users group>, DC=domain, DC=something, DC=net or com"); string name = objOU.Properties["givenName"].Value.ToString(); string...

Groupwise user name in pace of first and last name
We meet a strange behaviour with groupwise client ( windows ) in caching mode. since we've chosen "caching mode", Return notification ( popup ) for tracking information display "groupwise username" in place of "first/last Name" Anyone experienced this case ? Thanks -- chabot49 ------------------------------------------------------------------------ chabot49, It appears that in the past few days you have not received a response to your posting. That concerns us, and has triggered this automated reply. Has your problem been ...

Question about usernames, last name first or first name first
I have been looking through all the settings on groupwise and i am yet to find how to change the names from last name first to first name first. My account happens to say Phil Halbasch where others says Halbasch, Phil. If anyone knows of that secret setting to modify this it would be helpful. Thanks, Phil I figured it out, sorry for wasting ur time :) FYI Click Address book Click View tab and then name format "Phil Halbasch" <> wrote in message news:FJrDb.4825$ > I have been looking th...

Users with same first and last name
Our email addressing is first initial and full lastname @ We have students who have the same first name, so we use first 2 initials of first name and full last name @ The problem is sometimes we get errors on the user that has the first initial and full lastname email address stating that there is already a user with that email address. I can't figure out why it does that or how to fix it. We are running GroupWise 7.03 on Netware 6.5 sp5. Thanks, Johnny V. -- johnnyv5 -----------------------------------------------------------------------...

Search by first/last name or just last name?
I have a simple page that searches an access database by first and last name. How would I set it up to search by the first and last name OR just the last name.I tried this:where ([player.first_name] LIKE '%' + ? + '%') and ([player.last_name] LIKE '%' + ? + '%') or  ([player.last_name] LIKE '%' + ? + '%')but it didn't work. Thank you.  You just about got it, you just need a couple more parens, like this:where (([player.first_name] LIKE '%' + ? + '%') and ([player.last_name] LIKE '%' + ? + '%'...

DropDown List: Want to concatenate two fields so it displays "Last Name, First Name" in the ddl text to the user. Sproc for datasource
  I know I can do this if I use a LINQ data source access the tables directly with a LINQ  query, and I know I could modify my stored procedure to return a Last_FirstName field that would already have the name formatted as “Last, First” but I want to know if I can make the drop down list itself deal with this?  I have a sproc that returns EmployeeID, FirstNm, LastNm.  I want the drop down list to display “LastNm, FirstNm” and of course use the EmployeeID as DataValueField. Is there any way I can concatenate the Last and First together with VB.NET when the sproc ret...

Can not get user name from HttpContext.Current.User.Identity.Name
Hi All; I have tried to use HttpContext.Current.User.Identity.Name to get window user account. However, from debugger, for a long time ago I saw my window user name. But now, I did not see my window user name (from debugger) with the same code and same function call. Please help. Was I doing something wrong? Or any special settings on web.config/machine.config or project to make it work??? I'm stuck Thanks a lot well, you have to have windows integrated authentiction enabled in IIS, IIRC.RTFM - straight talk for web developers. Unmoderated, uncensored, occasionally unre...

How to get the user name of a process in
Could anybody tell meHow to get the user/owner name of a process in reason I need it is because I developed an application,which I will put on the winnt enviroment, I want to allow multiple instance.but only allow one single instance per user.I am using Application.Run(MyMainForm) to start my applicationThanks,Joseph...

User's first and last name
What would be the simplest way to add the user's first and last name to the registration process?I noticed there was a comment column in membership user.  Would it be easy to add xml document to this field?Thanks!Rob you can check the link below:Extend the MembershipUser class

Extracting first name, last name, middle name from a string
I have a variable in a stored procedure that puts the first name, last name, and middle name in the format LastName, FirstName MiddleName. (I cannot just used the columns firstname, lastname, etc. as they are not available in the stored proc.) I am trying to split this up so that it reads LastName, [new line] ~r~n FirstName + MiddleName. Any suggestions on extracting this into that format? Any help greatly appreciated. I am working with Infomaker 6.0 and Windows 2000 Thanks, Sean Actually, it's just the format LastName, FirstName so I would only need to search for the comma an...

Web resources about - Get user first and last name? -

Fresh Prince's Janet Hubert Slams Will & Jada Pinkett-Smith's Oscars 2016 Boycott Again
Will Smith ‘s former Fresh Prince of Bel-Air co-star Janet Hubert called out him and his wife Jada Pinkett-Smith ‘s Oscars 2016 boycott earlier ...

Moviefone Founder Andrew Jarecki Launches iOS Video Editing App KnowMe with Backing From J.J. Abrams
Online video stage fright is real. We all love to watch videos on YouTube, Vine or Instagram — but when it comes to turning the camera onto ourselves, ...

The Force is with this beautiful short Star Wars fan movie
Kara, protected by her father, stumbles through the sands of Jakku as a dogfight erupts overhead. Where is she headed? Joe Sill 's fan movie ...

David Axelrod: Hillary’s Private Email Sever Was ‘Not Good Judgment’
Former Obama advisor David Axelrod chastised his former boss’ Secretary of State Hillary Clinton for her use of private email, saying on CNN’s ...

How the WaPo whitewashed the Flint water disaster
I’m one of those masochists who signs up for daily email alerts from several news services just to keep tabs on the stories I might miss on cable ...

U.S. stocks open slightly higher as crude oil price stabilizes
U.S. stocks are moving higher Thursday, led by gains in energy companies as the prices of crude oil and natural gas recover from steep plunges ...

Two giant planets detected around an evolved intermediate-mass star
(—HD 47366 is an evolved star almost twice as massive as our sun. Located about 260 light years from the Earth, the star is approximately ...

Google Blocked 780 Million Bad Ads Last Year, Up From 524 Million In 2014
Google today released its annual report on the state of its advertising business, as it relates to the company’s ability to block bad ads – meaning ...

Pakistan attack raises tough question: should teachers shoot back?
By Jibran Ahmed and Tommy Wilkes CHARSADDA, Pakistan/ISLAMABAD (Reuters) - Stuck with 15 of his students on a third floor balcony of a campus ...

Thorough, not thoroughly fabricated: The truth about global temperature data
(credit: Scott K. Johnson/Suzanna Soileau-USGS/Hanna-Barbera) “In June, NOAA employees altered temperature data to get politically correct results.” ...

Resources last updated: 1/21/2016 4:14:44 PM