Finding the full human name of a system user

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've GOT to be missing something painfully obvious, here...

I need to programmatically get the full human name of the current user on a
local system, the same system upon which the app is running.

Using C#.NET MSDEV2003. OS will be Win2K or WinXP.

I've found numerous ways to get the user name, but have yet to find the way
to get the human name.

Anybody have any wisdom here?

Many thanks in advance,
Jason
 
You can't get anything that is not stored in the system. Unless the users
full name is entered in somewhere as part of being a user.

If you are connected to a network via something like Active Directory then
you can query the catalog for the users name as it is entered in there.
 
I thought so, too, but sadly that gives me the user name, as does
SystemInformation.UserName...
 
Well, the information is available, I'm just missing the mechanism for
getting it. What I'm looking for shows up in the Local Users and Groups
section of the Computer Management app that is part of the Administrative
Tools in Control Panel (this is on Win2K). I understand that if the user
chooses to leave this blank when the user account is created then there would
be nothing to retrieve from here, but my test system has data in this field.

Thanks for the input... the data is definitely available (the Computer
Management app can find it... :) ), so it sure seems that other apps should
be able to do so... I'll keep digging.
 
Just located this via Google:

Dim DomainUser As String =
System.Security.Principal.WindowsIdentity.GetCurrent.Name.Replace("\", "/")
Dim ADEntry As New System.DirectoryServices.DirectoryEntry("WinNT://" &
DomainUser)
Dim FullName As String = ADEntry.Properties("FullName").Value
Have not tried it yet... might work, might not.
 
Thanks, Ray... I saw that one too, and didn't try it because I had hopes of a
simpler (not going to a network) solution...

This does work, though, so I'll use it for now...

I appreciate the help.

Jason
 
You don't necessarily need a network to do this.

The WinNT provider should be able to be used to reach local account data on
a standalone system.

I *think*.
 
Back
Top